1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Deployer\Ssh; |
4
|
|
|
|
5
|
|
|
use PHPUnit\Framework\TestCase; |
6
|
|
|
use Symfony\Component\Console\Input\ArgvInput; |
7
|
|
|
use Symfony\Component\Console\Input\InputDefinition; |
8
|
|
|
use Symfony\Component\Console\Input\InputOption; |
9
|
|
|
use Symfony\Component\Console\Output\ConsoleOutput; |
10
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
11
|
|
|
|
12
|
|
|
class IOArgumentsTest extends TestCase |
13
|
|
|
{ |
14
|
|
|
public function testCollect() |
15
|
|
|
{ |
16
|
|
|
$definition = new InputDefinition([ |
17
|
|
|
new InputOption('option', 'o', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Set configuration option'), |
18
|
|
|
new InputOption('limit', 'l', InputOption::VALUE_REQUIRED, 'How many tasks to run in parallel?'), |
19
|
|
|
new InputOption('no-hooks', null, InputOption::VALUE_NONE, 'Run tasks without after/before hooks'), |
20
|
|
|
new InputOption('plan', null, InputOption::VALUE_NONE, 'Show execution plan'), |
21
|
|
|
new InputOption('start-from', null, InputOption::VALUE_REQUIRED, 'Start execution from this task'), |
22
|
|
|
new InputOption('log', null, InputOption::VALUE_REQUIRED, 'Write log to a file'), |
23
|
|
|
new InputOption('profile', null, InputOption::VALUE_REQUIRED, 'Write profile to a file', ), |
24
|
|
|
new InputOption('ansi', null, InputOption::VALUE_OPTIONAL, 'Force ANSI output', ), |
25
|
|
|
]); |
26
|
|
|
|
27
|
|
|
$args = IOArguments::collect( |
28
|
|
|
new ArgvInput(['deploy', '-o', 'env=prod', '--ansi', '-l1'], $definition), |
29
|
|
|
new ConsoleOutput(OutputInterface::VERBOSITY_DEBUG, false), |
30
|
|
|
); |
31
|
|
|
|
32
|
|
|
self::assertEquals(['--option','env=prod', '--limit', '1', '-vvv'], $args); |
33
|
|
|
} |
34
|
|
|
} |
35
|
|
|
|