7
7
8
8
namespace Magento \CatalogUrlRewrite \Test \Unit \Model ;
9
9
10
+ use Magento \Catalog \Api \CategoryRepositoryInterface ;
10
11
use Magento \Catalog \Model \Category ;
11
12
use Magento \Catalog \Model \Product ;
12
13
use Magento \CatalogUrlRewrite \Model \ObjectRegistry ;
@@ -69,6 +70,9 @@ class ProductScopeRewriteGeneratorTest extends TestCase
69
70
/** @var ScopeConfigInterface|MockObject */
70
71
private $ configMock ;
71
72
73
+ /** @var CategoryRepositoryInterface|MockObject */
74
+ private $ categoryRepository ;
75
+
72
76
protected function setUp (): void
73
77
{
74
78
$ this ->serializer = $ this ->createMock (Json::class);
@@ -126,6 +130,8 @@ function ($value) {
126
130
$ this ->configMock = $ this ->getMockBuilder (ScopeConfigInterface::class)
127
131
->getMock ();
128
132
133
+ $ this ->categoryRepository = $ this ->getMockForAbstractClass (CategoryRepositoryInterface::class);
134
+
129
135
$ this ->productScopeGenerator = (new ObjectManager ($ this ))->getObject (
130
136
ProductScopeRewriteGenerator::class,
131
137
[
@@ -137,7 +143,8 @@ function ($value) {
137
143
'storeViewService ' => $ this ->storeViewService ,
138
144
'storeManager ' => $ this ->storeManager ,
139
145
'mergeDataProviderFactory ' => $ mergeDataProviderFactory ,
140
- 'config ' => $ this ->configMock
146
+ 'config ' => $ this ->configMock ,
147
+ 'categoryRepository ' => $ this ->categoryRepository
141
148
]
142
149
);
143
150
$ this ->categoryMock = $ this ->getMockBuilder (Category::class)
@@ -215,6 +222,8 @@ public function testGenerationForSpecificStore()
215
222
$ this ->anchorUrlRewriteGenerator ->expects ($ this ->any ())->method ('generate ' )
216
223
->willReturn ([]);
217
224
225
+ $ this ->categoryRepository ->expects ($ this ->once ())->method ('get ' )->willReturn ($ this ->categoryMock );
226
+
218
227
$ this ->assertEquals (
219
228
['category-1_1 ' => $ canonical ],
220
229
$ this ->productScopeGenerator ->generateForSpecificStoreView (1 , [$ this ->categoryMock ], $ product , 1 )
0 commit comments