@@ -80,6 +80,11 @@ class MassInvalidateTest extends \PHPUnit\Framework\TestCase
80
80
*/
81
81
protected $ session ;
82
82
83
+ /**
84
+ * @var \Magento\Framework\Controller\Result\Redirect
85
+ */
86
+ protected $ resultRedirect ;
87
+
83
88
/**
84
89
* Set up test
85
90
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
@@ -100,7 +105,8 @@ protected function setUp()
100
105
'getRequest ' ,
101
106
'getResponse ' ,
102
107
'getObjectManager ' ,
103
- 'getMessageManager '
108
+ 'getMessageManager ' ,
109
+ 'getResultRedirectFactory ' ,
104
110
]);
105
111
106
112
$ this ->response = $ this ->createPartialMock (
@@ -140,6 +146,19 @@ protected function setUp()
140
146
false
141
147
);
142
148
149
+ $ resultRedirectFactory = $ this ->createPartialMock (
150
+ \Magento \Backend \Model \View \Result \RedirectFactory::class,
151
+ ['create ' ]
152
+ );
153
+ $ this ->resultRedirect = $ this ->createPartialMock (
154
+ \Magento \Framework \Controller \Result \Redirect::class,
155
+ ['setPath ' ]
156
+ );
157
+ $ this ->contextMock ->expects ($ this ->any ())->method ('getResultRedirectFactory ' )
158
+ ->willReturn ($ resultRedirectFactory );
159
+ $ resultRedirectFactory ->expects ($ this ->any ())->method ('create ' )
160
+ ->willReturn ($ this ->resultRedirect );
161
+
143
162
$ this ->response ->expects ($ this ->any ())->method ("setRedirect " )->willReturn (1 );
144
163
$ this ->page = $ this ->createMock (\Magento \Framework \View \Result \Page::class);
145
164
$ this ->config = $ this ->createMock (\Magento \Framework \View \Result \Page::class);
@@ -172,7 +191,10 @@ protected function setUp()
172
191
*/
173
192
public function testExecute ($ indexerIds , $ exception )
174
193
{
175
- $ this ->controller = new \Magento \Indexer \Controller \Adminhtml \Indexer \MassInvalidate ($ this ->contextMock , $ this ->indexReg );
194
+ $ this ->controller = new \Magento \Indexer \Controller \Adminhtml \Indexer \MassInvalidate (
195
+ $ this ->contextMock ,
196
+ $ this ->indexReg
197
+ );
176
198
$ this ->request ->expects ($ this ->any ())
177
199
->method ('getParam ' )->with ('indexer_ids ' )
178
200
->will ($ this ->returnValue ($ indexerIds ));
@@ -222,9 +244,9 @@ public function testExecute($indexerIds, $exception)
222
244
223
245
$ this ->helper ->expects ($ this ->any ())->method ("getUrl " )->willReturn ("magento.com " );
224
246
$ this ->response ->expects ($ this ->any ())->method ("setRedirect " )->willReturn (1 );
247
+ $ this ->resultRedirect ->expects ($ this ->once ())->method ('setPath ' )->with ('*/*/list ' );
225
248
226
- $ result = $ this ->controller ->execute ();
227
- $ this ->assertNull ($ result );
249
+ $ this ->controller ->execute ();
228
250
}
229
251
230
252
/**
0 commit comments