Skip to main content

Testing Strings: Expect toContain

Premium
4 min read

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...

The Full Lesson is Only for Premium Members

Want to access all of our courses? (30 h 33 min)

You also get:

55 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

No comments yet…

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.