1111use Magento \CloudPatches \Command \Process \Renderer ;
1212use Magento \CloudPatches \Command \Process \ShowStatus ;
1313use Magento \CloudPatches \Patch \Aggregator ;
14+ use Magento \CloudPatches \Patch \Data \AggregatedPatch ;
1415use Magento \CloudPatches \Patch \Data \AggregatedPatchInterface ;
1516use Magento \CloudPatches \Patch \Data \PatchInterface ;
1617use Magento \CloudPatches \Patch \Pool \LocalPool ;
@@ -89,17 +90,25 @@ protected function setUp()
8990 * Patch 1 - deprecated, applied - show warning message, show patch in the table;
9091 * Patch 2 - not deprecated, not applied - no warning message, show patch in the table;
9192 * Patch 3 - deprecated, not applied - no warning message, don't show patch in the table;
93+ * Patch 4 - deprecated, applied and replaced with applied patch4-v2 - don't show patch in the table;
94+ * Patch 5 - deprecated, applied and replaced with not applied patch5-v2 - show patch in the table;
9295 */
9396 public function testShowStatus ()
9497 {
9598 $ patch1 = $ this ->createPatch ('patch1 ' , true );
9699 $ patch2 = $ this ->createPatch ('patch2 ' , false );
97100 $ patch3 = $ this ->createPatch ('patch3 ' , true );
101+ $ patch4 = $ this ->createPatch ('patch4 ' , true , 'patch4-v2 ' );
102+ $ patch5 = $ this ->createPatch ('patch5 ' , true , 'patch5-v2 ' );
98103 $ this ->statusPool ->method ('isApplied ' )
99104 ->willReturnMap ([
100105 ['patch1 ' , true ],
101106 ['patch2 ' , false ],
102107 ['patch3 ' , false ],
108+ ['patch4 ' , true ],
109+ ['patch4-v2 ' , true ],
110+ ['patch5 ' , true ],
111+ ['patch5-v2 ' , false ],
103112 ]);
104113
105114 /** @var InputInterface|MockObject $inputMock */
@@ -118,10 +127,10 @@ public function testShowStatus()
118127
119128 $ this ->aggregator ->expects ($ this ->once ())
120129 ->method ('aggregate ' )
121- ->willReturn ([$ patch1 , $ patch2 , $ patch3 ]);
130+ ->willReturn ([$ patch1 , $ patch2 , $ patch3, $ patch4 , $ patch5 ]);
122131
123132 // Show warning message about patch deprecation
124- $ outputMock ->expects ($ this ->exactly (2 ))
133+ $ outputMock ->expects ($ this ->exactly (3 ))
125134 ->method ('writeln ' )
126135 ->withConsecutive (
127136 [$ this ->anything ()],
@@ -131,7 +140,7 @@ public function testShowStatus()
131140 // Show patches in the table
132141 $ this ->renderer ->expects ($ this ->once ())
133142 ->method ('printTable ' )
134- ->withConsecutive ([$ outputMock , [$ patch1 , $ patch2 ]]);
143+ ->withConsecutive ([$ outputMock , [$ patch1 , $ patch2, $ patch5 ]]);
135144
136145 $ this ->manager ->run ($ inputMock , $ outputMock );
137146 }
@@ -141,14 +150,18 @@ public function testShowStatus()
141150 *
142151 * @param string $id
143152 * @param bool $isDeprecated
144- *
153+ * @param string $replacedWith
145154 * @return AggregatedPatchInterface|MockObject
146155 */
147- private function createPatch (string $ id , bool $ isDeprecated )
156+ private function createPatch (string $ id , bool $ isDeprecated, string $ replacedWith = '' )
148157 {
149- $ patch = $ this ->getMockForAbstractClass (AggregatedPatchInterface ::class);
158+ $ patch = $ this ->createMock (AggregatedPatch ::class);
150159 $ patch ->method ('getId ' )->willReturn ($ id );
151160 $ patch ->method ('isDeprecated ' )->willReturn ($ isDeprecated );
161+ $ patch ->method ('getReplacedWith ' )->willReturn ($ replacedWith );
162+
163+ // To make mock object unique for assertions and array operations.
164+ $ patch ->id = microtime ();
152165
153166 return $ patch ;
154167 }
0 commit comments