Simulate production in your Laravel tests
In this video, Michael steps a natural approache on how to test environment specific functionality.
In this video, Michael steps a natural approache on how to test environment specific functionality.
I've used this little bash alias for many years to quickly run the tests inside of a project.
alias p="vendor/bin/phpunit"
With this alias in place, I can run the tests by typing "p" on the CLI. Nice!
For a long time, everything was great! But then, Pest appeared on the scene. It's an alternative test runner for PHP with a high focus on developer experience.
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’s newsletter is one of the best ways to stay updated with the Laravel and PHP ecosystem. It consistently highlights useful packages, tools, and ideas from the community, especially the amazing work coming from Spatie. As a Laravel developer building SaaS and web platforms, I find it extremely helpful to discover practical tools and insights that improve my development workflow."
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?
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]