Skip to content

[12.x] Add test coverage for filtering failed jobs by connection and queue #55441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions tests/Queue/DatabaseFailedJobProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,27 @@ public function testJobsCanBeCountedByQueueAndConnection()
$this->assertSame(2, $this->provider->count('connection-2', 'queue-1'));
}

public function testCanRetrieveFailedJobsByConnectionAndQueue()
{
$this->provider->log('email-conn', 'notifications', json_encode(['uuid' => (string) Str::uuid()]), new RuntimeException('Email error'));
$this->provider->log('email-conn', 'notifications', json_encode(['uuid' => (string) Str::uuid()]), new RuntimeException('Email error 2'));
$this->provider->log('email-conn', 'general', json_encode(['uuid' => (string) Str::uuid()]), new RuntimeException('Other error'));
$this->provider->log('sms-conn', 'notifications', json_encode(['uuid' => (string) Str::uuid()]), new RuntimeException('SMS error'));

$emailNotificationJobs = $this->failedJobsTable()
->where('connection', 'email-conn')
->where('queue', 'notifications')
->get();

$this->assertCount(2, $emailNotificationJobs);

foreach ($emailNotificationJobs as $job) {
$this->assertEquals('email-conn', $job->connection);
$this->assertEquals('notifications', $job->queue);
$this->assertStringContainsString('Email error', $job->exception);
}
}

protected function createSimpleDatabaseWithFailedJobTable()
{
$db = new DB;
Expand Down