This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | use AspectMock\Test as test; |
||
0 ignored issues
–
show
|
|||
3 | |||
4 | use Robo\Traits\Common\AdjustQuotes; |
||
5 | |||
6 | class ComposerTest extends \Codeception\TestCase\Test |
||
7 | { |
||
8 | use AdjustQuotes; |
||
9 | |||
10 | protected $container; |
||
11 | |||
12 | /** |
||
13 | * @var \AspectMock\Proxy\ClassProxy |
||
14 | */ |
||
15 | protected $baseComposer; |
||
16 | |||
17 | protected function _before() |
||
18 | { |
||
19 | $this->baseComposer = test::double('Robo\Task\Composer\Base', [ |
||
20 | 'output' => new \Symfony\Component\Console\Output\NullOutput(), |
||
21 | 'logger' => new \Psr\Log\NullLogger(), |
||
22 | ]); |
||
23 | } |
||
24 | // tests |
||
25 | View Code Duplication | public function testComposerInstall() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
26 | { |
||
27 | $composer = test::double('Robo\Task\Composer\Install', ['executeCommand' => null, 'getConfig' => new \Robo\Config(), 'logger' => new \Psr\Log\NullLogger()]); |
||
28 | |||
29 | (new \Robo\Task\Composer\Install('composer'))->run(); |
||
30 | $composer->verifyInvoked('executeCommand', ['composer install --no-interaction']); |
||
31 | |||
32 | (new \Robo\Task\Composer\Install('composer')) |
||
33 | ->preferSource() |
||
34 | ->run(); |
||
35 | $composer->verifyInvoked('executeCommand', ['composer install --prefer-source --no-interaction']); |
||
36 | |||
37 | (new \Robo\Task\Composer\Install('composer')) |
||
38 | ->optimizeAutoloader() |
||
39 | ->run(); |
||
40 | $composer->verifyInvoked('executeCommand', ['composer install --optimize-autoloader --no-interaction']); |
||
41 | } |
||
42 | |||
43 | public function testComposerInstallAnsi() |
||
44 | { |
||
45 | $config = new \Robo\Config(); |
||
46 | $config->setDecorated(true); |
||
47 | $config->setInteractive(true); |
||
48 | $composer = test::double('Robo\Task\Composer\Install', ['executeCommand' => null, 'getConfig' => $config, 'logger' => new \Psr\Log\NullLogger()]); |
||
49 | |||
50 | (new \Robo\Task\Composer\Install('composer'))->run(); |
||
51 | $composer->verifyInvoked('executeCommand', ['composer install --ansi']); |
||
52 | |||
53 | (new \Robo\Task\Composer\Install('composer')) |
||
54 | ->preferSource() |
||
55 | ->run(); |
||
56 | $composer->verifyInvoked('executeCommand', ['composer install --prefer-source --ansi']); |
||
57 | |||
58 | (new \Robo\Task\Composer\Install('composer')) |
||
59 | ->optimizeAutoloader() |
||
60 | ->run(); |
||
61 | $composer->verifyInvoked('executeCommand', ['composer install --optimize-autoloader --ansi']); |
||
62 | } |
||
63 | |||
64 | View Code Duplication | public function testComposerUpdate() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
65 | { |
||
66 | $composer = test::double('Robo\Task\Composer\Update', ['executeCommand' => null, 'getConfig' => new \Robo\Config(), 'logger' => new \Psr\Log\NullLogger()]); |
||
67 | |||
68 | (new \Robo\Task\Composer\Update('composer'))->run(); |
||
69 | $composer->verifyInvoked('executeCommand', ['composer update --no-interaction']); |
||
70 | |||
71 | (new \Robo\Task\Composer\Update('composer')) |
||
72 | ->optimizeAutoloader() |
||
73 | ->run(); |
||
74 | $composer->verifyInvoked('executeCommand', ['composer update --optimize-autoloader --no-interaction']); |
||
75 | } |
||
76 | |||
77 | public function testComposerDumpAutoload() |
||
78 | { |
||
79 | $composer = test::double('Robo\Task\Composer\DumpAutoload', ['executeCommand' => null, 'getConfig' => new \Robo\Config(), 'logger' => new \Psr\Log\NullLogger()]); |
||
80 | |||
81 | (new \Robo\Task\Composer\DumpAutoload('composer'))->run(); |
||
82 | $composer->verifyInvoked('executeCommand', ['composer dump-autoload --no-interaction']); |
||
83 | |||
84 | (new \Robo\Task\Composer\DumpAutoload('composer')) |
||
85 | ->noDev() |
||
86 | ->run(); |
||
87 | $composer->verifyInvoked('executeCommand', ['composer dump-autoload --no-dev --no-interaction']); |
||
88 | |||
89 | (new \Robo\Task\Composer\DumpAutoload('composer')) |
||
90 | ->optimize() |
||
91 | ->run(); |
||
92 | $composer->verifyInvoked('executeCommand', ['composer dump-autoload --optimize --no-interaction']); |
||
93 | |||
94 | (new \Robo\Task\Composer\DumpAutoload('composer')) |
||
95 | ->optimize() |
||
96 | ->noDev() |
||
97 | ->run(); |
||
98 | $composer->verifyInvoked('executeCommand', ['composer dump-autoload --optimize --no-dev --no-interaction']); |
||
99 | } |
||
100 | |||
101 | public function testComposerValidate() |
||
102 | { |
||
103 | $composer = test::double('Robo\Task\Composer\Validate', ['executeCommand' => null, 'getConfig' => new \Robo\Config(), 'logger' => new \Psr\Log\NullLogger()]); |
||
104 | |||
105 | (new \Robo\Task\Composer\Validate('composer'))->run(); |
||
106 | $composer->verifyInvoked('executeCommand', ['composer validate --no-interaction']); |
||
107 | |||
108 | (new \Robo\Task\Composer\Validate('composer')) |
||
109 | ->noCheckAll() |
||
110 | ->run(); |
||
111 | $composer->verifyInvoked('executeCommand', ['composer validate --no-check-all --no-interaction']); |
||
112 | |||
113 | (new \Robo\Task\Composer\Validate('composer')) |
||
114 | ->noCheckLock() |
||
115 | ->run(); |
||
116 | $composer->verifyInvoked('executeCommand', ['composer validate --no-check-lock --no-interaction']); |
||
117 | |||
118 | (new \Robo\Task\Composer\Validate('composer')) |
||
119 | ->noCheckPublish() |
||
120 | ->run(); |
||
121 | $composer->verifyInvoked('executeCommand', ['composer validate --no-check-publish --no-interaction']); |
||
122 | |||
123 | (new \Robo\Task\Composer\Validate('composer')) |
||
124 | ->withDependencies() |
||
125 | ->run(); |
||
126 | $composer->verifyInvoked('executeCommand', ['composer validate --with-dependencies --no-interaction']); |
||
127 | |||
128 | (new \Robo\Task\Composer\Validate('composer')) |
||
129 | ->strict() |
||
130 | ->run(); |
||
131 | $composer->verifyInvoked('executeCommand', ['composer validate --strict --no-interaction']); |
||
132 | } |
||
133 | |||
134 | public function testComposerInstallCommand() |
||
135 | { |
||
136 | $this->assertEquals( |
||
137 | 'composer install --no-interaction', |
||
138 | (new \Robo\Task\Composer\Install('composer'))->setConfig(new \Robo\Config())->getCommand() |
||
139 | ); |
||
140 | |||
141 | $this->assertEquals( |
||
142 | 'composer install --optimize-autoloader --prefer-dist --no-dev --no-interaction', |
||
143 | (new \Robo\Task\Composer\Install('composer')) |
||
144 | ->setConfig(new \Robo\Config()) |
||
145 | ->noDev() |
||
146 | ->preferDist() |
||
147 | ->optimizeAutoloader() |
||
148 | ->getCommand() |
||
149 | ); |
||
150 | } |
||
151 | |||
152 | public function testComposerUpdateCommand() |
||
153 | { |
||
154 | $this->assertEquals( |
||
155 | 'composer update --no-interaction', |
||
156 | (new \Robo\Task\Composer\Update('composer'))->setConfig(new \Robo\Config())->getCommand() |
||
157 | ); |
||
158 | |||
159 | $this->assertEquals( |
||
160 | 'composer update --prefer-dist --no-dev --no-interaction', |
||
161 | (new \Robo\Task\Composer\Update('composer')) |
||
162 | ->setConfig(new \Robo\Config()) |
||
163 | ->noDev() |
||
164 | ->preferDist() |
||
165 | ->getCommand() |
||
166 | ); |
||
167 | |||
168 | $this->assertEquals( |
||
169 | 'composer update --optimize-autoloader --prefer-dist --no-dev --no-interaction', |
||
170 | (new \Robo\Task\Composer\Update('composer')) |
||
171 | ->setConfig(new \Robo\Config()) |
||
172 | ->noDev() |
||
173 | ->preferDist() |
||
174 | ->optimizeAutoloader() |
||
175 | ->getCommand() |
||
176 | ); |
||
177 | } |
||
178 | |||
179 | public function testComposerDumpAutoloadCommand() |
||
180 | { |
||
181 | $this->assertEquals( |
||
182 | 'composer dump-autoload --no-interaction', |
||
183 | (new \Robo\Task\Composer\DumpAutoload('composer'))->setConfig(new \Robo\Config())->getCommand() |
||
184 | ); |
||
185 | |||
186 | $this->assertEquals( |
||
187 | 'composer dump-autoload --no-dev --no-interaction', |
||
188 | (new \Robo\Task\Composer\DumpAutoload('composer')) |
||
189 | ->setConfig(new \Robo\Config()) |
||
190 | ->noDev() |
||
191 | ->getCommand() |
||
192 | ); |
||
193 | |||
194 | $this->assertEquals( |
||
195 | 'composer dump-autoload --optimize --no-interaction', |
||
196 | (new \Robo\Task\Composer\DumpAutoload('composer')) |
||
197 | ->setConfig(new \Robo\Config()) |
||
198 | ->optimize() |
||
199 | ->getCommand() |
||
200 | ); |
||
201 | |||
202 | $this->assertEquals( |
||
203 | 'composer dump-autoload --optimize --no-dev --no-interaction', |
||
204 | (new \Robo\Task\Composer\DumpAutoload('composer')) |
||
205 | ->setConfig(new \Robo\Config()) |
||
206 | ->optimize() |
||
207 | ->noDev() |
||
208 | ->getCommand() |
||
209 | ); |
||
210 | } |
||
211 | |||
212 | public function testComposerRemove() |
||
213 | { |
||
214 | $this->assertEquals( |
||
215 | 'composer remove --no-interaction', |
||
216 | (new \Robo\Task\Composer\Remove('composer'))->setConfig(new \Robo\Config())->getCommand() |
||
217 | ); |
||
218 | $this->assertEquals( |
||
219 | 'composer remove --dev --no-progress --no-update --no-interaction', |
||
220 | (new \Robo\Task\Composer\Remove('composer')) |
||
221 | ->setConfig(new \Robo\Config()) |
||
222 | ->dev() |
||
223 | ->noProgress() |
||
224 | ->noUpdate() |
||
225 | ->getCommand() |
||
226 | ); |
||
227 | } |
||
228 | |||
229 | public function testComposerValidateCommand() |
||
230 | { |
||
231 | $this->assertEquals( |
||
232 | 'composer validate --no-interaction', |
||
233 | (new \Robo\Task\Composer\Validate('composer'))->setConfig(new \Robo\Config())->getCommand() |
||
234 | ); |
||
235 | |||
236 | $this->assertEquals( |
||
237 | 'composer validate --no-check-all --no-interaction', |
||
238 | (new \Robo\Task\Composer\Validate('composer')) |
||
239 | ->setConfig(new \Robo\Config()) |
||
240 | ->noCheckAll() |
||
241 | ->getCommand() |
||
242 | ); |
||
243 | |||
244 | $this->assertEquals( |
||
245 | 'composer validate --no-check-lock --no-interaction', |
||
246 | (new \Robo\Task\Composer\Validate('composer')) |
||
247 | ->setConfig(new \Robo\Config()) |
||
248 | ->noCheckLock() |
||
249 | ->getCommand() |
||
250 | ); |
||
251 | |||
252 | $this->assertEquals( |
||
253 | 'composer validate --no-check-publish --no-interaction', |
||
254 | (new \Robo\Task\Composer\Validate('composer')) |
||
255 | ->setConfig(new \Robo\Config()) |
||
256 | ->noCheckPublish() |
||
257 | ->getCommand() |
||
258 | ); |
||
259 | |||
260 | $this->assertEquals( |
||
261 | 'composer validate --with-dependencies --no-interaction', |
||
262 | (new \Robo\Task\Composer\Validate('composer')) |
||
263 | ->setConfig(new \Robo\Config()) |
||
264 | ->withDependencies() |
||
265 | ->getCommand() |
||
266 | ); |
||
267 | |||
268 | $this->assertEquals( |
||
269 | 'composer validate --strict --no-interaction', |
||
270 | (new \Robo\Task\Composer\Validate('composer')) |
||
271 | ->setConfig(new \Robo\Config()) |
||
272 | ->strict() |
||
273 | ->getCommand() |
||
274 | ); |
||
275 | |||
276 | $this->assertEquals( |
||
277 | 'composer validate --no-check-all --no-check-lock --no-check-publish --with-dependencies --strict --no-interaction', |
||
278 | (new \Robo\Task\Composer\Validate('composer')) |
||
279 | ->setConfig(new \Robo\Config()) |
||
280 | ->noCheckAll() |
||
281 | ->noCheckLock() |
||
282 | ->noCheckPublish() |
||
283 | ->withDependencies() |
||
284 | ->strict() |
||
285 | ->getCommand() |
||
286 | ); |
||
287 | } |
||
288 | |||
289 | public function testComposerInitCommand() |
||
290 | { |
||
291 | $this->assertEquals( |
||
292 | 'composer init --no-interaction', |
||
293 | (new \Robo\Task\Composer\Init('composer'))->setConfig(new \Robo\Config())->getCommand() |
||
294 | ); |
||
295 | |||
296 | $this->assertEquals( |
||
297 | $this->adjustQuotes("composer init --name foo/bar --description 'A test project' --require 'baz/boz:^2.4.8' --type project --homepage 'https://foo.bar.com' --stability beta --license MIT --repository 'https://packages.drupal.org/8' --no-interaction"), |
||
298 | (new \Robo\Task\Composer\Init('composer')) |
||
299 | ->setConfig(new \Robo\Config()) |
||
300 | ->projectName('foo/bar') |
||
301 | ->description('A test project') |
||
302 | ->dependency('baz/boz', '^2.4.8') |
||
303 | ->projectType('project') |
||
304 | ->homepage('https://foo.bar.com') |
||
305 | ->stability('beta') |
||
306 | ->license('MIT') |
||
307 | ->repository('https://packages.drupal.org/8') |
||
308 | ->getCommand() |
||
309 | ); |
||
310 | |||
311 | } |
||
312 | |||
313 | public function testComposerConfigCommand() |
||
314 | { |
||
315 | $this->assertEquals( |
||
316 | "composer config bin-dir bin/ --no-interaction", |
||
317 | (new \Robo\Task\Composer\Config('composer')) |
||
318 | ->setConfig(new \Robo\Config()) |
||
319 | ->set('bin-dir', 'bin/') |
||
320 | ->getCommand() |
||
321 | ); |
||
322 | |||
323 | $this->assertEquals( |
||
324 | "composer config --global bin-dir bin/ --no-interaction", |
||
325 | (new \Robo\Task\Composer\Config('composer')) |
||
326 | ->setConfig(new \Robo\Config()) |
||
327 | ->useGlobal() |
||
328 | ->set('bin-dir', 'bin/') |
||
329 | ->getCommand() |
||
330 | ); |
||
331 | |||
332 | $this->assertEquals( |
||
333 | $this->adjustQuotes("composer config repositories.drupalorg composer 'https://packages.drupal.org/8' --no-interaction"), |
||
334 | (new \Robo\Task\Composer\Config('composer')) |
||
335 | ->setConfig(new \Robo\Config()) |
||
336 | ->repository('drupalorg', 'https://packages.drupal.org/8', 'composer') |
||
337 | ->getCommand() |
||
338 | ); |
||
339 | } |
||
340 | |||
341 | public function testComposerRequireCommand() |
||
342 | { |
||
343 | $this->assertEquals( |
||
344 | $this->adjustQuotes("composer require 'foo/bar:^2.4.8' --no-interaction"), |
||
345 | (new \Robo\Task\Composer\RequireDependency('composer')) |
||
346 | ->setConfig(new \Robo\Config()) |
||
347 | ->dependency('foo/bar', '^2.4.8') |
||
348 | ->getCommand() |
||
349 | ); |
||
350 | |||
351 | $this->assertEquals( |
||
352 | $this->adjustQuotes("composer require a/b 'x/y:^1' --no-interaction"), |
||
353 | (new \Robo\Task\Composer\RequireDependency('composer')) |
||
354 | ->setConfig(new \Robo\Config()) |
||
355 | ->dependency(['a/b', 'x/y:^1']) |
||
356 | ->getCommand() |
||
357 | ); |
||
358 | } |
||
359 | |||
360 | public function testComposerCreateProjectCommand() |
||
361 | { |
||
362 | $this->assertEquals( |
||
363 | $this->adjustQuotes("composer create-project --repository 'https://packages.drupal.org/8' --keep-vcs --no-install foo/bar mybar '^2.4.8' --no-interaction"), |
||
364 | (new \Robo\Task\Composer\CreateProject('composer')) |
||
365 | ->setConfig(new \Robo\Config()) |
||
366 | ->source('foo/bar') |
||
367 | ->version('^2.4.8') |
||
368 | ->target('mybar') |
||
369 | ->repository('https://packages.drupal.org/8') |
||
370 | ->keepVcs() |
||
371 | ->noInstall() |
||
372 | ->getCommand() |
||
373 | ); |
||
374 | } |
||
375 | } |
||
376 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: