Now, I will show a few assertions related to text data to check something within a string. We will look at the examples from open-source projects.
Pest and PHPUnit Syntax Differences
In this course, we're trying to cover both tools. String assertion is the (rare) case when the syntax is slightly different.
The assertStringStartsWith()
and other similar string assertions are for PHPUnit. We will look at those examples later in the lesson.
With Pest, you would use expectations with equivalent methods. For example, an equivalent to the assertStringContainsString()
method in Pest would be toContain()
.
Laravel.io Example: Look for a Phrase in Email
In the open-source example from a laravelio/laravel.io project, we can see...