GetCommandTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 5

Importance

Changes 0
Metric Value
wmc 4
lcom 2
cbo 5
dl 0
loc 40
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTestCommand() 0 4 1
A testConfigure() 0 5 1
A testExecute() 0 5 1
A testNonExistentValue() 0 5 1
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