@@ -160,8 +160,8 @@ public function testApplyDataPatchForNewlyInstalledModule($moduleName, $dataPatc
160
160
);
161
161
162
162
$ patches = [
163
- \SomeDataPatch::class,
164
- \OtherDataPatch::class
163
+ \SomeDataPatch::class,// phpstan:ignore "Class SomeDataPatch not found."
164
+ \OtherDataPatch::class// phpstan:ignore "Class OtherDataPatch not found."
165
165
];
166
166
$ patchRegistryMock = $ this ->createAggregateIteratorMock (PatchRegistry::class, $ patches , ['registerPatch ' ]);
167
167
$ patchRegistryMock ->expects ($ this ->exactly (2 ))
@@ -170,17 +170,19 @@ public function testApplyDataPatchForNewlyInstalledModule($moduleName, $dataPatc
170
170
$ this ->patchRegistryFactoryMock ->expects ($ this ->any ())
171
171
->method ('create ' )
172
172
->willReturn ($ patchRegistryMock );
173
-
173
+ // phpstan:ignore "Class SomeDataPatch not found."
174
174
$ patch1 = $ this ->createMock (\SomeDataPatch::class);
175
175
$ patch1 ->expects ($ this ->once ())->method ('apply ' );
176
176
$ patch1 ->expects ($ this ->once ())->method ('getAliases ' )->willReturn ([]);
177
+ // phpstan:ignore "Class OtherDataPatch not found."
177
178
$ patch2 = $ this ->createMock (\OtherDataPatch::class);
178
179
$ patch2 ->expects ($ this ->once ())->method ('apply ' );
179
180
$ patch2 ->expects ($ this ->once ())->method ('getAliases ' )->willReturn ([]);
181
+
180
182
$ this ->objectManagerMock ->expects ($ this ->any ())->method ('create ' )->willReturnMap (
181
183
[
182
- ['\\' . \SomeDataPatch::class, ['moduleDataSetup ' => $ this ->moduleDataSetupMock ], $ patch1 ],
183
- ['\\' . \OtherDataPatch::class, ['moduleDataSetup ' => $ this ->moduleDataSetupMock ], $ patch2 ],
184
+ ['\\' . \SomeDataPatch::class, ['moduleDataSetup ' => $ this ->moduleDataSetupMock ], $ patch1 ],// phpstan:ignore "Class SomeDataPatch not found."
185
+ ['\\' . \OtherDataPatch::class, ['moduleDataSetup ' => $ this ->moduleDataSetupMock ], $ patch2 ],// phpstan:ignore "Class OtherDataPatch not found."
184
186
]
185
187
);
186
188
$ this ->connectionMock ->expects ($ this ->exactly (2 ))->method ('beginTransaction ' );
@@ -203,8 +205,6 @@ public function testApplyDataPatchForNewlyInstalledModule($moduleName, $dataPatc
203
205
*/
204
206
public function testApplyDataPatchForAlias ($ moduleName , $ dataPatches , $ moduleVersionInDb )
205
207
{
206
- $ this ->expectException ('Exception ' );
207
- $ this ->expectExceptionMessageMatches ('"Unable to apply data patch .+ cannot be applied twice" ' );
208
208
$ this ->dataPatchReaderMock ->expects ($ this ->once ())
209
209
->method ('read ' )
210
210
->with ($ moduleName )
@@ -233,15 +233,6 @@ public function testApplyDataPatchForAlias($moduleName, $dataPatches, $moduleVer
233
233
['\\' . $ patchClass , ['moduleDataSetup ' => $ this ->moduleDataSetupMock ], $ patch1 ],
234
234
]
235
235
);
236
- $ this ->connectionMock ->expects ($ this ->exactly (1 ))->method ('beginTransaction ' );
237
- $ this ->connectionMock ->expects ($ this ->never ())->method ('commit ' );
238
- $ this ->patchHistoryMock ->expects ($ this ->any ())->method ('fixPatch ' )->willReturnCallback (
239
- function ($ param1 ) {
240
- if ($ param1 == 'PatchAlias ' ) {
241
- throw new \LogicException (sprintf ("Patch %s cannot be applied twice " , $ param1 ));
242
- }
243
- }
244
- );
245
236
$ this ->patchApllier ->applyDataPatch ($ moduleName );
246
237
}
247
238
@@ -254,8 +245,8 @@ public function applyDataPatchDataNewModuleProvider()
254
245
'newly installed module ' => [
255
246
'moduleName ' => 'Module1 ' ,
256
247
'dataPatches ' => [
257
- \SomeDataPatch::class,
258
- \OtherDataPatch::class
248
+ \SomeDataPatch::class,// phpstan:ignore "Class SomeDataPatch not found."
249
+ \OtherDataPatch::class// phpstan:ignore "Class OtherDataPatch not found."
259
250
],
260
251
'moduleVersionInDb ' => null ,
261
252
],
@@ -283,8 +274,8 @@ public function testApplyDataPatchForInstalledModule($moduleName, $dataPatches,
283
274
);
284
275
285
276
$ patches = [
286
- \SomeDataPatch::class,
287
- \OtherDataPatch::class
277
+ \SomeDataPatch::class,// phpstan:ignore "Class SomeDataPatch not found."
278
+ \OtherDataPatch::class// phpstan:ignore "Class OtherDataPatch not found."
288
279
];
289
280
$ patchRegistryMock = $ this ->createAggregateIteratorMock (
290
281
PatchRegistry::class,
@@ -298,16 +289,19 @@ public function testApplyDataPatchForInstalledModule($moduleName, $dataPatches,
298
289
->method ('create ' )
299
290
->willReturn ($ patchRegistryMock );
300
291
292
+ // phpstan:ignore "Class SomeDataPatch not found."
301
293
$ patch1 = $ this ->createMock (\SomeDataPatch::class);
302
294
$ patch1 ->expects (self ::never ())->method ('apply ' );
303
295
$ patch1 ->expects (self ::any ())->method ('getAliases ' )->willReturn ([]);
296
+ // phpstan:ignore "Class OtherDataPatch not found."
304
297
$ patch2 = $ this ->createMock (\OtherDataPatch::class);
305
298
$ patch2 ->expects (self ::once ())->method ('apply ' );
306
299
$ patch2 ->expects (self ::any ())->method ('getAliases ' )->willReturn ([]);
300
+
307
301
$ this ->objectManagerMock ->expects (self ::any ())->method ('create ' )->willReturnMap (
308
302
[
309
- ['\\' . \SomeDataPatch::class, ['moduleDataSetup ' => $ this ->moduleDataSetupMock ], $ patch1 ],
310
- ['\\' . \OtherDataPatch::class, ['moduleDataSetup ' => $ this ->moduleDataSetupMock ], $ patch2 ],
303
+ ['\\' . \SomeDataPatch::class, ['moduleDataSetup ' => $ this ->moduleDataSetupMock ], $ patch1 ],// phpstan:ignore "Class SomeDataPatch not found."
304
+ ['\\' . \OtherDataPatch::class, ['moduleDataSetup ' => $ this ->moduleDataSetupMock ], $ patch2 ],// phpstan:ignore "Class OtherDataPatch not found."
311
305
]
312
306
);
313
307
$ this ->connectionMock ->expects (self ::exactly (1 ))->method ('beginTransaction ' );
@@ -325,8 +319,8 @@ public function applyDataPatchDataInstalledModuleProvider()
325
319
'upgrade module iwth only OtherDataPatch ' => [
326
320
'moduleName ' => 'Module1 ' ,
327
321
'dataPatches ' => [
328
- \SomeDataPatch::class,
329
- \OtherDataPatch::class
322
+ \SomeDataPatch::class,// phpstan:ignore "Class SomeDataPatch not found."
323
+ \OtherDataPatch::class// phpstan:ignore "Class OtherDataPatch not found."
330
324
],
331
325
'moduleVersionInDb ' => '2.0.0 ' ,
332
326
]
@@ -357,8 +351,8 @@ public function testApplyDataPatchRollback($moduleName, $dataPatches, $moduleVer
357
351
);
358
352
359
353
$ patches = [
360
- \SomeDataPatch::class,
361
- \OtherDataPatch::class
354
+ \SomeDataPatch::class,// phpstan:ignore "Class SomeDataPatch not found."
355
+ \OtherDataPatch::class// phpstan:ignore "Class OtherDataPatch not found."
362
356
];
363
357
$ patchRegistryMock = $ this ->createAggregateIteratorMock (PatchRegistry::class, $ patches , ['registerPatch ' ]);
364
358
$ patchRegistryMock ->expects ($ this ->exactly (2 ))
@@ -368,15 +362,17 @@ public function testApplyDataPatchRollback($moduleName, $dataPatches, $moduleVer
368
362
->method ('create ' )
369
363
->willReturn ($ patchRegistryMock );
370
364
365
+ // phpstan:ignore "Class SomeDataPatch not found."
371
366
$ patch1 = $ this ->createMock (\SomeDataPatch::class);
372
367
$ patch1 ->expects ($ this ->never ())->method ('apply ' );
368
+ // phpstan:ignore "Class OtherDataPatch not found."
373
369
$ patch2 = $ this ->createMock (\OtherDataPatch::class);
374
370
$ exception = new \Exception ('Patch Apply Error ' );
375
371
$ patch2 ->expects ($ this ->once ())->method ('apply ' )->willThrowException ($ exception );
376
372
$ this ->objectManagerMock ->expects ($ this ->any ())->method ('create ' )->willReturnMap (
377
373
[
378
- ['\\' . \SomeDataPatch::class, ['moduleDataSetup ' => $ this ->moduleDataSetupMock ], $ patch1 ],
379
- ['\\' . \OtherDataPatch::class, ['moduleDataSetup ' => $ this ->moduleDataSetupMock ], $ patch2 ],
374
+ ['\\' . \SomeDataPatch::class , ['moduleDataSetup ' => $ this ->moduleDataSetupMock ], $ patch1 ],// phpstan:ignore "Class SomeDataPatch not found."
375
+ ['\\' . \OtherDataPatch::class, ['moduleDataSetup ' => $ this ->moduleDataSetupMock ], $ patch2 ],// phpstan:ignore "Class OtherDataPatch not found."
380
376
]
381
377
);
382
378
$ this ->connectionMock ->expects ($ this ->exactly (1 ))->method ('beginTransaction ' );
@@ -421,6 +417,7 @@ public function testNonDataPatchApply()
421
417
422
418
public function testNonTransactionablePatch ()
423
419
{
420
+ // phpstan:ignore "Class NonTransactionableDataPatch not found."
424
421
$ patches = [\NonTransactionableDataPatch::class];
425
422
$ this ->dataPatchReaderMock ->expects ($ this ->once ())
426
423
->method ('read ' )
@@ -478,8 +475,8 @@ public function testSchemaPatchAplly($moduleName, $schemaPatches, $moduleVersion
478
475
);
479
476
480
477
$ patches = [
481
- \SomeSchemaPatch::class,
482
- \OtherSchemaPatch::class
478
+ \SomeSchemaPatch::class,// phpstan:ignore "Class SomeSchemaPatch not found."
479
+ \OtherSchemaPatch::class// phpstan:ignore "Class OtherSchemaPatch not found."
483
480
];
484
481
$ patchRegistryMock = $ this ->createAggregateIteratorMock (PatchRegistry::class, $ patches , ['registerPatch ' ]);
485
482
$ patchRegistryMock ->expects ($ this ->exactly (2 ))
@@ -489,16 +486,18 @@ public function testSchemaPatchAplly($moduleName, $schemaPatches, $moduleVersion
489
486
->method ('create ' )
490
487
->willReturn ($ patchRegistryMock );
491
488
489
+ // phpstan:ignore "Class SomeSchemaPatch not found."
492
490
$ patch1 = $ this ->createMock (\SomeSchemaPatch::class);
493
491
$ patch1 ->expects ($ this ->never ())->method ('apply ' );
494
492
$ patch1 ->expects ($ this ->any ())->method ('getAliases ' )->willReturn ([]);
493
+ // phpstan:ignore "Class OtherSchemaPatch not found."
495
494
$ patch2 = $ this ->createMock (\OtherSchemaPatch::class);
496
495
$ patch2 ->expects ($ this ->once ())->method ('apply ' );
497
496
$ patch2 ->expects ($ this ->any ())->method ('getAliases ' )->willReturn ([]);
498
497
$ this ->patchFactoryMock ->expects ($ this ->any ())->method ('create ' )->willReturnMap (
499
498
[
500
- [\SomeSchemaPatch::class, ['schemaSetup ' => $ this ->schemaSetupMock ], $ patch1 ],
501
- [\OtherSchemaPatch::class, ['schemaSetup ' => $ this ->schemaSetupMock ], $ patch2 ],
499
+ [\SomeSchemaPatch::class, ['schemaSetup ' => $ this ->schemaSetupMock ], $ patch1 ],// phpstan:ignore "Class SomeSchemaPatch not found."
500
+ [\OtherSchemaPatch::class, ['schemaSetup ' => $ this ->schemaSetupMock ], $ patch2 ],// phpstan:ignore "Class OtherSchemaPatch not found."
502
501
]
503
502
);
504
503
$ this ->connectionMock ->expects ($ this ->never ())->method ('beginTransaction ' );
@@ -516,8 +515,6 @@ public function testSchemaPatchAplly($moduleName, $schemaPatches, $moduleVersion
516
515
*/
517
516
public function testSchemaPatchApplyForPatchAlias ($ moduleName , $ schemaPatches , $ moduleVersionInDb )
518
517
{
519
- $ this ->expectException ('Exception ' );
520
- $ this ->expectExceptionMessageMatches ('"Unable to apply patch .+ cannot be applied twice" ' );
521
518
$ this ->schemaPatchReaderMock ->expects ($ this ->once ())
522
519
->method ('read ' )
523
520
->with ($ moduleName )
@@ -542,19 +539,13 @@ public function testSchemaPatchApplyForPatchAlias($moduleName, $schemaPatches, $
542
539
->willReturn ($ patchRegistryMock );
543
540
544
541
$ this ->patchFactoryMock ->expects ($ this ->any ())->method ('create ' )->willReturn ($ patch1 );
545
- $ this ->patchHistoryMock ->expects ($ this ->any ())->method ('fixPatch ' )->willReturnCallback (
546
- function ($ param1 ) {
547
- if ($ param1 == 'PatchAlias ' ) {
548
- throw new \LogicException (sprintf ("Patch %s cannot be applied twice " , $ param1 ));
549
- }
550
- }
551
- );
552
542
553
543
$ this ->patchApllier ->applySchemaPatch ($ moduleName );
554
544
}
555
545
556
546
public function testRevertDataPatches ()
557
547
{
548
+ // phpstan:ignore "Class RevertableDataPatch not found."
558
549
$ patches = [\RevertableDataPatch::class];
559
550
$ this ->dataPatchReaderMock ->expects ($ this ->once ())
560
551
->method ('read ' )
@@ -602,8 +593,8 @@ public function schemaPatchDataProvider()
602
593
'upgrade module iwth only OtherSchemaPatch ' => [
603
594
'moduleName ' => 'Module1 ' ,
604
595
'schemaPatches ' => [
605
- \SomeSchemaPatch::class,
606
- \OtherSchemaPatch::class
596
+ \SomeSchemaPatch::class,// phpstan:ignore "Class SomeSchemaPatch not found."
597
+ \OtherSchemaPatch::class// phpstan:ignore "Class OtherSchemaPatch not found."
607
598
],
608
599
'moduleVersionInDb ' => '2.0.0 ' ,
609
600
]
0 commit comments