@@ -87,6 +87,9 @@ class RepositoryTest extends TestCase
87
87
*/
88
88
private $ remoteFactoryMock ;
89
89
90
+ /** @var ThemeInterface|MockObject */
91
+ private $ themeMock ;
92
+
90
93
/**
91
94
* {@inheritDoc}
92
95
*/
@@ -137,17 +140,31 @@ protected function setUp(): void
137
140
->willReturn ($ repositoryMapMock );
138
141
\Magento \Framework \App \ObjectManager::setInstance ($ this ->objectManagerMock );
139
142
140
- $ this ->repository = (new ObjectManager ($ this ))->getObject (Repository::class, [
141
- 'baseUrl ' => $ this ->urlMock ,
142
- 'design ' => $ this ->designMock ,
143
- 'themeProvider ' => $ this ->themeProvider ,
144
- 'assetSource ' => $ this ->sourceMock ,
145
- 'request ' => $ this ->httpMock ,
146
- 'fileFactory ' => $ this ->fileFactoryMock ,
147
- 'fallbackContextFactory ' => $ this ->fallbackFactoryMock ,
148
- 'contextFactory ' => $ this ->contextFactoryMock ,
149
- 'remoteFactory ' => $ this ->remoteFactoryMock
150
- ]);
143
+ $ this ->designMock
144
+ ->expects ($ this ->any ())
145
+ ->method ('getDesignParams ' )
146
+ ->willReturn (
147
+ [
148
+ 'themeModel ' => $ this ->getThemeMock (),
149
+ 'area ' => 'area ' ,
150
+ 'locale ' => 'locale '
151
+ ]
152
+ );
153
+
154
+ $ this ->repository = (new ObjectManager ($ this ))->getObject (
155
+ Repository::class,
156
+ [
157
+ 'baseUrl ' => $ this ->urlMock ,
158
+ 'design ' => $ this ->designMock ,
159
+ 'themeProvider ' => $ this ->themeProvider ,
160
+ 'assetSource ' => $ this ->sourceMock ,
161
+ 'request ' => $ this ->httpMock ,
162
+ 'fileFactory ' => $ this ->fileFactoryMock ,
163
+ 'fallbackContextFactory ' => $ this ->fallbackFactoryMock ,
164
+ 'contextFactory ' => $ this ->contextFactoryMock ,
165
+ 'remoteFactory ' => $ this ->remoteFactoryMock
166
+ ]
167
+ );
151
168
}
152
169
153
170
/**
@@ -188,7 +205,7 @@ public function testUpdateDesignParams($params, $result)
188
205
public function testUpdateDesignParamsWithThemePath ()
189
206
{
190
207
$ params = ['area ' => 'AREA ' ];
191
- $ result = ['area ' => 'AREA ' , 'themeModel ' => 'Theme ' , 'module ' => false , 'locale ' => null ];
208
+ $ result = ['area ' => 'AREA ' , 'themeModel ' => 'Theme ' , 'module ' => false , 'locale ' => ' locale ' ];
192
209
193
210
$ this ->designMock
194
211
->expects ($ this ->once ())
@@ -210,7 +227,7 @@ public function testUpdateDesignParamsWithThemePath()
210
227
public function testUpdateDesignParamsWithThemeId ()
211
228
{
212
229
$ params = ['area ' => 'AREA ' ];
213
- $ result = ['area ' => 'AREA ' , 'themeModel ' => 'Theme ' , 'module ' => false , 'locale ' => null ];
230
+ $ result = ['area ' => 'AREA ' , 'themeModel ' => 'Theme ' , 'module ' => false , 'locale ' => ' locale ' ];
214
231
215
232
$ this ->designMock
216
233
->expects ($ this ->once ())
@@ -234,10 +251,10 @@ public function updateDesignParamsDataProvider()
234
251
return [
235
252
[
236
253
['area ' => 'AREA ' ],
237
- ['area ' => 'AREA ' , 'themeModel ' => '' , 'module ' => '' , 'locale ' => '' ]],
254
+ ['area ' => 'AREA ' , 'themeModel ' => $ this -> getThemeMock () , 'module ' => false , 'locale ' => 'locale ' ]],
238
255
[
239
256
['themeId ' => 'ThemeID ' ],
240
- ['area ' => '' , 'themeId ' => 'ThemeID ' , 'themeModel ' => 'ThemeID ' , 'module ' => '' , 'locale ' => '' ]
257
+ ['area ' => 'area ' , 'themeId ' => 'ThemeID ' , 'themeModel ' => 'ThemeID ' , 'module ' => false , 'locale ' => 'locale ' ]
241
258
]
242
259
];
243
260
}
@@ -247,6 +264,7 @@ public function updateDesignParamsDataProvider()
247
264
*/
248
265
public function testCreateAsset ()
249
266
{
267
+
250
268
$ this ->themeProvider
251
269
->expects ($ this ->any ())
252
270
->method ('getThemeByFullPath ' )
@@ -260,10 +278,10 @@ public function testCreateAsset()
260
278
->method ('create ' )
261
279
->with (
262
280
[
263
- 'baseUrl ' => '' ,
264
- 'areaType ' => '' ,
281
+ 'baseUrl ' => null ,
282
+ 'areaType ' => 'area ' ,
265
283
'themePath ' => 'Default ' ,
266
- 'localeCode ' => ''
284
+ 'localeCode ' => 'locale '
267
285
]
268
286
)
269
287
->willReturn ($ fallbackContextMock );
@@ -441,13 +459,6 @@ public function testCreateArbitrary()
441
459
);
442
460
}
443
461
444
- /**
445
- * @return void
446
- */
447
- public function testCreateRemoteAsset ()
448
- {
449
- }
450
-
451
462
/**
452
463
* @return void
453
464
*/
@@ -506,4 +517,16 @@ public function testExtractModuleException()
506
517
$ this ->expectExceptionMessage ('Scope separator "::" cannot be used without scope identifier. ' );
507
518
$ this ->repository ->extractModule ('::asdsad ' );
508
519
}
520
+
521
+ /**
522
+ * @return ThemeInterface|MockObject
523
+ */
524
+ private function getThemeMock ()
525
+ {
526
+ if (null === $ this ->themeMock ) {
527
+ $ this ->themeMock = $ this ->createMock (ThemeInterface::class);
528
+ }
529
+
530
+ return $ this ->themeMock ;
531
+ }
509
532
}
0 commit comments