These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | require_once codecept_data_dir() . 'TestedRoboFile.php'; |
||
3 | |||
4 | use Robo\Robo; |
||
5 | use Consolidation\AnnotatedCommand\Parser\CommandInfo; |
||
6 | use Robo\Collection\CollectionBuilder; |
||
7 | |||
8 | class ApplicationTest extends \Codeception\TestCase\Test |
||
9 | { |
||
10 | /** |
||
11 | * @var \Robo\Runner |
||
12 | */ |
||
13 | private $runner; |
||
14 | |||
15 | /** |
||
16 | * @var \Robo\Application |
||
17 | */ |
||
18 | private $app; |
||
19 | |||
20 | /** |
||
21 | * @var Consolidation\AnnotatedCommand\AnnotatedCommandFactory |
||
22 | */ |
||
23 | private $commandFactory; |
||
24 | |||
25 | /** |
||
26 | * @var TestRoboFile |
||
27 | */ |
||
28 | private $roboCommandFileInstance; |
||
29 | |||
30 | protected function _before() |
||
31 | { |
||
32 | $container = Robo::createDefaultContainer(); |
||
33 | |||
34 | $this->app = $container->get('application'); |
||
35 | $config = $container->get('config'); |
||
36 | $this->commandFactory = $container->get('commandFactory'); |
||
37 | $this->roboCommandFileInstance = new TestedRoboFile; |
||
0 ignored issues
–
show
|
|||
38 | $builder = CollectionBuilder::create($container, $this->roboCommandFileInstance); |
||
39 | $this->roboCommandFileInstance->setBuilder($builder); |
||
40 | $commandList = $this->commandFactory->createCommandsFromClass($this->roboCommandFileInstance); |
||
41 | foreach ($commandList as $command) { |
||
42 | $this->app->add($command); |
||
43 | } |
||
44 | } |
||
45 | |||
46 | public function testTaskAccessor() |
||
47 | { |
||
48 | // Get a reference to the protected 'task' method, as |
||
49 | // this is normally only callable by methods of the |
||
50 | // commandfile instance. |
||
51 | $method = new ReflectionMethod($this->roboCommandFileInstance, 'task'); |
||
52 | $method->setAccessible(true); |
||
53 | $collectionBuilder = $method->invoke($this->roboCommandFileInstance, 'Robo\Task\Base\Exec', 'ls'); |
||
54 | verify(get_class($collectionBuilder))->equals('Robo\Collection\CollectionBuilder'); |
||
55 | $task = $collectionBuilder->getCollectionBuilderCurrentTask(); |
||
56 | verify(get_class($task))->equals('Robo\Task\Base\Exec'); |
||
57 | verify(get_class($task))->equals('Robo\Task\Base\Exec'); |
||
58 | } |
||
59 | |||
60 | public function testAllowEmptyValuesAsDefaultsToOptionalOptions() |
||
61 | { |
||
62 | $command = $this->createCommand('hello'); |
||
63 | |||
64 | $yell = $command->getDefinition()->getOption('yell'); |
||
65 | |||
66 | verify($yell->isValueOptional()) |
||
67 | ->equals(false); |
||
68 | verify($yell->getDefault()) |
||
69 | ->equals(false); |
||
70 | |||
71 | $to = $command->getDefinition()->getOption('to'); |
||
72 | |||
73 | verify($to->isValueOptional()) |
||
74 | ->equals(true); |
||
75 | verify($to->getDefault()) |
||
76 | ->equals(null); |
||
77 | } |
||
78 | |||
79 | public function testCommandDocumentation() |
||
80 | { |
||
81 | $command = $this->createCommand('fibonacci'); |
||
82 | |||
83 | verify($command->getDescription()) |
||
84 | ->equals('Calculate the fibonacci sequence between two numbers.'); |
||
85 | } |
||
86 | |||
87 | public function testCommandCompactDocumentation() |
||
88 | { |
||
89 | $command = $this->createCommand('compact'); |
||
90 | |||
91 | verify($command->getDescription()) |
||
92 | ->equals('Compact doc comment'); |
||
93 | } |
||
94 | |||
95 | public function testCommandArgumentDocumentation() |
||
96 | { |
||
97 | $command = $this->createCommand('fibonacci'); |
||
98 | |||
99 | $start = $command->getDefinition()->getArgument('start'); |
||
100 | |||
101 | verify($start->getDescription()) |
||
102 | ->equals('Number to start from'); |
||
103 | |||
104 | $steps = $command->getDefinition()->getArgument('steps'); |
||
105 | |||
106 | verify($steps->getDescription()) |
||
107 | ->equals('Number of steps to perform'); |
||
108 | } |
||
109 | |||
110 | public function testCommandOptionDocumentation() |
||
111 | { |
||
112 | $command = $this->createCommand('fibonacci'); |
||
113 | |||
114 | $graphic = $command->getDefinition()->getOption('graphic'); |
||
115 | |||
116 | verify($graphic->getDescription()) |
||
117 | ->equals('Display the sequence graphically using cube representation'); |
||
118 | } |
||
119 | |||
120 | public function testCommandHelpDocumentation() |
||
121 | { |
||
122 | $command = $this->createCommand('fibonacci'); |
||
123 | |||
124 | verify($command->getHelp()) |
||
125 | ->contains('+----+---+'); |
||
126 | } |
||
127 | |||
128 | public function testCommandNaming() |
||
129 | { |
||
130 | $this->assertNotNull($this->app->find('generate:user-avatar')); |
||
131 | } |
||
132 | |||
133 | protected function createCommand($name) |
||
134 | { |
||
135 | $commandInfo = new CommandInfo($this->roboCommandFileInstance, $name); |
||
136 | return $this->commandFactory->createCommand($commandInfo, $this->roboCommandFileInstance); |
||
137 | } |
||
138 | } |
||
139 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..