GetCommandTest::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\ORM\DataObject;
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
    protected function getTestCommand()
16
    {
17
        return 'config:get';
18
    }
19
20
    /**
21
     * Ensure that the class and property arguments are required
22
     *
23
     * @covers ::configure
24
     */
25
    public function testConfigure()
26
    {
27
        $this->assertTrue($this->command->getDefinition()->getArgument('class')->isRequired());
28
        $this->assertTrue($this->command->getDefinition()->getArgument('property')->isRequired());
29
    }
30
31
    /**
32
     * Ensure a successful execution returns the value of the config property
33
     *
34
     * @covers ::execute
35
     */
36
    public function testExecute()
37
    {
38
        $result = $this->executeTest(['class' => DataObject::class, 'property' => 'fixed_fields'])->getDisplay();
39
        $this->assertContains('ClassName', $result);
40
    }
41
42
    /**
43
     * Ensure that null is returned for a non-existent value
44
     *
45
     * @covers ::execute
46
     */
47
    public function testNonExistentValue()
48
    {
49
        $result = $this->executeTest(['class' => 'Moegli', 'property' => 'penny_farthing'])->getDisplay();
50
        $this->assertContains('NULL', $result);
51
    }
52
}
53