Never Miss a Laravel Release ๐
The Laravel team released version 12.38.0, adding a WithCachedRoutes test trait, a WithCachedConfig test trait, a model prompt for the model:show command, and more.
WithCachedRoutes Testing Trait
Luke Kuzmish contributed the WithCachedRoutes trait, which builds routes once and stores them in memory. Routes are only built once for all tests in your test suite:
use App\Http\Controllers\UserController;use Illuminate\Foundation\Testing\WithCachedRoutes;use Tests\TestCase; // Pestpest()->use(WithCachedRoutes::class); test('basic example', function () { $this->get(action([UserController::class, 'index'])); // ...}); // PHPUnitclass BasicTest extends TestCase{ use WithCachedRoutes; /** * A basic functional test example. */ public function test_basic_example(): void { $response = $this->get(action([UserController::class, 'index'])); // ... }}
See Pull Request #57623 for more info.
WithCachedConfig Testing Trait
Luke Kuzmish contributed a WithCachedConfig trait, which builds the configuration in your app once and reuses it for all tests:
use Illuminate\Foundation\Testing\WithCachedConfig;use Tests\TestCase; // Pestpest()->use(WithCachedConfig::class); test('modifies config', function () { config(['services.postmark.key' => 'xyz']); expect(config('services.postmark.key'))->toBe('xyz');}); test('uses default config', function () { expect(config('services.postmark.key'))->not->toBe('xyz');}); // PHPUnitclass ConfigTest extends TestCase{ use WithCachedConfig; /** * A test that modifies the config. */ public function test_modifies_config(): void { $this->assertEquals('xyz', config('services.postmark.key')); } /** * A test that makes no modification to the config. */ public function test_uses_default_config(): void { $this->assertNotEquals('xyz', config('services.postmark.key')); }}
See Pull Request #57663 for more info.
The model:show Command Now Prompts for Input
Razin Shaikh contributed an update to the model:show command to prompt for input when you run the command without arguments. Here's a before-and-after example:
See Pull Request #57671 for more info.
Release notes
You can see the complete list of new features and updates below and the diff between 12.37.0 and 12.38.0 on GitHub. The following release notes are directly from the changelog:
v12.38.0
- [12.x] Cache the result of
configurationIsCached()by @cosmastech in https://github.com/laravel/framework/pull/57665 - [12.x] model:show command prompt for missing input with model suggestion by @mrazinshaikh in https://github.com/laravel/framework/pull/57671
- Don't call Model::toArray() to get attributes for factory insert by @riesjart in https://github.com/laravel/framework/pull/57670
- [12.x] Introduce
WithCachedRoutestesting trait by @cosmastech in https://github.com/laravel/framework/pull/57623 - [12.x] Add missing separators to
Stringable::ucwordsby @kichetof in https://github.com/laravel/framework/pull/57688 - [12.x] Cache result of
Application@routesAreCached()by @cosmastech in https://github.com/laravel/framework/pull/57687 - fix phpdoc return of HasAttributes::getArrayAttributeWithValue by @chuckadams in https://github.com/laravel/framework/pull/57691
- [12.x] Remove unnecessary imports from BackgroundQueue and DeferredQueue. by @seriquynh in https://github.com/laravel/framework/pull/57699
- [12.x] add SQLite support for whereNotMorphedTo method by @faisuc in https://github.com/laravel/framework/pull/57698
- [12.x] Handle AWS ElasticCache failover by reconnecting when READONLY by @wsamoht in https://github.com/laravel/framework/pull/57685
- [12.x] Introduce
WithCachedConfigtesting trait by @cosmastech in https://github.com/laravel/framework/pull/57663 - [12.x] Fix WithCachedConfig@tearDownWithCachedConfig() by @cosmastech in https://github.com/laravel/framework/pull/57708
- [12.x] Reorder some core aliases in alphabetical order. by @kevinb1989 in https://github.com/laravel/framework/pull/57706
- Allow Resend ^1.0 by @ziming in https://github.com/laravel/framework/pull/57713
- [12.x] memoize result of
Application@eventsAreCached()by @cosmastech in https://github.com/laravel/framework/pull/57709 - [12.x] Test
Factory@insert()with hidden by @cosmastech in https://github.com/laravel/framework/pull/57722 - [12.x] Separate workflow for Redis integration tests by @vadimonus in https://github.com/laravel/framework/pull/57710
- [12.x] Types: HasDatabaseNotifications read/unread notifications by @liamduckett in https://github.com/laravel/framework/pull/57718
- [12.x] Supports Symfony 7.4 by @crynobone in https://github.com/laravel/framework/pull/57724
- [12.x] Revert lowercasing validation message placeholders by @florianraith in https://github.com/laravel/framework/pull/57733
- [12.x] try another way to activate Broadcast routes by @browner12 in https://github.com/laravel/framework/pull/57734
- [12.x] Add environment information to json output of schedule:list command by @mmachatschek in https://github.com/laravel/framework/pull/57741
- [12.x] Make DumpCommand prohibitable by @jackbayliss in https://github.com/laravel/framework/pull/57735
- [12.x] Clean ConsoleApplicationTest by @seriquynh in https://github.com/laravel/framework/pull/57761
- [12.x] Fix the docblock of the BroadcastManager::purge method. by @seriquynh in https://github.com/laravel/framework/pull/57758
- [12.x] Fix setting request exception truncating doesn't work on HTTP layer when configured inside
bootstrap/app.phpby @crynobone in https://github.com/laravel/framework/pull/57759