1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MyBuilder\Bundle\CronosBundle\Tests\Command; |
4
|
|
|
|
5
|
|
|
use MyBuilder\Bundle\CronosBundle\Command\DumpCommand; |
6
|
|
|
use MyBuilder\Bundle\CronosBundle\Command\ReplaceCommand; |
7
|
|
|
use MyBuilder\Bundle\CronosBundle\Tests\CronosTestCase; |
8
|
|
|
use MyBuilder\Bundle\CronosBundle\Tests\Fixtures\Command\TestCommand; |
9
|
|
|
use Symfony\Bundle\FrameworkBundle\Console\Application; |
10
|
|
|
use Symfony\Component\Console\Command\Command; |
11
|
|
|
use Symfony\Component\Console\Tester\CommandTester; |
12
|
|
|
|
13
|
|
|
class DumpCommandTest extends CronosTestCase |
14
|
|
|
{ |
15
|
|
|
/** @var Command */ |
16
|
|
|
private $command; |
17
|
|
|
|
18
|
|
|
protected function setUp(): void |
19
|
|
|
{ |
20
|
|
|
$kernel = self::createKernel(); |
21
|
|
|
$kernel->boot(); |
22
|
|
|
|
23
|
|
|
$application = new Application($kernel); |
24
|
|
|
|
25
|
|
|
$application->add(new DumpCommand()); |
26
|
|
|
$application->add(new ReplaceCommand()); |
27
|
|
|
$application->add(new TestCommand()); |
28
|
|
|
|
29
|
|
|
$this->command = $application->find('cronos:dump'); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
protected function tearDown(): void |
33
|
|
|
{ |
34
|
|
|
self::ensureKernelShutdown(); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @test |
39
|
|
|
* @dataProvider environmentDumps |
40
|
|
|
*/ |
41
|
|
|
public function test_dump_should_be_as_expected(string $expectedOutput, array $input): void |
42
|
|
|
{ |
43
|
|
|
$input = array_merge(['command' => $this->command->getName()], $input); |
44
|
|
|
|
45
|
|
|
$commandTester = new CommandTester($this->command); |
46
|
|
|
$commandTester->execute($input); |
47
|
|
|
|
48
|
|
|
static::assertEquals($expectedOutput, trim($commandTester->getDisplay())); |
|
|
|
|
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function environmentDumps(): array |
52
|
|
|
{ |
53
|
|
|
return [ |
54
|
|
|
[ |
55
|
|
|
'Server all |
56
|
|
|
Found 3 lines |
57
|
|
|
We would have put the following in cron |
58
|
|
|
PATH=/bin:~/bin |
59
|
|
|
[email protected] |
60
|
|
|
|
61
|
|
|
27 0 * * 6 php app/console cronos:test-command --env=test |
62
|
|
|
|
63
|
|
|
*/5 */3 * * * php app/console cronos:test-command --env=test |
64
|
|
|
|
65
|
|
|
41 10 1 * * php -d mbstring.func_overload=0 app/console cronos:test-command --env=test', |
66
|
|
|
[ |
67
|
|
|
'--env' => 'test', |
68
|
|
|
], |
69
|
|
|
], |
70
|
|
|
[ |
71
|
|
|
'Server web |
72
|
|
|
Found 1 lines |
73
|
|
|
We would have put the following in cron |
74
|
|
|
PATH=/bin:~/bin |
75
|
|
|
[email protected] |
76
|
|
|
|
77
|
|
|
27 0 * * 6 php app/console cronos:test-command --env=prod', |
78
|
|
|
[ |
79
|
|
|
'--env' => 'prod', |
80
|
|
|
'--server' => 'web', |
81
|
|
|
], |
82
|
|
|
], |
83
|
|
|
]; |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.