Skip to content

Commit dd87207

Browse files
committed
ACP2E-49: Incorrect Behavior from Data Patch Aliases
- Fixed the static test failure.
2 parents 83e95d1 + f1ec17c commit dd87207

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

lib/internal/Magento/Framework/Setup/Test/Unit/Patch/PatchApplierTest.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ public function testApplyDataPatchForNewlyInstalledModule($moduleName, $dataPatc
162162
// phpstan:ignore
163163
$patches = [
164164
\SomeDataPatch::class,
165+
// phpstan:ignore
165166
\OtherDataPatch::class
166167
];
167168
$patchRegistryMock = $this->createAggregateIteratorMock(PatchRegistry::class, $patches, ['registerPatch']);
@@ -180,10 +181,11 @@ public function testApplyDataPatchForNewlyInstalledModule($moduleName, $dataPatc
180181
$patch2->expects($this->once())->method('apply');
181182
$patch2->expects($this->once())->method('getAliases')->willReturn([]);
182183

183-
// phpstan:ignore
184184
$this->objectManagerMock->expects($this->any())->method('create')->willReturnMap(
185185
[
186+
// phpstan:ignore
186187
['\\' . \SomeDataPatch::class, ['moduleDataSetup' => $this->moduleDataSetupMock], $patch1],
188+
// phpstan:ignore
187189
['\\' . \OtherDataPatch::class, ['moduleDataSetup' => $this->moduleDataSetupMock], $patch2],
188190
]
189191
);
@@ -243,12 +245,13 @@ public function testApplyDataPatchForAlias($moduleName, $dataPatches, $moduleVer
243245
*/
244246
public function applyDataPatchDataNewModuleProvider()
245247
{
246-
// phpstan:ignore
247248
return [
248249
'newly installed module' => [
249250
'moduleName' => 'Module1',
250251
'dataPatches' => [
252+
// phpstan:ignore
251253
\SomeDataPatch::class,
254+
// phpstan:ignore
252255
\OtherDataPatch::class
253256
],
254257
'moduleVersionInDb' => null,
@@ -279,6 +282,7 @@ public function testApplyDataPatchForInstalledModule($moduleName, $dataPatches,
279282
// phpstan:ignore
280283
$patches = [
281284
\SomeDataPatch::class,
285+
// phpstan:ignore
282286
\OtherDataPatch::class
283287
];
284288
$patchRegistryMock = $this->createAggregateIteratorMock(
@@ -302,10 +306,11 @@ public function testApplyDataPatchForInstalledModule($moduleName, $dataPatches,
302306
$patch2->expects(self::once())->method('apply');
303307
$patch2->expects(self::any())->method('getAliases')->willReturn([]);
304308

305-
// phpstan:ignore
306309
$this->objectManagerMock->expects(self::any())->method('create')->willReturnMap(
307310
[
311+
// phpstan:ignore
308312
['\\' . \SomeDataPatch::class, ['moduleDataSetup' => $this->moduleDataSetupMock], $patch1],
313+
// phpstan:ignore
309314
['\\' . \OtherDataPatch::class, ['moduleDataSetup' => $this->moduleDataSetupMock], $patch2],
310315
]
311316
);
@@ -320,12 +325,13 @@ public function testApplyDataPatchForInstalledModule($moduleName, $dataPatches,
320325
*/
321326
public function applyDataPatchDataInstalledModuleProvider()
322327
{
323-
// phpstan:ignore
324328
return [
325329
'upgrade module iwth only OtherDataPatch' => [
326330
'moduleName' => 'Module1',
327331
'dataPatches' => [
332+
// phpstan:ignore
328333
\SomeDataPatch::class,
334+
// phpstan:ignore
329335
\OtherDataPatch::class
330336
],
331337
'moduleVersionInDb' => '2.0.0',
@@ -359,6 +365,7 @@ public function testApplyDataPatchRollback($moduleName, $dataPatches, $moduleVer
359365
// phpstan:ignore
360366
$patches = [
361367
\SomeDataPatch::class,
368+
// phpstan:ignore
362369
\OtherDataPatch::class
363370
];
364371
$patchRegistryMock = $this->createAggregateIteratorMock(PatchRegistry::class, $patches, ['registerPatch']);
@@ -376,10 +383,12 @@ public function testApplyDataPatchRollback($moduleName, $dataPatches, $moduleVer
376383
$patch2 = $this->createMock(\OtherDataPatch::class);
377384
$exception = new \Exception('Patch Apply Error');
378385
$patch2->expects($this->once())->method('apply')->willThrowException($exception);
379-
// phpstan:ignore
386+
380387
$this->objectManagerMock->expects($this->any())->method('create')->willReturnMap(
381388
[
389+
// phpstan:ignore
382390
['\\' . \SomeDataPatch::class, ['moduleDataSetup' => $this->moduleDataSetupMock], $patch1],
391+
// phpstan:ignore
383392
['\\' . \OtherDataPatch::class, ['moduleDataSetup' => $this->moduleDataSetupMock], $patch2],
384393
]
385394
);
@@ -485,6 +494,7 @@ public function testSchemaPatchAplly($moduleName, $schemaPatches, $moduleVersion
485494
// phpstan:ignore
486495
$patches = [
487496
\SomeSchemaPatch::class,
497+
// phpstan:ignore
488498
\OtherSchemaPatch::class
489499
];
490500
$patchRegistryMock = $this->createAggregateIteratorMock(PatchRegistry::class, $patches, ['registerPatch']);
@@ -503,10 +513,11 @@ public function testSchemaPatchAplly($moduleName, $schemaPatches, $moduleVersion
503513
$patch2 = $this->createMock(\OtherSchemaPatch::class);
504514
$patch2->expects($this->once())->method('apply');
505515
$patch2->expects($this->any())->method('getAliases')->willReturn([]);
506-
// phpstan:ignore
507516
$this->patchFactoryMock->expects($this->any())->method('create')->willReturnMap(
508517
[
518+
// phpstan:ignore
509519
[\SomeSchemaPatch::class, ['schemaSetup' => $this->schemaSetupMock], $patch1],
520+
// phpstan:ignore
510521
[\OtherSchemaPatch::class, ['schemaSetup' => $this->schemaSetupMock], $patch2],
511522
]
512523
);
@@ -599,12 +610,13 @@ public function testRevertDataPatches()
599610
*/
600611
public function schemaPatchDataProvider()
601612
{
602-
// phpstan:ignore
603613
return [
604614
'upgrade module iwth only OtherSchemaPatch' => [
605615
'moduleName' => 'Module1',
606616
'schemaPatches' => [
617+
// phpstan:ignore
607618
\SomeSchemaPatch::class,
619+
// phpstan:ignore
608620
\OtherSchemaPatch::class
609621
],
610622
'moduleVersionInDb' => '2.0.0',

0 commit comments

Comments
 (0)