|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SilverLeague\Console\Tests\Command\Config; |
|
4
|
|
|
|
|
5
|
|
|
use SilverLeague\Console\Tests\Command\AbstractCommandTest; |
|
6
|
|
|
use SilverStripe\Config\Collections\ConfigCollectionInterface; |
|
7
|
|
|
use SilverStripe\Control\RequestHandler; |
|
8
|
|
|
use SilverStripe\Core\Config\Config; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* @coversDefaultClass \SilverLeague\Console\Command\Config\DumpCommand |
|
12
|
|
|
* @package silverstripe-console |
|
13
|
|
|
* @author Robbie Averill <[email protected]> |
|
14
|
|
|
*/ |
|
15
|
|
|
class DumpCommandTest extends AbstractCommandTest |
|
16
|
|
|
{ |
|
17
|
|
|
protected function getTestCommand() |
|
18
|
|
|
{ |
|
19
|
|
|
return 'config:dump'; |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Ensure that the InputOptions exist |
|
24
|
|
|
* |
|
25
|
|
|
* @covers ::configure |
|
26
|
|
|
*/ |
|
27
|
|
|
public function testConfigure() |
|
28
|
|
|
{ |
|
29
|
|
|
$this->assertTrue($this->command->getDefinition()->hasOption('filter')); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Test that the command can successfully be executed |
|
34
|
|
|
* |
|
35
|
|
|
* @covers ::execute |
|
36
|
|
|
*/ |
|
37
|
|
|
public function testExecute() |
|
38
|
|
|
{ |
|
39
|
|
|
$result = $this->executeTest()->getDisplay(); |
|
40
|
|
|
$this->assertContains('silverstripe\\control\\director', $result); |
|
41
|
|
|
$this->assertContains('silverstripe\\core\\injector\\injector', $result); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Test that the results can be filtered |
|
46
|
|
|
* |
|
47
|
|
|
* @covers ::execute |
|
48
|
|
|
* @covers ::filterOutput |
|
49
|
|
|
*/ |
|
50
|
|
|
public function testExecuteWithFilteredResults() |
|
51
|
|
|
{ |
|
52
|
|
|
$result = $this->executeTest(['--filter' => 'ViewableData'])->getDisplay(); |
|
53
|
|
|
$this->assertContains( RequestHandler::class, $result); |
|
54
|
|
|
$this->assertNotContains('silverstripe\\core\\injector\\injector', $result); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Ensure that the filter is applied to any column of the data |
|
59
|
|
|
* |
|
60
|
|
|
* @covers ::filterOutput |
|
61
|
|
|
*/ |
|
62
|
|
|
public function testFilterOnAnyColumn() |
|
63
|
|
|
{ |
|
64
|
|
|
$result = $this->executeTest(['--filter' => 'pushDisplayErrorHandler'])->getDisplay(); |
|
65
|
|
|
$this->assertContains('pushHandler', $result); |
|
66
|
|
|
|
|
67
|
|
|
$result = $this->executeTest(['--filter' => 'pushHandler'])->getDisplay(); |
|
68
|
|
|
$this->assertContains('%$Monolog\\\\Handler\\\\HandlerInterface', $result); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Ensure that numeric property keys are replaced with nada |
|
73
|
|
|
* |
|
74
|
|
|
* @covers ::getParsedOutput |
|
75
|
|
|
*/ |
|
76
|
|
|
public function testNumericKeysAreNotShown() |
|
77
|
|
|
{ |
|
78
|
|
|
Config::modify()->set('FooBar', 'my_property', [1 => 'baz', 'bar' => 'banter']); |
|
79
|
|
|
$result = $this->executeTest(['--filter' => 'FooBar'])->getDisplay(); |
|
80
|
|
|
$this->assertNotContains('1', $result); |
|
81
|
|
|
$this->assertContains('bar', $result); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Ensure that a ConfigCollectionInterface is returned |
|
86
|
|
|
* |
|
87
|
|
|
* @covers \SilverLeague\Console\Command\Config\AbstractConfigCommand::getConfig |
|
88
|
|
|
*/ |
|
89
|
|
|
public function testGetConfigCollectionInterface() |
|
90
|
|
|
{ |
|
91
|
|
|
$result = $this->command->getConfig(); |
|
92
|
|
|
$this->assertInstanceOf(ConfigCollectionInterface::class, $result); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|