DumpCommandTest::getTestCommand()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\Core\Config\Config;
8
9
/**
10
 * @coversDefaultClass \SilverLeague\Console\Command\Config\DumpCommand
11
 * @package silverstripe-console
12
 * @author  Robbie Averill <[email protected]>
13
 */
14
class DumpCommandTest extends AbstractCommandTest
15
{
16
    protected function getTestCommand()
17
    {
18
        return 'config:dump';
19
    }
20
21
    /**
22
     * Ensure that the InputOptions exist
23
     *
24
     * @covers ::configure
25
     */
26
    public function testConfigure()
27
    {
28
        $this->assertTrue($this->command->getDefinition()->hasOption('filter'));
29
    }
30
31
    /**
32
     * Test that the command can successfully be executed
33
     *
34
     * @covers ::execute
35
     */
36
    public function testExecute()
37
    {
38
        $result = $this->executeTest()->getDisplay();
39
        $this->assertContains('silverstripe\\control\\director', $result);
40
        $this->assertContains('silverstripe\\core\\injector\\injector', $result);
41
    }
42
43
    /**
44
     * Test that the results can be filtered
45
     *
46
     * @covers ::execute
47
     * @covers ::filterOutput
48
     */
49
    public function testExecuteWithFilteredResults()
50
    {
51
        $result = $this->executeTest(['--filter' => 'ViewableData'])->getDisplay();
52
        $this->assertContains('silverstripe\\dev\\buildtask', $result);
53
        $this->assertNotContains('silverstripe\\core\\injector\\injector', $result);
54
    }
55
56
    /**
57
     * Ensure that the filter is applied to any column of the data
58
     *
59
     * @covers ::filterOutput
60
     */
61
    public function testFilterOnAnyColumn()
62
    {
63
        $result = $this->executeTest(['--filter' => 'pushDisplayErrorHandler'])->getDisplay();
64
        $this->assertContains('pushHandler', $result);
65
66
        $result = $this->executeTest(['--filter' => 'pushHandler'])->getDisplay();
67
        $this->assertContains('%$Monolog\\\\Handler\\\\HandlerInterface', $result);
68
    }
69
70
    /**
71
     * Ensure that a ConfigCollectionInterface is returned
72
     *
73
     * @covers \SilverLeague\Console\Command\Config\AbstractConfigCommand::getConfig
74
     */
75
    public function testGetConfigCollectionInterface()
76
    {
77
        $result = $this->command->getConfig();
78
        $this->assertInstanceOf(ConfigCollectionInterface::class, $result);
79
    }
80
}
81