|
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); |
|
|
|
|
|
|
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
|
|
|
|