Drying up test coverage using model scope events
β devonmather.dev - submitted by Devon Mather
Let's explore the option of firing events on model scopes to add some glue between our feature tests and our unit tests.
Read more [devonmather.dev]
β devonmather.dev - submitted by Devon Mather
Let's explore the option of firing events on model scopes to add some glue between our feature tests and our unit tests.
Read more [devonmather.dev]
Last week, Caleb tweeted about a nifty function called invade - that he had made to easily work with private properties and methods.
π Whatcha think of my new favorite helper method?
— Caleb Porzio (@calebporzio) February 11, 2022
That property/method protected or private? No problemoooo π pic.twitter.com/HqMXKKpRsJ
He added that invade function to Livewire. Because I could see myself using this in non-Laravel projects, I packaged up the function in a new package called spatie/invade.
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."
Last year, Laracon held another online edition in the summer. All of the videos are now publicly viewable. You'll find them in this playlist on YouTube.
I had the honour of doing a short talk on snapshot testing in PHP, which you can watch below.
β downing.tech
Here's how Luke Downing goes about testing environment specific things.
Read more [downing.tech]
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.
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?
β spatie.be
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.
β jasonmccreary.me
Jason McCreary explains why and how he created his cool Pest converter
Read more [jasonmccreary.me]
β peakd.com
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.