|
8 | 8 |
|
9 | 9 | namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Category;
|
10 | 10 |
|
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; |
14 | 14 | use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
15 | 15 |
|
| 16 | +/** |
| 17 | + * Test for class RefreshPath. |
| 18 | + */ |
16 | 19 | class RefreshPathTest extends \PHPUnit\Framework\TestCase
|
17 | 20 | {
|
18 | 21 | /**
|
@@ -109,4 +112,36 @@ public function testExecute()
|
109 | 112 |
|
110 | 113 | $this->assertEquals($result, $refreshPath->execute());
|
111 | 114 | }
|
| 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 | + } |
112 | 147 | }
|
0 commit comments