I created an easy to use API to help businesses do incredible things with AI.
Laravel

6 pull requests merged in Laravel during week 34 of 2023

Benjamin Crozat
Published on Sep 1, 2023 0 comments Edit on GitHub
6 pull requests merged in Laravel during week 34 of 2023

Introduction

Buckle up, esteemed colleagues! Some of this week’s merged pull requests in Laravel give us a mix of improved testing capabilities, seamless handling of job lifecycle hooks, updates for query builders and relations, and additional support for failed job providers!

What was merged in Laravel

A more reliable way to test jobs with BusFake and QueueFake

In the first highlight of the week, Luke Kuzmish brings us a wonderful addition to enhance our testing capabilities. The serializeAndRestoreJobs() method simulates the queuing process and detects potential serialization errors during tests rather than waiting for unpleasant surprises in production. This baby makes test suite failures easier to anticipate and debug! Amazing, right? Kudos to Luke!

Learn more from pull request #1483009836.

public function testCanDispatchJobImproved()
{
    Queue::fake()->serializeAndRestore();

    MyJob::dispatch(fn() => true); // ❌ Exception  Serialization of 'Closure' is not allowed. 🥳 
}

createOrFirst() now plays nice with transactions

Next, we see an astute fix by Tony Messias on createOrFirst methods in transactions. Using the new withSavepointIfNeeded(fn) method, Tony ensures that the create or attach parts get wrapped within a save point transaction, alleviating issues that might occur without it. A big thumbs-up to Tony!

Catch all the sparkles in pull request #1485758586.

Countable failed job providers

Tim MacDonald swoops in with a solution for more efficient handling of failed jobs. By making the 1st party drivers Countable without introducing a new method on the interface, Tim saves us from retrieve all records into memory and perform an in-memory count. A life-saver for applications with a large volume of failed jobs! Hats off to Tim!

Check out all details in pull request #1489028327.

Job UUID in the JobQueued event

Tim is back in action with an addition that makes tracking a job from being queued to all its lifecycle hooks easier. By providing access to the job’s UUID, which doesn’t change when a job fails and is retried, we get a robust solution for handling job lifecycle hooks. Top-notch work, Tim!

Get more insights from pull request #1489134277.

Artisan becomes more flexible

Nuno Maduro spices things up with his work on slimming Laravel’s 11 skeleton. He allows for chaining a schedule methods directly on the Artisan::command call, which makes the syntax more concise and easier to read. Keep it up, Nuno!

Flex into pull request #1484641172.

A new and more relaxed JSON assertion

In his PR, Günther Debrauwer brilliantly circumvents a common issue when testing API calls by introducing the new method assertJsonPathCanonicalizing. Once more, testing within Laravel becomes a smoother process thanks to Günther’s contribution!

Deep dive into pull request #1480973461.

$users = User::factory()->count(2)->create();

$this->get('/api/users')->assertJsonPathCanonicalizing('data.*.id', $users->pluck('id')->all());

Conclusion

That’s all for this week, folks! I hope you found these updates enlightening.

Are you ready to dive into the next week’s Laravel adventures? I’ll bring you more stories of code bravado and technical brilliance. Remember to share these updates with your teammates and other developers who work with Laravel. Happy coding!

Be the first to comment!

Get help or share something of value with other readers!

Great deals for enterprise developers
  • Summarize and talk to YouTube videos. Bypass ads, sponsors, chit-chat, and get to the point.
    Try Nobinge →
  • Monitor the health of your apps: downtimes, certificates, broken links, and more.
    20% off the first 3 months using the promo code CROZAT.
    Try Oh Dear for free
  • Keep the customers coming; monitor your Google rankings.
    30% off your first month using the promo code WELCOME30
    Try Wincher for free →
The latest community links
- / -