Laravel 8.55, weekly updates, and 🔥 tip
Laravel 8.55
There are a lot of new features this week, mostly from the papercuts Taylor focused on. This brings Laravel to 8.55.0.
Here are the highlights:
- Fix
firstOrCreate
andfirstOrNew
attributes merge in #38346 - Add stringable support for
isUuid
in #38330 - Allow for closure reflection on all Mail fake assertions in #38328
- Add
assertNothingOutgoing
andassertNotOutgoing
to Mail fake in 363af479 and a3658c93 - Support
withTrashed
on routes with model bindings in #38348 - Add
Rule::when
for conditional validation in #38361 - Added
assertRedirectToSignedRoute
for testing responses in #38349 - Support union types on event discovery in #38383
- Add
assertInvalid
andassertValid
in #38384 AddqualifyColumns
method to qualify multiple columns in #38403
You may review the full branch diff on GitHub for a complete list of changes.
This version bump and update is automated for subscribers to a Shifty Plan. If you don't have one of those, be sure to bump your constraint and run composer update
to get the latest features.
Weekly Journal
Last week Jess and I finished tracking the PHP version of common packages. Previously many of the Shifts and Workbench tasks would bump package dependencies to the latest version.
However, this did not take into consideration any PHP version constraints. So you may have ended up with a package which requires PHP 8.0, even though you are running PHP 7.4.
Shift will now honor any specific PHP version set within your composer.json
and use that when bumping your package dependency. To ensure you receive the proper bumps, review your composer.json
file to ensure require the PHP version you're using. For example, "php": "~7.4.1"
or "php": "8.0.x"
.
I normally reserve this part of the year for building the new Laravel Shifts. But since Laravel 9 has been pushed out to next January, I have some free time. So this week Jess and I are fixing some tiny bugs reported in older Shifts.
I also spent some time on Blueprint. Several open issues and PRs have built up over the last few months. It's actually become a bit unwieldy because of the support for older Laravel versions. This is something I ranted about on Twitter last week.
This morning I tagged Blueprint 2.0.0. This is really a superficial version bump to mark the adoption of the new policy to only support the latest, stable Laravel version.
After these, I'm considering using any remaining downtime to create a PHPUnit to Pest Shift. A few members of the community have expressed strong interest in this automation. Generally speaking this isn't necessarily a good indication of demand. But, I think I could crank out an MVP during this gap, and with the growing interest in Pest, it would be a natural addition to the existing Laravel Shifts. So you may be hearing more about that in the coming weeks.
🔥 Tip
It was nice to see many of the additions this week relating to testing. As more and more developers begin testing their application, I think we will continue to see more improvements to Laravel's testing layer.
One of which I suggested was a single Mail assertion. I found myself writing a few tests which used both assertNothingSent
and assertNothingQueue
. It was pretty easy to wrap this in a custom macro, but now there's a native assertion - assertNothingOutgoing()
When suggestion this assertion (and others) there were some questions about its need. Which brings us to this week's tip.
I like to ensure my test focus on what is expected and isolate that behavior. In this case, I want to make sure that mail, and only that mail, was sent.
I consider it an implementation detail whether the mail was sent directly or queued. So while I could use assetNothingQueued
now, what if in the future I changed the code to send it directly - the test would still pass.
While I don't like defensively testing all potential code paths. I do like to lock down the assertions I am making to strictly check that code path.