Back to Course |
Testing in Laravel 11: Advanced Level

Links to Other Assertions

Before finishing this section, I want to mention other available assertions. But I don't want to list all of them, so I will provide a set of useful links.

  1. Assertions for HTTP requests - https://laravel.com/docs/http-tests#available-assertions
  2. Database assertions - https://laravel.com/docs/database-testing#available-assertions
  3. If you are using browser testing, then Dusk assertions - https://laravel.com/docs/dusk#available-assertions
  4. And assertions for console tests - https://laravel.com/docs/console-tests

Also, because Laravel uses PHPUnit for testing, you can check the assertions in the PHPUnit docs.

If you use the Pest framework, you can still use the same assertions from PHPUnit. Because under the hood Pest requires PHPUnit.

But, for Pest, you mainly will use expectations, which Pest have quite a lot.

Finally, if you don't find a method that tests what you need, as a final resort, you may use assertTrue() or expect($value)->toBeTrue() with any condition.

For example, if you search for toBeTrue() on the laravelio/laravel.io, you will find multiple expectation like that.