@@ -87,7 +87,7 @@ protected function setUp()
8787 $ this ->objectManager = new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this );
8888
8989 $ this ->contextMock = $ this ->getMock (
90- ' Magento\Backend\App\Action\Context ' ,
90+ \ Magento \Backend \App \Action \Context::class ,
9191 [
9292 'getTitle ' ,
9393 'getRequest ' ,
@@ -102,47 +102,47 @@ protected function setUp()
102102 false
103103 );
104104 $ this ->resultRedirectFactoryMock = $ this ->getMock (
105- ' Magento\Backend\Model\View\Result\RedirectFactory ' ,
105+ \ Magento \Backend \Model \View \Result \RedirectFactory::class ,
106106 ['create ' ],
107107 [],
108108 '' ,
109109 false
110110 );
111111 $ this ->resultRawFactoryMock = $ this ->getMock (
112- ' Magento\Framework\Controller\Result\RawFactory ' ,
112+ \ Magento \Framework \Controller \Result \RawFactory::class ,
113113 [],
114114 [],
115115 '' ,
116116 false
117117 );
118118 $ this ->resultJsonFactoryMock = $ this ->getMock (
119- ' Magento\Framework\Controller\Result\JsonFactory ' ,
119+ \ Magento \Framework \Controller \Result \JsonFactory::class ,
120120 ['create ' ],
121121 [],
122122 '' ,
123123 false
124124 );
125125 $ this ->layoutFactoryMock = $ this ->getMock (
126- ' Magento\Framework\View\LayoutFactory ' ,
126+ \ Magento \Framework \View \LayoutFactory::class ,
127127 ['create ' ],
128128 [],
129129 '' ,
130130 false
131131 );
132132 $ this ->requestMock = $ this ->getMockForAbstractClass (
133- ' Magento\Framework\App\RequestInterface ' ,
133+ \ Magento \Framework \App \RequestInterface::class ,
134134 [],
135135 '' ,
136136 false ,
137137 true ,
138138 true ,
139139 ['getParam ' , 'getPost ' , 'getPostValue ' ]
140140 );
141- $ this ->objectManagerMock = $ this ->getMockBuilder (' Magento\Framework\ObjectManagerInterface ' )
141+ $ this ->objectManagerMock = $ this ->getMockBuilder (\ Magento \Framework \ObjectManagerInterface::class )
142142 ->disableOriginalConstructor ()
143143 ->getMock ();
144144 $ this ->eventManagerMock = $ this ->getMockForAbstractClass (
145- ' Magento\Framework\Event\ManagerInterface ' ,
145+ \ Magento \Framework \Event \ManagerInterface::class ,
146146 [],
147147 '' ,
148148 false ,
@@ -151,13 +151,13 @@ protected function setUp()
151151 ['dispatch ' ]
152152 );
153153 $ this ->responseMock = $ this ->getMockForAbstractClass (
154- ' Magento\Framework\App\ResponseInterface ' ,
154+ \ Magento \Framework \App \ResponseInterface::class ,
155155 [],
156156 '' ,
157157 false
158158 );
159159 $ this ->messageManagerMock = $ this ->getMockForAbstractClass (
160- ' Magento\Framework\Message\ManagerInterface ' ,
160+ \ Magento \Framework \Message \ManagerInterface::class ,
161161 [],
162162 '' ,
163163 false ,
@@ -177,7 +177,7 @@ protected function setUp()
177177 ->willReturn ($ this ->resultRedirectFactoryMock );
178178
179179 $ this ->save = $ this ->objectManager ->getObject (
180- ' Magento\Catalog\Controller\Adminhtml\Category\Save ' ,
180+ \ Magento \Catalog \Controller \Adminhtml \Category \Save::class ,
181181 [
182182 'context ' => $ this ->contextMock ,
183183 'resultRawFactory ' => $ this ->resultRawFactoryMock ,
@@ -212,7 +212,7 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
212212 * |\PHPUnit_Framework_MockObject_MockObject $resultRedirectMock
213213 */
214214 $ resultRedirectMock = $ this ->getMock (
215- ' Magento\Backend\Model\View\Result\Redirect ' ,
215+ \ Magento \Backend \Model \View \Result \Redirect::class ,
216216 [],
217217 [],
218218 '' ,
@@ -223,7 +223,7 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
223223 * |\PHPUnit_Framework_MockObject_MockObject $blockMock
224224 */
225225 $ blockMock = $ this ->getMock (
226- ' Magento\Framework\View\Element\Messages ' ,
226+ \ Magento \Framework \View \Element \Messages::class ,
227227 ['setMessages ' , 'getGroupedHtml ' ],
228228 [],
229229 '' ,
@@ -234,7 +234,7 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
234234 * |\PHPUnit_Framework_MockObject_MockObject $categoryMock
235235 */
236236 $ categoryMock = $ this ->getMock (
237- ' Magento\Catalog\Model\Category ' ,
237+ \ Magento \Catalog \Model \Category::class ,
238238 [
239239 'setStoreId ' ,
240240 'load ' ,
@@ -263,7 +263,7 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
263263 * |\PHPUnit_Framework_MockObject_MockObject $parentCategoryMock
264264 */
265265 $ parentCategoryMock = $ this ->getMock (
266- ' Magento\Catalog\Model\Category ' ,
266+ \ Magento \Catalog \Model \Category::class ,
267267 [
268268 'setStoreId ' ,
269269 'load ' ,
@@ -287,7 +287,7 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
287287 * |\PHPUnit_Framework_MockObject_MockObject $sessionMock
288288 */
289289 $ sessionMock = $ this ->getMock (
290- ' Magento\Backend\Model\Auth\Session ' ,
290+ \ Magento \Backend \Model \Auth \Session::class ,
291291 ['setActiveTabId ' ],
292292 [],
293293 '' ,
@@ -298,7 +298,7 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
298298 * |\PHPUnit_Framework_MockObject_MockObject $registryMock
299299 */
300300 $ registryMock = $ this ->getMock (
301- ' Magento\Framework\Registry ' ,
301+ \ Magento \Framework \Registry::class ,
302302 ['register ' ],
303303 [],
304304 '' ,
@@ -309,7 +309,7 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
309309 * |\PHPUnit_Framework_MockObject_MockObject $wysiwygConfigMock
310310 */
311311 $ wysiwygConfigMock = $ this ->getMock (
312- ' Magento\Cms\Model\Wysiwyg\Config ' ,
312+ \ Magento \Cms \Model \Wysiwyg \Config::class ,
313313 ['setStoreId ' ],
314314 [],
315315 '' ,
@@ -320,20 +320,20 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
320320 * |\PHPUnit_Framework_MockObject_MockObject $storeManagerMock
321321 */
322322 $ storeManagerMock = $ this ->getMockForAbstractClass (
323- ' Magento\Store\Model\StoreManagerInterface ' ,
323+ \ Magento \Store \Model \StoreManagerInterface::class ,
324324 [],
325325 '' ,
326326 false ,
327327 true ,
328328 true ,
329- ['getStore ' , 'getRootCategoryId ' ]
329+ ['getStore ' , 'getRootCategoryId ' , ' setCurrentStore ' ]
330330 );
331331 /**
332332 * @var \Magento\Framework\View\Layout
333333 * |\PHPUnit_Framework_MockObject_MockObject $layoutMock
334334 */
335335 $ layoutMock = $ this ->getMockForAbstractClass (
336- ' Magento\Framework\View\Layout ' ,
336+ \ Magento \Framework \View \Layout::class ,
337337 [],
338338 '' ,
339339 false ,
@@ -346,7 +346,7 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
346346 * |\PHPUnit_Framework_MockObject_MockObject $resultJsonMock
347347 */
348348 $ resultJsonMock = $ this ->getMock (
349- ' Magento\Cms\Model\Wysiwyg\Config ' ,
349+ \ Magento \Cms \Model \Wysiwyg \Config::class ,
350350 ['setData ' ],
351351 [],
352352 '' ,
@@ -357,13 +357,26 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
357357 * |\PHPUnit_Framework_MockObject_MockObject $messagesMock
358358 */
359359 $ messagesMock = $ this ->getMock (
360- ' Magento\Framework\Message\Collection ' ,
360+ \ Magento \Framework \Message \Collection::class ,
361361 [],
362362 [],
363363 '' ,
364364 false
365365 );
366366
367+ /**
368+ * @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject $storeMock
369+ */
370+ $ storeMock = $ this ->getMock (
371+ \Magento \Store \Model \Store::class,
372+ [
373+ 'getCode ' ,
374+ ],
375+ [],
376+ '' ,
377+ false
378+ );
379+
367380 $ this ->resultRedirectFactoryMock ->expects ($ this ->once ())
368381 ->method ('create ' )
369382 ->will ($ this ->returnValue ($ resultRedirectMock ));
@@ -379,6 +392,15 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
379392 ]
380393 )
381394 );
395+
396+ $ storeMock ->expects ($ this ->once ())
397+ ->method ('getCode ' )
398+ ->will ($ this ->returnValue ('admin ' ));
399+
400+ $ storeManagerMock ->expects ($ this ->once ())
401+ ->method ('setCurrentStore ' )
402+ ->with ('admin ' );
403+
382404 $ this ->objectManagerMock ->expects ($ this ->atLeastOnce ())
383405 ->method ('create ' )
384406 ->will ($ this ->returnValue ($ categoryMock ));
@@ -387,10 +409,10 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
387409 ->will (
388410 $ this ->returnValueMap (
389411 [
390- [' Magento\Backend\Model\Auth\Session ' , $ sessionMock ],
391- [' Magento\Framework\Registry ' , $ registryMock ],
392- [' Magento\Cms\Model\Wysiwyg\Config ' , $ wysiwygConfigMock ],
393- [' Magento\Store\Model\StoreManagerInterface ' , $ storeManagerMock ],
412+ [\ Magento \Backend \Model \Auth \Session::class , $ sessionMock ],
413+ [\ Magento \Framework \Registry::class , $ registryMock ],
414+ [\ Magento \Cms \Model \Wysiwyg \Config::class , $ wysiwygConfigMock ],
415+ [\ Magento \Store \Model \StoreManagerInterface::class , $ storeManagerMock ],
394416 ]
395417 )
396418 );
@@ -441,15 +463,23 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
441463
442464 if (!$ parentId ) {
443465 if ($ storeId ) {
444- $ storeManagerMock ->expects ($ this ->once ( ))
466+ $ storeManagerMock ->expects ($ this ->exactly ( 2 ))
445467 ->method ('getStore ' )
446468 ->with ($ storeId )
447- ->will ($ this ->returnSelf ());
469+ ->willReturnOnConsecutiveCalls (
470+ $ storeMock ,
471+ $ this ->returnSelf ()
472+ );
448473 $ storeManagerMock ->expects ($ this ->once ())
449474 ->method ('getRootCategoryId ' )
450475 ->will ($ this ->returnValue ($ rootCategoryId ));
451476 $ parentId = $ rootCategoryId ;
452477 }
478+ } else {
479+ $ storeManagerMock ->expects ($ this ->once ())
480+ ->method ('getStore ' )
481+ ->with ($ storeId )
482+ ->will ($ this ->returnValue ($ storeMock ));
453483 }
454484 $ categoryMock ->expects ($ this ->any ())
455485 ->method ('load ' )
@@ -494,7 +524,7 @@ public function testExecute($categoryId, $storeId, $activeTabId, $parentId)
494524 );
495525
496526 $ categoryResource = $ this ->getMock (
497- ' Magento\Catalog\Model\ResourceModel\Category ' ,
527+ \ Magento \Catalog \Model \ResourceModel \Category::class ,
498528 [],
499529 [],
500530 '' ,
0 commit comments