@@ -159,8 +159,10 @@ public function testApplyDataPatchForNewlyInstalledModule($moduleName, $dataPatc
159
159
]
160
160
);
161
161
162
+ // phpstan:ignore
162
163
$ patches = [
163
164
\SomeDataPatch::class,
165
+ // phpstan:ignore
164
166
\OtherDataPatch::class
165
167
];
166
168
$ patchRegistryMock = $ this ->createAggregateIteratorMock (PatchRegistry::class, $ patches , ['registerPatch ' ]);
@@ -170,16 +172,20 @@ public function testApplyDataPatchForNewlyInstalledModule($moduleName, $dataPatc
170
172
$ this ->patchRegistryFactoryMock ->expects ($ this ->any ())
171
173
->method ('create ' )
172
174
->willReturn ($ patchRegistryMock );
173
-
175
+ // phpstan:ignore "Class SomeDataPatch not found."
174
176
$ patch1 = $ this ->createMock (\SomeDataPatch::class);
175
177
$ patch1 ->expects ($ this ->once ())->method ('apply ' );
176
178
$ patch1 ->expects ($ this ->once ())->method ('getAliases ' )->willReturn ([]);
179
+ // phpstan:ignore "Class OtherDataPatch not found."
177
180
$ patch2 = $ this ->createMock (\OtherDataPatch::class);
178
181
$ patch2 ->expects ($ this ->once ())->method ('apply ' );
179
182
$ patch2 ->expects ($ this ->once ())->method ('getAliases ' )->willReturn ([]);
183
+
180
184
$ this ->objectManagerMock ->expects ($ this ->any ())->method ('create ' )->willReturnMap (
181
185
[
186
+ // phpstan:ignore
182
187
['\\' . \SomeDataPatch::class, ['moduleDataSetup ' => $ this ->moduleDataSetupMock ], $ patch1 ],
188
+ // phpstan:ignore
183
189
['\\' . \OtherDataPatch::class, ['moduleDataSetup ' => $ this ->moduleDataSetupMock ], $ patch2 ],
184
190
]
185
191
);
@@ -203,8 +209,6 @@ public function testApplyDataPatchForNewlyInstalledModule($moduleName, $dataPatc
203
209
*/
204
210
public function testApplyDataPatchForAlias ($ moduleName , $ dataPatches , $ moduleVersionInDb )
205
211
{
206
- $ this ->expectException ('Exception ' );
207
- $ this ->expectExceptionMessageMatches ('"Unable to apply data patch .+ cannot be applied twice" ' );
208
212
$ this ->dataPatchReaderMock ->expects ($ this ->once ())
209
213
->method ('read ' )
210
214
->with ($ moduleName )
@@ -233,15 +237,6 @@ public function testApplyDataPatchForAlias($moduleName, $dataPatches, $moduleVer
233
237
['\\' . $ patchClass , ['moduleDataSetup ' => $ this ->moduleDataSetupMock ], $ patch1 ],
234
238
]
235
239
);
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
240
$ this ->patchApllier ->applyDataPatch ($ moduleName );
246
241
}
247
242
@@ -254,7 +249,9 @@ public function applyDataPatchDataNewModuleProvider()
254
249
'newly installed module ' => [
255
250
'moduleName ' => 'Module1 ' ,
256
251
'dataPatches ' => [
252
+ // phpstan:ignore
257
253
\SomeDataPatch::class,
254
+ // phpstan:ignore
258
255
\OtherDataPatch::class
259
256
],
260
257
'moduleVersionInDb ' => null ,
@@ -282,8 +279,10 @@ public function testApplyDataPatchForInstalledModule($moduleName, $dataPatches,
282
279
]
283
280
);
284
281
282
+ // phpstan:ignore
285
283
$ patches = [
286
284
\SomeDataPatch::class,
285
+ // phpstan:ignore
287
286
\OtherDataPatch::class
288
287
];
289
288
$ patchRegistryMock = $ this ->createAggregateIteratorMock (
@@ -298,15 +297,20 @@ public function testApplyDataPatchForInstalledModule($moduleName, $dataPatches,
298
297
->method ('create ' )
299
298
->willReturn ($ patchRegistryMock );
300
299
300
+ // phpstan:ignore "Class SomeDataPatch not found."
301
301
$ patch1 = $ this ->createMock (\SomeDataPatch::class);
302
302
$ patch1 ->expects (self ::never ())->method ('apply ' );
303
303
$ patch1 ->expects (self ::any ())->method ('getAliases ' )->willReturn ([]);
304
+ // phpstan:ignore "Class OtherDataPatch not found."
304
305
$ patch2 = $ this ->createMock (\OtherDataPatch::class);
305
306
$ patch2 ->expects (self ::once ())->method ('apply ' );
306
307
$ patch2 ->expects (self ::any ())->method ('getAliases ' )->willReturn ([]);
308
+
307
309
$ this ->objectManagerMock ->expects (self ::any ())->method ('create ' )->willReturnMap (
308
310
[
311
+ // phpstan:ignore
309
312
['\\' . \SomeDataPatch::class, ['moduleDataSetup ' => $ this ->moduleDataSetupMock ], $ patch1 ],
313
+ // phpstan:ignore
310
314
['\\' . \OtherDataPatch::class, ['moduleDataSetup ' => $ this ->moduleDataSetupMock ], $ patch2 ],
311
315
]
312
316
);
@@ -325,7 +329,9 @@ public function applyDataPatchDataInstalledModuleProvider()
325
329
'upgrade module iwth only OtherDataPatch ' => [
326
330
'moduleName ' => 'Module1 ' ,
327
331
'dataPatches ' => [
332
+ // phpstan:ignore
328
333
\SomeDataPatch::class,
334
+ // phpstan:ignore
329
335
\OtherDataPatch::class
330
336
],
331
337
'moduleVersionInDb ' => '2.0.0 ' ,
@@ -356,8 +362,10 @@ public function testApplyDataPatchRollback($moduleName, $dataPatches, $moduleVer
356
362
]
357
363
);
358
364
365
+ // phpstan:ignore
359
366
$ patches = [
360
367
\SomeDataPatch::class,
368
+ // phpstan:ignore
361
369
\OtherDataPatch::class
362
370
];
363
371
$ patchRegistryMock = $ this ->createAggregateIteratorMock (PatchRegistry::class, $ patches , ['registerPatch ' ]);
@@ -368,14 +376,19 @@ public function testApplyDataPatchRollback($moduleName, $dataPatches, $moduleVer
368
376
->method ('create ' )
369
377
->willReturn ($ patchRegistryMock );
370
378
379
+ // phpstan:ignore "Class SomeDataPatch not found."
371
380
$ patch1 = $ this ->createMock (\SomeDataPatch::class);
372
381
$ patch1 ->expects ($ this ->never ())->method ('apply ' );
382
+ // phpstan:ignore "Class OtherDataPatch not found."
373
383
$ patch2 = $ this ->createMock (\OtherDataPatch::class);
374
384
$ exception = new \Exception ('Patch Apply Error ' );
375
385
$ patch2 ->expects ($ this ->once ())->method ('apply ' )->willThrowException ($ exception );
386
+
376
387
$ this ->objectManagerMock ->expects ($ this ->any ())->method ('create ' )->willReturnMap (
377
388
[
389
+ // phpstan:ignore
378
390
['\\' . \SomeDataPatch::class, ['moduleDataSetup ' => $ this ->moduleDataSetupMock ], $ patch1 ],
391
+ // phpstan:ignore
379
392
['\\' . \OtherDataPatch::class, ['moduleDataSetup ' => $ this ->moduleDataSetupMock ], $ patch2 ],
380
393
]
381
394
);
@@ -421,6 +434,7 @@ public function testNonDataPatchApply()
421
434
422
435
public function testNonTransactionablePatch ()
423
436
{
437
+ // phpstan:ignore "Class NonTransactionableDataPatch not found."
424
438
$ patches = [\NonTransactionableDataPatch::class];
425
439
$ this ->dataPatchReaderMock ->expects ($ this ->once ())
426
440
->method ('read ' )
@@ -477,8 +491,10 @@ public function testSchemaPatchAplly($moduleName, $schemaPatches, $moduleVersion
477
491
]
478
492
);
479
493
494
+ // phpstan:ignore
480
495
$ patches = [
481
496
\SomeSchemaPatch::class,
497
+ // phpstan:ignore
482
498
\OtherSchemaPatch::class
483
499
];
484
500
$ patchRegistryMock = $ this ->createAggregateIteratorMock (PatchRegistry::class, $ patches , ['registerPatch ' ]);
@@ -489,15 +505,19 @@ public function testSchemaPatchAplly($moduleName, $schemaPatches, $moduleVersion
489
505
->method ('create ' )
490
506
->willReturn ($ patchRegistryMock );
491
507
508
+ // phpstan:ignore "Class SomeSchemaPatch not found."
492
509
$ patch1 = $ this ->createMock (\SomeSchemaPatch::class);
493
510
$ patch1 ->expects ($ this ->never ())->method ('apply ' );
494
511
$ patch1 ->expects ($ this ->any ())->method ('getAliases ' )->willReturn ([]);
512
+ // phpstan:ignore "Class OtherSchemaPatch not found."
495
513
$ patch2 = $ this ->createMock (\OtherSchemaPatch::class);
496
514
$ patch2 ->expects ($ this ->once ())->method ('apply ' );
497
515
$ patch2 ->expects ($ this ->any ())->method ('getAliases ' )->willReturn ([]);
498
516
$ this ->patchFactoryMock ->expects ($ this ->any ())->method ('create ' )->willReturnMap (
499
517
[
518
+ // phpstan:ignore
500
519
[\SomeSchemaPatch::class, ['schemaSetup ' => $ this ->schemaSetupMock ], $ patch1 ],
520
+ // phpstan:ignore
501
521
[\OtherSchemaPatch::class, ['schemaSetup ' => $ this ->schemaSetupMock ], $ patch2 ],
502
522
]
503
523
);
@@ -516,8 +536,6 @@ public function testSchemaPatchAplly($moduleName, $schemaPatches, $moduleVersion
516
536
*/
517
537
public function testSchemaPatchApplyForPatchAlias ($ moduleName , $ schemaPatches , $ moduleVersionInDb )
518
538
{
519
- $ this ->expectException ('Exception ' );
520
- $ this ->expectExceptionMessageMatches ('"Unable to apply patch .+ cannot be applied twice" ' );
521
539
$ this ->schemaPatchReaderMock ->expects ($ this ->once ())
522
540
->method ('read ' )
523
541
->with ($ moduleName )
@@ -542,19 +560,13 @@ public function testSchemaPatchApplyForPatchAlias($moduleName, $schemaPatches, $
542
560
->willReturn ($ patchRegistryMock );
543
561
544
562
$ 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
563
553
564
$ this ->patchApllier ->applySchemaPatch ($ moduleName );
554
565
}
555
566
556
567
public function testRevertDataPatches ()
557
568
{
569
+ // phpstan:ignore "Class RevertableDataPatch not found."
558
570
$ patches = [\RevertableDataPatch::class];
559
571
$ this ->dataPatchReaderMock ->expects ($ this ->once ())
560
572
->method ('read ' )
@@ -602,7 +614,9 @@ public function schemaPatchDataProvider()
602
614
'upgrade module iwth only OtherSchemaPatch ' => [
603
615
'moduleName ' => 'Module1 ' ,
604
616
'schemaPatches ' => [
617
+ // phpstan:ignore
605
618
\SomeSchemaPatch::class,
619
+ // phpstan:ignore
606
620
\OtherSchemaPatch::class
607
621
],
608
622
'moduleVersionInDb ' => '2.0.0 ' ,
0 commit comments