File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed
lib/internal/Magento/Framework/Setup Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -56,9 +56,9 @@ public function __construct(ResourceConnection $resourceConnection)
56
56
* Read and cache data patches from db
57
57
*
58
58
* All patches are store in patch_list table
59
- * @see self::TABLE_NAME
60
59
*
61
- * @return array
60
+ * @see self::TABLE_NAME
61
+ * @return string[]
62
62
*/
63
63
private function getAppliedPatches ()
64
64
{
@@ -87,12 +87,14 @@ public function fixPatch($patchName)
87
87
88
88
$ adapter = $ this ->resourceConnection ->getConnection ();
89
89
$ adapter ->insert ($ this ->resourceConnection ->getTableName (self ::TABLE_NAME ), [self ::CLASS_NAME => $ patchName ]);
90
+
91
+ $ this ->patchesRegistry [] = $ patchName ;
90
92
}
91
93
92
94
/**
93
95
* Revert patch from history
94
96
*
95
- * @param $patchName
97
+ * @param string $patchName
96
98
* @return void
97
99
*/
98
100
public function revertPatchFromHistory ($ patchName )
Original file line number Diff line number Diff line change @@ -83,4 +83,28 @@ public function testFixAppliedPatch()
83
83
$ adapterMock ->expects ($ this ->never ())->method ('insert ' );
84
84
$ this ->patchHistory ->fixPatch (get_class ($ patch1 ));
85
85
}
86
+
87
+ /**
88
+ * @expectedException \LogicException
89
+ * @expectedExceptionMessageRegExp "Patch [a-zA-Z0-9\_]+ cannot be applied twice"
90
+ */
91
+ public function testFixPatchTwice ()
92
+ {
93
+ /** @var PatchInterface|\PHPUnit_Framework_MockObject_MockObject $patch1 */
94
+ $ patch = $ this ->createMock (PatchInterface::class);
95
+ /** @var AdapterInterface|\PHPUnit_Framework_MockObject_MockObject $adapterMock */
96
+ $ adapterMock = $ this ->createMock (AdapterInterface::class);
97
+ $ this ->resourceConnectionMock ->expects ($ this ->any ())->method ('getConnection ' )->willReturn ($ adapterMock );
98
+ $ this ->resourceConnectionMock ->expects ($ this ->any ())
99
+ ->method ('getTableName ' )
100
+ ->willReturn (PatchHistory::TABLE_NAME );
101
+ $ selectMock = $ this ->createMock (\Magento \Framework \DB \Select::class);
102
+ $ selectMock ->expects ($ this ->once ())->method ('from ' );
103
+ $ adapterMock ->expects ($ this ->any ())->method ('select ' )->willReturn ($ selectMock );
104
+ $ adapterMock ->expects ($ this ->once ())->method ('fetchCol ' )->willReturn ([]);
105
+ $ adapterMock ->expects ($ this ->once ())->method ('insert ' );
106
+
107
+ $ this ->patchHistory ->fixPatch (get_class ($ patch ));
108
+ $ this ->patchHistory ->fixPatch (get_class ($ patch ));
109
+ }
86
110
}
You can’t perform that action at this time.
0 commit comments