How to test that an Eloquent model actually exists original
In your tests, you might have used assertDatabaseHas to make sure that a model actual is persisted.
Posts tagged with testing
In your tests, you might have used assertDatabaseHas to make sure that a model actual is persisted.
Have you ever had to write an API integration from scratch? Where you're managing the HTTP calls yourself instead of being able to rely on third-party packages?
Join 9,500+ smart developers
Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.
No spam. Unsubscribe anytime. You can also follow me on X.
"Freek publishes a super resourceful and practical newsletter. A must for anyone in the Laravel space"
In this video, which is part of the Testing Laravel video course, I explain the benefits of testing.
Read more [spatie.be]
- submitted by Mateus Guimarães
Mateus Guimaraes show a couple of neat tests powered by Pest.
Mocking, faking; these might sound like intimidating words if you don't know what they are about, but once you do, you'll be able to improve your testing skills significantly.
Part of "the art of testing" is being able to test code in some level of isolation to make sure a test suite is trustworthy and versatile. These topics are so important that we actually made five or six videos on them in our Testing Laravel course.
In this post, I want to share three ways how you can deal with mocking and faking. Let's dive in!
One of the things I really like about modern Laravel projects, are the new model factories introduced in Laravel 8.
Testing a Laravel project is one of the most pleasant experiences I've ever had: there's a clean testing API, a very powerful layer added on top of testing frameworks; all while keeping the simplicity and eloquence you'd expect from a Laravel project.
This edition of the meetup features those two excellent talks:
– ryangjchandler.co.uk - submitted by Ryan Chandler
Let's look at how we can use Pest's Expectation API with array items.
Want to learn more about testing and/or Pest? Check out Testing Laravel
Read more [ryangjchandler.co.uk]
While recording videos for the Testing Laravel video course, I became a big fan of Pest, a test runner that tries to optimize the developer experience. I'm now using Pest as the default for testing new packages and projects.
I've also converted a couple of existing testsuites from PHPUnit to Pest. Luckily, this is a very easy process. In this video I'll show you how to get started. You'll see that it only takes a couple of minutes.
Jason McCreary explains why and how he created his cool Pest converter
Read more [jasonmccreary.me]
Data providers are a PHPUnit feature (and many testing frameworks have an equivalent) that lets you run a single test method multiple times but with different data. Larry Garflied shows some cool things you can do with them.
Read more [peakd.com]
In this stream, Luke Downing shows us around in the source code of Pest parallel plugin he created.
In this video, my colleague Brent explains a good way to test a form in a Laravel app.
This video is part of our new premium video course Testing Laravel.
In this stream, Brent and I showcase some cool techniques we use in our test suites.
I've been creating web applications for over 15 years now. It's only in the last five years that I've learned how to test an application automatically. I can safely say that there is no other technique that has improved the quality of my code more.
Let's go over what a test is and all the benefits it provides.
Read more [testing-laravel.com]
In this video, which is part of the Testing Laravel video course, I explain to cool ways to test middleware in Laravel.
In this video, we're using Pest, but you can easily use the techniques in a PHPUnit testsuite as well.
Native PHP functionality and having a good design in the first place provide everything you need to avoid a mocking library.
Read more [peakd.com]
In this stream, Pest creator Nuno Maduro explains how his testing tool works under the hood.
If you want to know how to use Pest (or PHPUnit) to test your application code, consider picking up our Testing Laravel video course.
Knowing how to write automated tests is a fundamental skill for any developer. By adding a quality test suite to your application, you'll end up with fewer bugs in production. It allows you to refactor with confidence using a test suite that has your back.
We're currently recording a new premium video course called Testing Laravel. It will be released in September.