forked from dereuromark/cakephp-queue
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInfoCommandTest.php
More file actions
75 lines (59 loc) · 1.9 KB
/
InfoCommandTest.php
File metadata and controls
75 lines (59 loc) · 1.9 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
72
73
74
75
<?php
declare(strict_types=1);
namespace Queue\Test\TestCase\Command;
use Cake\Console\TestSuite\ConsoleIntegrationTestTrait;
use Cake\Core\Configure;
use Cake\TestSuite\TestCase;
/**
* @uses \Queue\Command\InfoCommand
*/
class InfoCommandTest extends TestCase {
use ConsoleIntegrationTestTrait;
/**
* @var array<string>
*/
protected array $fixtures = [
'plugin.Queue.QueueProcesses',
'plugin.Queue.QueuedJobs',
];
/**
* @return void
*/
public function setUp(): void {
parent::setUp();
$this->loadPlugins(['Queue']);
}
/**
* @return void
*/
public function testExecute(): void {
$this->exec('queue info');
$output = $this->_out->output();
$this->assertStringContainsString('16 tasks available:', $output);
$this->assertExitCode(0);
}
/**
* Test that new config names are displayed in the info command.
*
* @return void
*/
public function testExecuteWithNewConfigNames(): void {
// Set up some config values using old names
Configure::write('Queue.defaultworkertimeout', 300);
Configure::write('Queue.workermaxruntime', 60);
Configure::write('Queue.defaultworkerretries', 2);
Configure::write('Queue.workertimeout', 120);
// Suppress deprecation warnings triggered by Config methods reading old keys
$errorLevel = error_reporting();
error_reporting($errorLevel & ~E_USER_DEPRECATED);
$this->exec('queue info');
error_reporting($errorLevel);
$output = $this->_out->output();
// Check that new config names are displayed with old names noted
$this->assertStringContainsString('defaultRequeueTimeout (was: defaultworkertimeout): 300', $output);
$this->assertStringContainsString('workerLifetime (was: workermaxruntime): 60', $output);
$this->assertStringContainsString('defaultJobRetries (was: defaultworkerretries): 2', $output);
$this->assertStringContainsString('workerPhpTimeout (was: workertimeout): 120', $output);
$this->assertExitCode(0);
}
}