Passed
Push — master ( 8bad73...c5d158 )
by David
57s queued 11s
created

AddAssetCommandTest::testCallWithBadPriority()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace TheCodingMachine\Discovery\Tests\Commands;
5
6
7
use Symfony\Component\Console\Input\ArrayInput;
8
use Symfony\Component\Console\Input\InputArgument;
9
use Symfony\Component\Console\Input\InputDefinition;
10
use Symfony\Component\Console\Input\InputOption;
11
use TheCodingMachine\Discovery\Commands\AddAssetCommand;
12
use TheCodingMachine\Discovery\Tests\AbstractDiscoveryTest;
13
14
class AddAssetCommandTest extends AbstractDiscoveryTest
15
{
16
    public static function getInputDefinition()
17
    {
18
        return new InputDefinition([
19
            new InputArgument('asset-type', InputArgument::REQUIRED),
20
            new InputArgument('value', InputArgument::REQUIRED),
21
            new InputOption('priority', 'p', InputOption::VALUE_REQUIRED, '', 0.0)
22
        ]);
23
    }
24
25
    public function testCall()
26
    {
27
        if (file_exists('discovery.json')) {
28
            unlink('discovery.json');
29
        }
30
31
        $input = new ArrayInput([
32
            'asset-type' => 'foo',
33
            'value' => 'bar'
34
        ], self::getInputDefinition());
35
36
        $result = $this->callCommand(new AddAssetCommand(), $input);
0 ignored issues
show
Unused Code introduced by
The assignment to $result is dead and can be removed.
Loading history...
37
38
        $this->assertFileExists('discovery.json');
39
40
        $result = $this->callCommand(new AddAssetCommand(), $input);
41
42
        $this->assertFileExists('discovery.json');
43
44
45
        unlink('discovery.json');
46
    }
47
48
    public function testCallWithBadPriority()
49
    {
50
        $input = new ArrayInput([
51
            'asset-type' => 'foo',
52
            'value' => 'bar',
53
            '--priority' => 'a'
54
        ], self::getInputDefinition());
55
56
        $result = $this->callCommand(new AddAssetCommand(), $input);
57
58
        $this->assertStringContainsString('The priority must be a numeric value.', $result);
59
60
    }
61
62
}
63