6 pull requests merged in Laravel during week 34 of 2023

6 pull requests merged in Laravel during week 34 of 2023

Published
Sep 1, 2023
Written by
Benjamin Crozat
0
comments
3 minutes
read

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!

About Benjamin Crozat
Benjamin Crozat

Hi! I’m from the South of France and I’ve been a self-taught web developer since 2006. When I started learning PHP and JavaScript, PHP 4 was still widely used, Internet Explorer 6 ruled the world, and we used DHTML to add falling snow on websites.

Being able to educate myself for free on the web changed my life for the better. Giving back to the community was a natural direction in my career and I truly enjoy it.

Therefore, I decided to take action:

  1. I launched this blog in September 2022 with the goal to be in everyone’s Google search. I get more than tens of thousands of monthly clicks from it and even more visits overall (my analytics dashboard is public by the way).
  2. I also started growing my X (formerly Twitter) account at the same time, which has now over 7,000 followers.
  3. All the content I write is free thanks to my sponsors.

I also want to be completely free with my time and make a living with my own products. In April 2024, I launched Nobinge, a tool to summarize and chat with your content, including YouTube videos.

Believe me, I’m just getting started!

0 comments

You need to be signed in to comment this post.
Sign in with GitHub