|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the GitElephant package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Matteo Giachino <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
* |
|
11
|
|
|
* Just for fun... |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace GitElephant\Command; |
|
15
|
|
|
|
|
16
|
|
|
use GitElephant\TestCase; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Class RemoteCommandTest |
|
20
|
|
|
* |
|
21
|
|
|
* @package GitElephant\Command |
|
22
|
|
|
* @author David Neimeyer <[email protected]> |
|
23
|
|
|
*/ |
|
24
|
|
|
class SubCommandCommandTest extends TestCase |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* verify SubCommandCommands behavior, which is slightly |
|
28
|
|
|
* different that BaseCommand, for more sophisticated needs |
|
29
|
|
|
*/ |
|
30
|
|
|
public function testGetCommand(): void |
|
31
|
|
|
{ |
|
32
|
|
|
$cmdName = 'foo'; |
|
33
|
|
|
$subOne = 'bar'; |
|
34
|
|
|
$subTwo = 'baz'; |
|
35
|
|
|
$subThree = 'blurg'; |
|
36
|
|
|
$argOne = '--opt1'; |
|
37
|
|
|
$argTwo = '--opt2'; |
|
38
|
|
|
$argTwoValue = 'val2'; |
|
39
|
|
|
$expected = "foo '$argOne' '$argTwo' '$argTwoValue' '$subOne' '$subTwo' '$subThree'"; |
|
40
|
|
|
|
|
41
|
|
|
$subcmd = new SubCommandCommand(); |
|
42
|
|
|
|
|
43
|
|
|
$rmeth = new \ReflectionMethod($subcmd, 'addCommandName'); |
|
44
|
|
|
$rmeth->setAccessible(true); |
|
45
|
|
|
$rmeth->invoke($subcmd, $cmdName); |
|
46
|
|
|
|
|
47
|
|
|
$rmeth = new \ReflectionMethod($subcmd, 'addCommandSubject'); |
|
48
|
|
|
$rmeth->setAccessible(true); |
|
49
|
|
|
$rmeth->invoke($subcmd, $subOne); |
|
50
|
|
|
|
|
51
|
|
|
$rmeth = new \ReflectionMethod($subcmd, 'addCommandSubject'); |
|
52
|
|
|
$rmeth->setAccessible(true); |
|
53
|
|
|
$rmeth->invoke($subcmd, $subTwo); |
|
54
|
|
|
|
|
55
|
|
|
$rmeth = new \ReflectionMethod($subcmd, 'addCommandSubject'); |
|
56
|
|
|
$rmeth->setAccessible(true); |
|
57
|
|
|
$rmeth->invoke($subcmd, $subThree); |
|
58
|
|
|
|
|
59
|
|
|
$rmeth = new \ReflectionMethod($subcmd, 'addCommandArgument'); |
|
60
|
|
|
$rmeth->setAccessible(true); |
|
61
|
|
|
$rmeth->invoke($subcmd, $argOne); |
|
62
|
|
|
|
|
63
|
|
|
$rmeth = new \ReflectionMethod($subcmd, 'addCommandArgument'); |
|
64
|
|
|
$rmeth->setAccessible(true); |
|
65
|
|
|
$rmeth->invoke($subcmd, [$argTwo, $argTwoValue]); |
|
66
|
|
|
|
|
67
|
|
|
$actual = $subcmd->getCommand(); |
|
68
|
|
|
$this->assertEquals( |
|
69
|
|
|
$expected, |
|
70
|
|
|
$actual, |
|
71
|
|
|
'getCommand() produces string made from subject stact and extracted args' |
|
72
|
|
|
); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|