Laravel 10.22 Released
September 6th, 2023
Via:
Laravel News
This week, the Laravel team released v10.21.1 and v10.22 with ULID testing helpers, precognition testing helpers, Enum support in Rule::in() and Rule::notIn() validation rules, and more:
ULID testing helpers
Jason Jones contributed testing helpers for the generation of ULIDs to match testing helpers created for UUIDs:
$ulid = Str::ulid();
Str::createUlidsUsing(fn() => $ulid);
Str::ulid() === $ulid; // true
// Freeze ULID generation then restore generation
$ulid = Str::freezeUlids();
Str::ulid() === Str::ulid() === $ulid; // true
Str::createUlidsNormally();
// Freeze for the duration of the closure
Str::freezeUlids(function ($ulid) {
Str::ulid() === Str::ulid() === $ulid; // true
});
Str::ulid() === Str::ulid(); // false
// Sequences of ULIDs
Str::createUlidsUsingSequence([
$zeroth = Str::ulid(),
$first = Str::ulid(),
]);
Str::ulid() === $zeroth;
Str::ulid() === $first;
Str::ulid(); // back to normally generated ULIDs.
I didn't list the entire API available; you can check out Pull Request #48276 for more details.
Precognition testing helpers
Peter Fox contributed testing helpers for Laravel Precognition
$this->withPrecognition()
->get('/')
->assertSuccessfulPrecognition();
Enum support for in and notIn validation rules
Tim Geisendoerfer contributed enum support for the Rule::in()
and Rule::notIn()
validation rules:
enum Color: string
{
case RED = 'red';
case GREEN = 'green';
case BLUE = 'blue';
}
// Use the Color enum with Rule::in()
Validator::validate(
['color'=>'green'],
[
'color'=> [
Rule::in([Color::RED, Color::GREEN])
]
],
);
Release notes
You can see the complete list of new features and updates below and the diff between 10.21.0 and 10.22.0 on GitHub. The following release notes are directly from the changelog: