-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathQueueRetryTest.php
More file actions
71 lines (54 loc) · 2 KB
/
Copy pathQueueRetryTest.php
File metadata and controls
71 lines (54 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
declare(strict_types=1);
/**
* This file is part of CodeIgniter Queue.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Tests\Commands;
use CodeIgniter\Queue\Models\QueueJobFailedModel;
use CodeIgniter\Test\Filters\CITestStreamFilter;
use Tests\Support\CLITestCase;
/**
* @internal
*/
final class QueueRetryTest extends CLITestCase
{
public function testRunWithNoQueueName(): void
{
CITestStreamFilter::registration();
CITestStreamFilter::addErrorFilter();
$this->assertNotFalse(command('queue:retry'));
$output = $this->parseOutput(CITestStreamFilter::$buffer);
CITestStreamFilter::removeErrorFilter();
$this->assertSame('The ID of the failed job is not specified.', $output);
}
public function testRunFailed(): void
{
CITestStreamFilter::registration();
CITestStreamFilter::addOutputFilter();
$this->assertNotFalse(command('queue:retry all -queue test'));
$output = $this->parseOutput(CITestStreamFilter::$buffer);
CITestStreamFilter::removeOutputFilter();
$this->assertSame('No failed jobs has been restored to the queue test', $output);
}
public function testRun(): void
{
fake(QueueJobFailedModel::class, [
'connection' => 'database',
'queue' => 'test',
'payload' => ['job' => 'failure', 'data' => ['key' => 'value']],
'priority' => 'default',
'exception' => 'Exception: Test error',
]);
CITestStreamFilter::registration();
CITestStreamFilter::addOutputFilter();
$this->assertNotFalse(command('queue:retry 1'));
$output = $this->parseOutput(CITestStreamFilter::$buffer);
CITestStreamFilter::removeOutputFilter();
$this->assertSame('1 failed job(s) has been restored to the queue ', $output);
}
}