Completed
Push — master ( 2dc9c5...1f3c35 )
by Robbie
9s
created

GetCommandTest::testNonExistentValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
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\Core\Config\Config;
7
8
/**
9
 * @coversDefaultClass \SilverLeague\Console\Command\Config\GetCommand
10
 * @package silverstripe-console
11
 * @author  Robbie Averill <[email protected]>
12
 */
13
class GetCommandTest extends AbstractCommandTest
14
{
15
    /**
16
     * {@inheritDoc}
17
     */
18
    protected function getTestCommand()
19
    {
20
        return 'config:get';
21
    }
22
23
    /**
24
     * Ensure that the class and property arguments are required
25
     *
26
     * @covers ::configure
27
     */
28
    public function testConfigure()
29
    {
30
        $this->assertTrue($this->command->getDefinition()->getArgument('class')->isRequired());
31
        $this->assertTrue($this->command->getDefinition()->getArgument('property')->isRequired());
32
    }
33
34
    /**
35
     * Ensure a successful execution returns the value of the config property
36
     *
37
     * @covers ::execute
38
     */
39
    public function testExecute()
40
    {
41
        Config::inst()->update('space', 'monkey_hater_machine', 'donkey');
42
        $result = $this->executeTest(['class' => 'space', 'property' => 'monkey_hater_machine'])->getDisplay();
43
        $this->assertContains('donkey', $result);
44
    }
45
46
    /**
47
     * Ensure that null is returned for a non-existent value
48
     *
49
     * @covers ::execute
50
     */
51
    public function testNonExistentValue()
52
    {
53
        $result = $this->executeTest(['class' => 'Moegli', 'property' => 'penny_farthing'])->getDisplay();
54
        $this->assertContains('NULL', $result);
55
    }
56
}
57