Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

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? (31 h 16 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…