Passed
Push — master ( 52a038...0b42aa )
by Robbie
02:27
created

DumpCommandTest::testNumericKeysAreNotShown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 5
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\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 a ConfigCollectionInterface is returned
73
     *
74
     * @covers \SilverLeague\Console\Command\Config\AbstractConfigCommand::getConfig
75
     */
76
    public function testGetConfigCollectionInterface()
77
    {
78
        $result = $this->command->getConfig();
79
        $this->assertInstanceOf(ConfigCollectionInterface::class, $result);
80
    }
81
}
82