@@ -32,11 +32,10 @@ protected function setUp(): void
32
32
$ filesystem ->remove (FLEX_TEST_DIR );
33
33
}
34
34
35
-
36
35
public function testFileDoesNotExistSkipped ()
37
36
{
38
37
$ this ->runConfigure ([
39
- ['file ' => 'non-existent.php ' ]
38
+ ['file ' => 'non-existent.php ' ],
40
39
]);
41
40
$ this ->assertFileDoesNotExist (FLEX_TEST_DIR .'/non-existent.php ' );
42
41
}
@@ -54,7 +53,7 @@ public function testLinesAddedToTopOfFile()
54
53
[
55
54
'file ' => 'assets/app.js ' ,
56
55
'position ' => 'top ' ,
57
- 'content ' => "import './bootstrap'; "
56
+ 'content ' => "import './bootstrap'; " ,
58
57
],
59
58
]);
60
59
$ actualContents = $ this ->readFile ('assets/app.js ' );
@@ -63,7 +62,8 @@ public function testLinesAddedToTopOfFile()
63
62
import * as Turbo from '@hotwired/turbo';
64
63
65
64
console.log(Turbo);
66
- EOF ,
65
+ EOF
66
+ ,
67
67
$ actualContents );
68
68
}
69
69
@@ -80,7 +80,7 @@ public function testLinesAddedToBottomOfFile()
80
80
[
81
81
'file ' => 'assets/app.js ' ,
82
82
'position ' => 'bottom ' ,
83
- 'content ' => "import './bootstrap'; "
83
+ 'content ' => "import './bootstrap'; " ,
84
84
],
85
85
]);
86
86
$ actualContents = $ this ->readFile ('assets/app.js ' );
@@ -89,7 +89,8 @@ public function testLinesAddedToBottomOfFile()
89
89
90
90
console.log(Turbo);
91
91
import './bootstrap';
92
- EOF ,
92
+ EOF
93
+ ,
93
94
$ actualContents );
94
95
}
95
96
@@ -122,7 +123,6 @@ public function testLinesAddedAfterTarget()
122
123
// enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js)
123
124
.enableStimulusBridge('./assets/controllers.json')
124
125
EOF
125
-
126
126
],
127
127
]);
128
128
@@ -144,7 +144,8 @@ public function testLinesAddedAfterTarget()
144
144
;
145
145
146
146
module.exports = Encore.getWebpackConfig();
147
- EOF ,
147
+ EOF
148
+ ,
148
149
$ actualContents );
149
150
}
150
151
@@ -171,7 +172,6 @@ public function testSkippedIfTargetCannotBeFound()
171
172
172
173
// some new line
173
174
EOF
174
-
175
175
],
176
176
]);
177
177
@@ -193,7 +193,7 @@ public function testPatchIgnoredIfValueAlreadyExists()
193
193
[
194
194
'file ' => 'assets/app.js ' ,
195
195
'position ' => 'top ' ,
196
- 'content ' => "import './bootstrap'; "
196
+ 'content ' => "import './bootstrap'; " ,
197
197
],
198
198
]);
199
199
$ actualContents = $ this ->readFile ('assets/app.js ' );
@@ -212,30 +212,31 @@ public function testLinesAddedToMultipleFiles()
212
212
EOF
213
213
);
214
214
215
-
216
215
$ this ->runConfigure ([
217
216
[
218
217
'file ' => 'assets/app.js ' ,
219
218
'position ' => 'top ' ,
220
- 'content ' => "import './bootstrap'; "
219
+ 'content ' => "import './bootstrap'; " ,
221
220
],
222
221
[
223
222
'file ' => 'assets/bootstrap.js ' ,
224
223
'position ' => 'bottom ' ,
225
- 'content ' => "console.log('on the bottom'); "
224
+ 'content ' => "console.log('on the bottom'); " ,
226
225
],
227
226
]);
228
227
229
228
$ this ->assertSame (<<<EOF
230
229
import './bootstrap';
231
230
import * as Turbo from '@hotwired/turbo';
232
- EOF ,
231
+ EOF
232
+ ,
233
233
$ this ->readFile ('assets/app.js ' ));
234
234
235
235
$ this ->assertSame (<<<EOF
236
236
console.log('bootstrap.js');
237
237
console.log('on the bottom');
238
- EOF ,
238
+ EOF
239
+ ,
239
240
$ this ->readFile ('assets/bootstrap.js ' ));
240
241
}
241
242
@@ -248,20 +249,22 @@ public function testLineSkippedIfRequiredPackageMissing()
248
249
EOF
249
250
);
250
251
252
+ $ composer = $ this ->createComposerMockWithPackagesInstalled ([]);
251
253
$ this ->runConfigure ([
252
254
[
253
255
'file ' => 'assets/app.js ' ,
254
256
'position ' => 'top ' ,
255
257
'content ' => "import './bootstrap'; " ,
256
258
'requires ' => 'symfony/invented-package ' ,
257
259
],
258
- ]);
260
+ ], $ composer );
259
261
$ actualContents = $ this ->readFile ('assets/app.js ' );
260
262
$ this ->assertSame (<<<EOF
261
263
import * as Turbo from '@hotwired/turbo';
262
264
263
265
console.log(Turbo);
264
- EOF ,
266
+ EOF
267
+ ,
265
268
$ actualContents );
266
269
}
267
270
@@ -293,7 +296,8 @@ public function testLineProcessedIfRequiredPackageIsPresent()
293
296
import * as Turbo from '@hotwired/turbo';
294
297
295
298
console.log(Turbo);
296
- EOF ,
299
+ EOF
300
+ ,
297
301
$ actualContents );
298
302
}
299
303
@@ -356,7 +360,7 @@ public function getUnconfigureTests()
356
360
console.log(Turbo);
357
361
EOF
358
362
,
359
- " console.log(Turbo); " ,
363
+ ' console.log(Turbo); ' ,
360
364
<<<EOF
361
365
import * as Turbo from '@hotwired/turbo';
362
366
import './bootstrap';
@@ -390,7 +394,7 @@ public function getUnconfigureTests()
390
394
console.log(Turbo);
391
395
EOF
392
396
,
393
- " console.log(Turbo); " ,
397
+ ' console.log(Turbo); ' ,
394
398
<<<EOF
395
399
import * as Turbo from '@hotwired/turbo';
396
400
import './bootstrap';
@@ -439,14 +443,13 @@ public function getUpdateTests()
439
443
console.log('on the bottom');
440
444
EOF ;
441
445
442
-
443
446
yield 'recipe_changes_patch_contents ' => [
444
447
['assets/app.js ' => $ appJs ],
445
448
[
446
- ['file ' => 'assets/app.js ' , 'position ' => 'top ' , 'content ' => "import './bootstrap'; " ]
449
+ ['file ' => 'assets/app.js ' , 'position ' => 'top ' , 'content ' => "import './bootstrap'; " ],
447
450
],
448
451
[
449
- ['file ' => 'assets/app.js ' , 'position ' => 'top ' , 'content ' => "import './stimulus_bootstrap'; " ]
452
+ ['file ' => 'assets/app.js ' , 'position ' => 'top ' , 'content ' => "import './stimulus_bootstrap'; " ],
450
453
],
451
454
['assets/app.js ' => <<<EOF
452
455
import './stimulus_bootstrap';
@@ -460,28 +463,29 @@ public function getUpdateTests()
460
463
yield 'recipe_file_and_value_same_before_and_after ' => [
461
464
['assets/app.js ' => $ appJs ],
462
465
[
463
- ['file ' => 'assets/app.js ' , 'position ' => 'top ' , 'content ' => "import * as Turbo from '@hotwired/turbo'; " ]
466
+ ['file ' => 'assets/app.js ' , 'position ' => 'top ' , 'content ' => "import * as Turbo from '@hotwired/turbo'; " ],
464
467
],
465
468
[
466
- ['file ' => 'assets/app.js ' , 'position ' => 'top ' , 'content ' => "import * as Turbo from '@hotwired/turbo'; " ]
469
+ ['file ' => 'assets/app.js ' , 'position ' => 'top ' , 'content ' => "import * as Turbo from '@hotwired/turbo'; " ],
467
470
],
468
471
['assets/app.js ' => $ appJs ],
469
472
];
470
473
471
474
yield 'different_files_unconfigures_old_and_configures_new ' => [
472
475
['assets/app.js ' => $ appJs , 'assets/bootstrap.js ' => $ bootstrapJs ],
473
476
[
474
- ['file ' => 'assets/app.js ' , 'position ' => 'top ' , 'content ' => "import * as Turbo from '@hotwired/turbo'; " ]
477
+ ['file ' => 'assets/app.js ' , 'position ' => 'top ' , 'content ' => "import * as Turbo from '@hotwired/turbo'; " ],
475
478
],
476
479
[
477
- ['file ' => 'assets/bootstrap.js ' , 'position ' => 'top ' , 'content ' => "import * as Turbo from '@hotwired/turbo'; " ]
480
+ ['file ' => 'assets/bootstrap.js ' , 'position ' => 'top ' , 'content ' => "import * as Turbo from '@hotwired/turbo'; " ],
478
481
],
479
482
[
480
483
'assets/app.js ' => <<<EOF
481
484
import './bootstrap';
482
485
483
486
console.log(Turbo);
484
- EOF ,
487
+ EOF
488
+ ,
485
489
'assets/bootstrap.js ' => <<<EOF
486
490
import * as Turbo from '@hotwired/turbo';
487
491
console.log('bootstrap.js');
@@ -494,21 +498,21 @@ public function getUpdateTests()
494
498
yield 'recipe_changes_but_ignored_because_package_not_installed ' => [
495
499
['assets/app.js ' => $ appJs ],
496
500
[
497
- ['file ' => 'assets/app.js ' , 'position ' => 'top ' , 'content ' => "import './bootstrap'; " , 'requires ' => 'symfony/not-installed ' ]
501
+ ['file ' => 'assets/app.js ' , 'position ' => 'top ' , 'content ' => "import './bootstrap'; " , 'requires ' => 'symfony/not-installed ' ],
498
502
],
499
503
[
500
- ['file ' => 'assets/app.js ' , 'position ' => 'top ' , 'content ' => "import './stimulus_bootstrap'; " , 'requires ' => 'symfony/not-installed ' ]
504
+ ['file ' => 'assets/app.js ' , 'position ' => 'top ' , 'content ' => "import './stimulus_bootstrap'; " , 'requires ' => 'symfony/not-installed ' ],
501
505
],
502
506
['assets/app.js ' => $ appJs ],
503
507
];
504
508
505
509
yield 'recipe_changes_are_applied_if_required_package_installed ' => [
506
510
['assets/app.js ' => $ appJs ],
507
511
[
508
- ['file ' => 'assets/app.js ' , 'position ' => 'top ' , 'content ' => "import './bootstrap'; " , 'requires ' => 'symfony/installed-package ' ]
512
+ ['file ' => 'assets/app.js ' , 'position ' => 'top ' , 'content ' => "import './bootstrap'; " , 'requires ' => 'symfony/installed-package ' ],
509
513
],
510
514
[
511
- ['file ' => 'assets/app.js ' , 'position ' => 'top ' , 'content ' => "import './stimulus_bootstrap'; " , 'requires ' => 'symfony/installed-package ' ]
515
+ ['file ' => 'assets/app.js ' , 'position ' => 'top ' , 'content ' => "import './stimulus_bootstrap'; " , 'requires ' => 'symfony/installed-package ' ],
512
516
],
513
517
['assets/app.js ' => <<<EOF
514
518
import './stimulus_bootstrap';
@@ -541,7 +545,7 @@ private function runUnconfigure(array $config)
541
545
private function createConfigurator (Composer $ composer = null )
542
546
{
543
547
return new AddLinesConfigurator (
544
- $ composer ? $ composer : $ this ->getMockBuilder (Composer::class)->getMock (),
548
+ $ composer ?: $ this ->getMockBuilder (Composer::class)->getMock (),
545
549
$ this ->getMockBuilder (IOInterface::class)->getMock (),
546
550
new Options (['config-dir ' => 'config ' , 'root-dir ' => FLEX_TEST_DIR ])
547
551
);
0 commit comments