6
6
namespace Magento \CatalogUrlRewrite \Test \Unit \Model \Category \Plugin \Category ;
7
7
8
8
/**
9
- * Unit test for Magento\CatalogUrlRewrite\Model\Category\Plugin\Category\Save class
9
+ * Unit test for Magento\CatalogUrlRewrite\Model\Category\Plugin\Category\UpdateUrlPath class
10
10
*/
11
- class SaveTest extends \PHPUnit \Framework \TestCase
11
+ class UpdateUrlPathTest extends \PHPUnit \Framework \TestCase
12
12
{
13
13
/**
14
14
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
@@ -46,9 +46,9 @@ class SaveTest extends \PHPUnit\Framework\TestCase
46
46
private $ category ;
47
47
48
48
/**
49
- * @var \Magento\CatalogUrlRewrite\Model\Category\Plugin\Category\Save
49
+ * @var \Magento\CatalogUrlRewrite\Model\Category\Plugin\Category\UpdateUrlPath
50
50
*/
51
- private $ categorySavePlugin ;
51
+ private $ updateUrlPathPlugin ;
52
52
53
53
/**
54
54
* @inheritdoc
@@ -96,8 +96,8 @@ protected function setUp()
96
96
->setMethods (['replace ' ])
97
97
->getMockForAbstractClass ();
98
98
99
- $ this ->categorySavePlugin = $ this ->objectManager ->getObject (
100
- \Magento \CatalogUrlRewrite \Model \Category \Plugin \Category \Save ::class,
99
+ $ this ->updateUrlPathPlugin = $ this ->objectManager ->getObject (
100
+ \Magento \CatalogUrlRewrite \Model \Category \Plugin \Category \UpdateUrlPath ::class,
101
101
[
102
102
'categoryUrlPathGenerator ' => $ this ->categoryUrlPathGenerator ,
103
103
'categoryUrlRewriteGenerator ' => $ this ->categoryUrlRewriteGenerator ,
@@ -109,19 +109,14 @@ protected function setUp()
109
109
110
110
public function testAroundSaveWithoutRootCategory ()
111
111
{
112
- $ proceed = function () {
113
- return $ this ->categoryResource ;
114
- };
115
-
116
- $ this ->category ->expects ($ this ->atLeastOnce ())->method ('getStoreId ' )->willReturn (0 );
117
112
$ this ->category ->expects ($ this ->atLeastOnce ())->method ('getParentId ' )->willReturn (0 );
118
113
$ this ->category ->expects ($ this ->atLeastOnce ())->method ('isObjectNew ' )->willReturn (true );
119
114
$ this ->category ->expects ($ this ->atLeastOnce ())->method ('isInRootCategoryList ' )->willReturn (false );
120
115
$ this ->category ->expects ($ this ->never ())->method ('getStoreIds ' );
121
116
122
117
$ this ->assertEquals (
123
118
$ this ->categoryResource ,
124
- $ this ->categorySavePlugin -> aroundSave ($ this ->categoryResource , $ proceed , $ this ->category )
119
+ $ this ->updateUrlPathPlugin -> afterSave ($ this ->categoryResource , $ this -> categoryResource , $ this ->category )
125
120
);
126
121
}
127
122
@@ -130,13 +125,9 @@ public function testAroundSaveWithRootCategory()
130
125
$ parentId = 1 ;
131
126
$ categoryStoreIds = [0 ,1 ,2 ];
132
127
$ generatedUrlPath = 'parent_category/child_category ' ;
133
- $ proceed = function () {
134
- return $ this ->categoryResource ;
135
- };
136
128
137
129
$ this ->categoryUrlPathGenerator ->expects ($ this ->once ())->method ('getUrlPath ' )->with ($ this ->category )
138
130
->willReturn ($ generatedUrlPath );
139
- $ this ->category ->expects ($ this ->atLeastOnce ())->method ('getStoreId ' )->willReturn (0 );
140
131
$ this ->category ->expects ($ this ->atLeastOnce ())->method ('getParentId ' )->willReturn ($ parentId );
141
132
$ this ->category ->expects ($ this ->atLeastOnce ())->method ('isObjectNew ' )->willReturn (true );
142
133
$ this ->category ->expects ($ this ->atLeastOnce ())->method ('isInRootCategoryList ' )->willReturn (false );
@@ -166,7 +157,7 @@ public function testAroundSaveWithRootCategory()
166
157
167
158
$ this ->assertEquals (
168
159
$ this ->categoryResource ,
169
- $ this ->categorySavePlugin -> aroundSave ($ this ->categoryResource , $ proceed , $ this ->category )
160
+ $ this ->updateUrlPathPlugin -> afterSave ($ this ->categoryResource , $ this -> categoryResource , $ this ->category )
170
161
);
171
162
}
172
163
}
0 commit comments