Skip to content

Commit 03066dd

Browse files
author
Oleksandr Iegorov
committed
MAGETWO-61549: Use default URL Key
1 parent db655a4 commit 03066dd

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryUrlPathAutogeneratorObserverTest.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,16 @@ protected function setUp()
5252
);
5353
$this->category = $this->getMock(
5454
\Magento\Catalog\Model\Category::class,
55-
['setUrlKey', 'setUrlPath', 'dataHasChangedFor', 'isObjectNew', 'getResource', 'getUrlKey', 'getStoreId'],
55+
[
56+
'setUrlKey',
57+
'setUrlPath',
58+
'dataHasChangedFor',
59+
'isObjectNew',
60+
'getResource',
61+
'getUrlKey',
62+
'getStoreId',
63+
'getData'
64+
],
5665
[],
5766
'',
5867
false
@@ -109,6 +118,26 @@ public function testExecuteWithoutUrlKeyAndUrlPathUpdating()
109118
$this->categoryUrlPathAutogeneratorObserver->execute($this->observer);
110119
}
111120

121+
/**
122+
* @expectedException \Magento\Framework\Exception\LocalizedException
123+
* @expectedExceptionMessage Invalid URL key
124+
*/
125+
public function testExecuteWithException()
126+
{
127+
$categoryName = 'test';
128+
$categoryData = ['url_key' => 0];
129+
$this->category->expects($this->once())->method('getUrlKey')->willReturn($categoryName);
130+
$this->category->expects($this->once())
131+
->method('getData')
132+
->with('use_default')
133+
->willReturn($categoryData);
134+
$this->categoryUrlPathGenerator->expects($this->once())
135+
->method('getUrlKey')
136+
->with($this->category)
137+
->willReturn(null);
138+
$this->categoryUrlPathAutogeneratorObserver->execute($this->observer);
139+
}
140+
112141
public function testUrlKeyAndUrlPathUpdating()
113142
{
114143
$this->categoryUrlPathGenerator->expects($this->once())->method('getUrlKey')->with($this->category)

0 commit comments

Comments
 (0)