Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Getting Started with PHP Unit Testing!
You have completed Getting Started with PHP Unit Testing!
Preview
Consonant Clusters
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Consonant blends, also called consonant
clusters, are two or three consonants
0:01
that make a distinct consonant sound,
as in the tr of treehouse.
0:06
When a word starts with
these consonant blends,
0:11
then we want to take that first sound and
move it to the end of the word.
0:14
We're going to test these two and
three consonant blends separately.
0:19
A two-letter blend is called a digraph,
and
0:24
a three-letter blend is called a trigraph.
0:27
Let's go back to our code.
0:31
We're going to add a new test for
digraphs.
0:33
We can copy this test.
0:40
And change convertDiagraphWordToPigLatin,
0:47
our word will need to be a diagraph.
0:52
We'll use treehouse.
0:56
And our expected results
will be eehousetray.
1:02
Now we're ready to run our test.
1:07
Our diagraph converson fails
because our convert method is only
1:11
using the first letter of the word.
1:16
We need to update our convert method.
1:19
We'll start by adding
a digraph array to our class.
1:22
Next, in our convert method,
1:32
we're going to add a second variable,
firstTwoLetters.
1:35
Again, we can use a substring of the word.
1:40
Start at the beginning and
give 2 characters.
1:44
Next, we'll add a conditional.
1:47
We'll check if (in_array),
1:50
we want to use the $firstTwoLetters and
1:54
check our $this->, digraphs array.
1:59
We can duplicate these two
lines from creating a new word.
2:09
Instead of starting after the first
character, we'll start after the second.
2:15
And we'll use first 2 letters.
2:20
Then we'll add an else.
2:24
Here we'll have our original conversion.
2:28
Either way, we want to return the new
word, let's run our test again.
2:32
This time, we see that our tests pass,
let's add a test for trigraphs next.
2:38
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up