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; |
||
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() |
|
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() |
|
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 | verify( |
||
137 | (new \Robo\Task\Composer\Install('composer'))->setConfig(new \Robo\Config())->getCommand() |
||
138 | )->equals('composer install --no-interaction'); |
||
139 | |||
140 | verify( |
||
141 | (new \Robo\Task\Composer\Install('composer')) |
||
142 | ->setConfig(new \Robo\Config()) |
||
143 | ->noDev() |
||
144 | ->preferDist() |
||
145 | ->optimizeAutoloader() |
||
146 | ->getCommand() |
||
147 | )->equals('composer install --optimize-autoloader --prefer-dist --no-dev --no-interaction'); |
||
148 | } |
||
149 | |||
150 | public function testComposerUpdateCommand() |
||
151 | { |
||
152 | verify( |
||
153 | (new \Robo\Task\Composer\Update('composer'))->setConfig(new \Robo\Config())->getCommand() |
||
154 | )->equals('composer update --no-interaction'); |
||
155 | |||
156 | verify( |
||
157 | (new \Robo\Task\Composer\Update('composer')) |
||
158 | ->setConfig(new \Robo\Config()) |
||
159 | ->noDev() |
||
160 | ->preferDist() |
||
161 | ->getCommand() |
||
162 | )->equals('composer update --prefer-dist --no-dev --no-interaction'); |
||
163 | |||
164 | verify( |
||
165 | (new \Robo\Task\Composer\Update('composer')) |
||
166 | ->setConfig(new \Robo\Config()) |
||
167 | ->noDev() |
||
168 | ->preferDist() |
||
169 | ->optimizeAutoloader() |
||
170 | ->getCommand() |
||
171 | )->equals('composer update --optimize-autoloader --prefer-dist --no-dev --no-interaction'); |
||
172 | } |
||
173 | |||
174 | public function testComposerDumpAutoloadCommand() |
||
175 | { |
||
176 | verify( |
||
177 | (new \Robo\Task\Composer\DumpAutoload('composer'))->setConfig(new \Robo\Config())->getCommand() |
||
178 | )->equals('composer dump-autoload --no-interaction'); |
||
179 | |||
180 | verify( |
||
181 | (new \Robo\Task\Composer\DumpAutoload('composer')) |
||
182 | ->setConfig(new \Robo\Config()) |
||
183 | ->noDev() |
||
184 | ->getCommand() |
||
185 | )->equals('composer dump-autoload --no-dev --no-interaction'); |
||
186 | |||
187 | verify( |
||
188 | (new \Robo\Task\Composer\DumpAutoload('composer')) |
||
189 | ->setConfig(new \Robo\Config()) |
||
190 | ->optimize() |
||
191 | ->getCommand() |
||
192 | )->equals('composer dump-autoload --optimize --no-interaction'); |
||
193 | |||
194 | verify( |
||
195 | (new \Robo\Task\Composer\DumpAutoload('composer')) |
||
196 | ->setConfig(new \Robo\Config()) |
||
197 | ->optimize() |
||
198 | ->noDev() |
||
199 | ->getCommand() |
||
200 | )->equals('composer dump-autoload --optimize --no-dev --no-interaction'); |
||
201 | } |
||
202 | |||
203 | public function testComposerRemove() |
||
204 | { |
||
205 | verify( |
||
206 | (new \Robo\Task\Composer\Remove('composer'))->setConfig(new \Robo\Config())->getCommand() |
||
207 | )->equals('composer remove --no-interaction'); |
||
208 | verify( |
||
209 | (new \Robo\Task\Composer\Remove('composer')) |
||
210 | ->setConfig(new \Robo\Config()) |
||
211 | ->dev() |
||
212 | ->noProgress() |
||
213 | ->noUpdate() |
||
214 | ->getCommand() |
||
215 | )->equals('composer remove --dev --no-progress --no-update --no-interaction'); |
||
216 | } |
||
217 | |||
218 | public function testComposerValidateCommand() |
||
219 | { |
||
220 | verify( |
||
221 | (new \Robo\Task\Composer\Validate('composer'))->setConfig(new \Robo\Config())->getCommand() |
||
222 | )->equals('composer validate --no-interaction'); |
||
223 | |||
224 | verify( |
||
225 | (new \Robo\Task\Composer\Validate('composer')) |
||
226 | ->setConfig(new \Robo\Config()) |
||
227 | ->noCheckAll() |
||
228 | ->getCommand() |
||
229 | )->equals('composer validate --no-check-all --no-interaction'); |
||
230 | |||
231 | verify( |
||
232 | (new \Robo\Task\Composer\Validate('composer')) |
||
233 | ->setConfig(new \Robo\Config()) |
||
234 | ->noCheckLock() |
||
235 | ->getCommand() |
||
236 | )->equals('composer validate --no-check-lock --no-interaction'); |
||
237 | |||
238 | verify( |
||
239 | (new \Robo\Task\Composer\Validate('composer')) |
||
240 | ->setConfig(new \Robo\Config()) |
||
241 | ->noCheckPublish() |
||
242 | ->getCommand() |
||
243 | )->equals('composer validate --no-check-publish --no-interaction'); |
||
244 | |||
245 | verify( |
||
246 | (new \Robo\Task\Composer\Validate('composer')) |
||
247 | ->setConfig(new \Robo\Config()) |
||
248 | ->withDependencies() |
||
249 | ->getCommand() |
||
250 | )->equals('composer validate --with-dependencies --no-interaction'); |
||
251 | |||
252 | verify( |
||
253 | (new \Robo\Task\Composer\Validate('composer')) |
||
254 | ->setConfig(new \Robo\Config()) |
||
255 | ->strict() |
||
256 | ->getCommand() |
||
257 | )->equals('composer validate --strict --no-interaction'); |
||
258 | |||
259 | verify( |
||
260 | (new \Robo\Task\Composer\Validate('composer')) |
||
261 | ->setConfig(new \Robo\Config()) |
||
262 | ->noCheckAll() |
||
263 | ->noCheckLock() |
||
264 | ->noCheckPublish() |
||
265 | ->withDependencies() |
||
266 | ->strict() |
||
267 | ->getCommand() |
||
268 | )->equals('composer validate --no-check-all --no-check-lock --no-check-publish --with-dependencies --strict --no-interaction'); |
||
269 | } |
||
270 | |||
271 | public function testComposerInitCommand() |
||
272 | { |
||
273 | verify( |
||
274 | (new \Robo\Task\Composer\Init('composer'))->setConfig(new \Robo\Config())->getCommand() |
||
0 ignored issues
–
show
|
|||
275 | )->equals('composer init --no-interaction'); |
||
276 | |||
277 | verify( |
||
278 | (new \Robo\Task\Composer\Init('composer')) |
||
279 | ->setConfig(new \Robo\Config()) |
||
0 ignored issues
–
show
The class
Robo\Config has been deprecated with message: Use \Robo\Config\Config
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.
Loading history...
|
|||
280 | ->projectName('foo/bar') |
||
281 | ->description('A test project') |
||
282 | ->dependency('baz/boz', '^2.4.8') |
||
283 | ->projectType('project') |
||
284 | ->homepage('https://foo.bar.com') |
||
285 | ->stability('beta') |
||
286 | ->license('MIT') |
||
287 | ->repository('https://packages.drupal.org/8') |
||
288 | ->getCommand() |
||
289 | )->equals($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")); |
||
290 | |||
291 | } |
||
292 | |||
293 | public function testComposerConfigCommand() |
||
294 | { |
||
295 | verify( |
||
296 | (new \Robo\Task\Composer\Config('composer')) |
||
297 | ->setConfig(new \Robo\Config()) |
||
0 ignored issues
–
show
The class
Robo\Config has been deprecated with message: Use \Robo\Config\Config
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.
Loading history...
|
|||
298 | ->set('bin-dir', 'bin/') |
||
299 | ->getCommand() |
||
300 | )->equals("composer config bin-dir bin/ --no-interaction"); |
||
301 | |||
302 | verify( |
||
303 | (new \Robo\Task\Composer\Config('composer')) |
||
304 | ->setConfig(new \Robo\Config()) |
||
0 ignored issues
–
show
The class
Robo\Config has been deprecated with message: Use \Robo\Config\Config
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.
Loading history...
|
|||
305 | ->useGlobal() |
||
306 | ->set('bin-dir', 'bin/') |
||
307 | ->getCommand() |
||
308 | )->equals("composer config --global bin-dir bin/ --no-interaction"); |
||
309 | |||
310 | verify( |
||
311 | (new \Robo\Task\Composer\Config('composer')) |
||
312 | ->setConfig(new \Robo\Config()) |
||
0 ignored issues
–
show
The class
Robo\Config has been deprecated with message: Use \Robo\Config\Config
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.
Loading history...
|
|||
313 | ->repository('drupalorg', 'https://packages.drupal.org/8', 'composer') |
||
314 | ->getCommand() |
||
315 | )->equals($this->adjustQuotes("composer config repositories.drupalorg composer 'https://packages.drupal.org/8' --no-interaction")); |
||
316 | } |
||
317 | |||
318 | public function testComposerRequireCommand() |
||
319 | { |
||
320 | verify( |
||
321 | (new \Robo\Task\Composer\RequireDependency('composer')) |
||
322 | ->setConfig(new \Robo\Config()) |
||
0 ignored issues
–
show
The class
Robo\Config has been deprecated with message: Use \Robo\Config\Config
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.
Loading history...
|
|||
323 | ->dependency('foo/bar', '^2.4.8') |
||
324 | ->getCommand() |
||
325 | )->equals($this->adjustQuotes("composer require 'foo/bar:^2.4.8' --no-interaction")); |
||
326 | |||
327 | verify( |
||
328 | (new \Robo\Task\Composer\RequireDependency('composer')) |
||
329 | ->setConfig(new \Robo\Config()) |
||
0 ignored issues
–
show
The class
Robo\Config has been deprecated with message: Use \Robo\Config\Config
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.
Loading history...
|
|||
330 | ->dependency(['a/b', 'x/y:^1']) |
||
331 | ->getCommand() |
||
332 | )->equals($this->adjustQuotes("composer require a/b 'x/y:^1' --no-interaction")); |
||
333 | } |
||
334 | |||
335 | public function testComposerCreateProjectCommand() |
||
336 | { |
||
337 | verify( |
||
338 | (new \Robo\Task\Composer\CreateProject('composer')) |
||
339 | ->setConfig(new \Robo\Config()) |
||
0 ignored issues
–
show
The class
Robo\Config has been deprecated with message: Use \Robo\Config\Config
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.
Loading history...
|
|||
340 | ->source('foo/bar') |
||
341 | ->version('^2.4.8') |
||
342 | ->target('mybar') |
||
343 | ->repository('https://packages.drupal.org/8') |
||
344 | ->keepVcs() |
||
345 | ->noInstall() |
||
346 | ->getCommand() |
||
347 | )->equals($this->adjustQuotes("composer create-project --repository 'https://packages.drupal.org/8' --keep-vcs --no-install foo/bar mybar '^2.4.8' --no-interaction")); |
||
348 | } |
||
349 | } |
||
350 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.