Skip to content

Commit 8941d4f

Browse files
committed
#28081 Add missing stub data required by Repository
1 parent ed7efb9 commit 8941d4f

File tree

1 file changed

+48
-25
lines changed

1 file changed

+48
-25
lines changed

lib/internal/Magento/Framework/View/Test/Unit/Asset/RepositoryTest.php

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ class RepositoryTest extends TestCase
8787
*/
8888
private $remoteFactoryMock;
8989

90+
/** @var ThemeInterface|MockObject */
91+
private $themeMock;
92+
9093
/**
9194
* {@inheritDoc}
9295
*/
@@ -137,17 +140,31 @@ protected function setUp(): void
137140
->willReturn($repositoryMapMock);
138141
\Magento\Framework\App\ObjectManager::setInstance($this->objectManagerMock);
139142

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+
);
151168
}
152169

153170
/**
@@ -188,7 +205,7 @@ public function testUpdateDesignParams($params, $result)
188205
public function testUpdateDesignParamsWithThemePath()
189206
{
190207
$params = ['area' => 'AREA'];
191-
$result = ['area' => 'AREA', 'themeModel' => 'Theme', 'module' => false, 'locale' => null];
208+
$result = ['area' => 'AREA', 'themeModel' => 'Theme', 'module' => false, 'locale' => 'locale'];
192209

193210
$this->designMock
194211
->expects($this->once())
@@ -210,7 +227,7 @@ public function testUpdateDesignParamsWithThemePath()
210227
public function testUpdateDesignParamsWithThemeId()
211228
{
212229
$params = ['area' => 'AREA'];
213-
$result = ['area' => 'AREA', 'themeModel' => 'Theme', 'module' => false, 'locale' => null];
230+
$result = ['area' => 'AREA', 'themeModel' => 'Theme', 'module' => false, 'locale' => 'locale'];
214231

215232
$this->designMock
216233
->expects($this->once())
@@ -234,10 +251,10 @@ public function updateDesignParamsDataProvider()
234251
return [
235252
[
236253
['area' => 'AREA'],
237-
['area' => 'AREA', 'themeModel' => '', 'module' => '', 'locale' => '']],
254+
['area' => 'AREA', 'themeModel' => $this->getThemeMock(), 'module' => false, 'locale' => 'locale']],
238255
[
239256
['themeId' => 'ThemeID'],
240-
['area' => '', 'themeId' => 'ThemeID', 'themeModel' => 'ThemeID', 'module' => '', 'locale' => '']
257+
['area' => 'area', 'themeId' => 'ThemeID', 'themeModel' => 'ThemeID', 'module' => false, 'locale' => 'locale']
241258
]
242259
];
243260
}
@@ -247,6 +264,7 @@ public function updateDesignParamsDataProvider()
247264
*/
248265
public function testCreateAsset()
249266
{
267+
250268
$this->themeProvider
251269
->expects($this->any())
252270
->method('getThemeByFullPath')
@@ -260,10 +278,10 @@ public function testCreateAsset()
260278
->method('create')
261279
->with(
262280
[
263-
'baseUrl' => '',
264-
'areaType' => '',
281+
'baseUrl' => null,
282+
'areaType' => 'area',
265283
'themePath' => 'Default',
266-
'localeCode' => ''
284+
'localeCode' => 'locale'
267285
]
268286
)
269287
->willReturn($fallbackContextMock);
@@ -441,13 +459,6 @@ public function testCreateArbitrary()
441459
);
442460
}
443461

444-
/**
445-
* @return void
446-
*/
447-
public function testCreateRemoteAsset()
448-
{
449-
}
450-
451462
/**
452463
* @return void
453464
*/
@@ -506,4 +517,16 @@ public function testExtractModuleException()
506517
$this->expectExceptionMessage('Scope separator "::" cannot be used without scope identifier.');
507518
$this->repository->extractModule('::asdsad');
508519
}
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+
}
509532
}

0 commit comments

Comments
 (0)