Skip to content

Commit f36a620

Browse files
committed
MAGETWO-81926: Category hierarchy isn't updated on Product Admin page
1 parent c782adb commit f36a620

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/RefreshPathTest.php

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88

99
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Category;
1010

11-
use \Magento\Framework\Controller\Result\JsonFactory;
12-
use \Magento\Catalog\Controller\Adminhtml\Category\RefreshPath;
13-
use \Magento\Backend\App\Action\Context;
11+
use Magento\Framework\Controller\Result\JsonFactory;
12+
use Magento\Catalog\Controller\Adminhtml\Category\RefreshPath;
13+
use Magento\Backend\App\Action\Context;
1414
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1515

16+
/**
17+
* Test for class RefreshPath.
18+
*/
1619
class RefreshPathTest extends \PHPUnit\Framework\TestCase
1720
{
1821
/**
@@ -109,4 +112,36 @@ public function testExecute()
109112

110113
$this->assertEquals($result, $refreshPath->execute());
111114
}
115+
116+
/**
117+
* @return void
118+
*/
119+
public function testExecuteWithoutCategoryId()
120+
{
121+
$requestMock = $this->getMockForAbstractClass(\Magento\Framework\App\RequestInterface::class);
122+
123+
$refreshPath = $this->getMockBuilder(RefreshPath::class)
124+
->setMethods(['getRequest', 'create'])
125+
->setConstructorArgs([
126+
$this->contextMock,
127+
$this->resultJsonFactoryMock,
128+
])->getMock();
129+
130+
$refreshPath->expects($this->any())->method('getRequest')->willReturn($requestMock);
131+
$requestMock->expects($this->any())->method('getParam')->with('id')->willReturn(null);
132+
133+
$objectManagerMock = $this->getMockBuilder(ObjectManager::class)
134+
->disableOriginalConstructor()
135+
->setMethods(['create'])
136+
->getMock();
137+
138+
$this->setObjectProperty($refreshPath, '_objectManager', $objectManagerMock);
139+
140+
$objectManagerMock->expects($this->never())
141+
->method('create')
142+
->with(\Magento\Catalog\Model\Category::class)
143+
->willReturnSelf();
144+
145+
$refreshPath->execute();
146+
}
112147
}

0 commit comments

Comments
 (0)