Skip to content

[11.x] add assertFailedWith to InteractsWithQueue trait#53980

Merged
taylorotwell merged 5 commits intolaravel:11.xfrom
teddy-francfort:interact-with-queues-assert-failed-with
Dec 27, 2024
Merged

[11.x] add assertFailedWith to InteractsWithQueue trait#53980
taylorotwell merged 5 commits intolaravel:11.xfrom
teddy-francfort:interact-with-queues-assert-failed-with

Conversation

@teddy-francfort
Copy link
Copy Markdown
Contributor

This PR improves testing job's queue interactions for manually failed jobs by adding a new method assertFailedWith.
The existing method assertFailed does not allow to check the failing exception.

When manually failing the job, we can now check for the failure exception.

use App\Jobs\ProcessPodcast;
use App\Exceptions\MyException;
 
$job = (new ProcessPodcast)->withFakeQueueInteractions();
 
$job->assertFailedWith('whoops');
$job->assertFailedWith(MyException::class);
$job->assertFailedWith(new MyException);
$job->assertFailedWith(new MyException(message: 'whoops'));
$job->assertFailedWith(new MyException(message: 'whoops', code: 123));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants