11
11
use Magento \CloudPatches \Command \Process \Renderer ;
12
12
use Magento \CloudPatches \Command \Process \ShowStatus ;
13
13
use Magento \CloudPatches \Patch \Aggregator ;
14
+ use Magento \CloudPatches \Patch \Data \AggregatedPatch ;
14
15
use Magento \CloudPatches \Patch \Data \AggregatedPatchInterface ;
15
16
use Magento \CloudPatches \Patch \Data \PatchInterface ;
16
17
use Magento \CloudPatches \Patch \Pool \LocalPool ;
@@ -89,17 +90,25 @@ protected function setUp()
89
90
* Patch 1 - deprecated, applied - show warning message, show patch in the table;
90
91
* Patch 2 - not deprecated, not applied - no warning message, show patch in the table;
91
92
* 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;
92
95
*/
93
96
public function testShowStatus ()
94
97
{
95
98
$ patch1 = $ this ->createPatch ('patch1 ' , true );
96
99
$ patch2 = $ this ->createPatch ('patch2 ' , false );
97
100
$ patch3 = $ this ->createPatch ('patch3 ' , true );
101
+ $ patch4 = $ this ->createPatch ('patch4 ' , true , 'patch4-v2 ' );
102
+ $ patch5 = $ this ->createPatch ('patch5 ' , true , 'patch5-v2 ' );
98
103
$ this ->statusPool ->method ('isApplied ' )
99
104
->willReturnMap ([
100
105
['patch1 ' , true ],
101
106
['patch2 ' , false ],
102
107
['patch3 ' , false ],
108
+ ['patch4 ' , true ],
109
+ ['patch4-v2 ' , true ],
110
+ ['patch5 ' , true ],
111
+ ['patch5-v2 ' , false ],
103
112
]);
104
113
105
114
/** @var InputInterface|MockObject $inputMock */
@@ -118,10 +127,10 @@ public function testShowStatus()
118
127
119
128
$ this ->aggregator ->expects ($ this ->once ())
120
129
->method ('aggregate ' )
121
- ->willReturn ([$ patch1 , $ patch2 , $ patch3 ]);
130
+ ->willReturn ([$ patch1 , $ patch2 , $ patch3, $ patch4 , $ patch5 ]);
122
131
123
132
// Show warning message about patch deprecation
124
- $ outputMock ->expects ($ this ->exactly (2 ))
133
+ $ outputMock ->expects ($ this ->exactly (3 ))
125
134
->method ('writeln ' )
126
135
->withConsecutive (
127
136
[$ this ->anything ()],
@@ -131,7 +140,7 @@ public function testShowStatus()
131
140
// Show patches in the table
132
141
$ this ->renderer ->expects ($ this ->once ())
133
142
->method ('printTable ' )
134
- ->withConsecutive ([$ outputMock , [$ patch1 , $ patch2 ]]);
143
+ ->withConsecutive ([$ outputMock , [$ patch1 , $ patch2, $ patch5 ]]);
135
144
136
145
$ this ->manager ->run ($ inputMock , $ outputMock );
137
146
}
@@ -141,14 +150,18 @@ public function testShowStatus()
141
150
*
142
151
* @param string $id
143
152
* @param bool $isDeprecated
144
- *
153
+ * @param string $replacedWith
145
154
* @return AggregatedPatchInterface|MockObject
146
155
*/
147
- private function createPatch (string $ id , bool $ isDeprecated )
156
+ private function createPatch (string $ id , bool $ isDeprecated, string $ replacedWith = '' )
148
157
{
149
- $ patch = $ this ->getMockForAbstractClass (AggregatedPatchInterface ::class);
158
+ $ patch = $ this ->createMock (AggregatedPatch ::class);
150
159
$ patch ->method ('getId ' )->willReturn ($ id );
151
160
$ 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 ();
152
165
153
166
return $ patch ;
154
167
}
0 commit comments