Skip to content

Commit b206bd5

Browse files
author
Oleksandr Karpenko
committed
MAGETWO-49766: HTML head Design Configurations are used in Admin
1 parent f7ce87e commit b206bd5

File tree

1 file changed

+45
-13
lines changed

1 file changed

+45
-13
lines changed

lib/internal/Magento/Framework/View/Test/Unit/Page/ConfigTest.php

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
6969
*/
7070
protected $areaResolverMock;
7171

72+
/**
73+
* @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject
74+
*/
75+
protected $localeMock;
76+
7277
protected function setUp()
7378
{
7479
$this->assetRepo = $this->getMock('Magento\Framework\View\Asset\Repository', [], [], '', false);
@@ -79,8 +84,8 @@ protected function setUp()
7984
$this->asset = $this->getMock('Magento\Framework\View\Asset\File', [], [], '', false);
8085
$this->remoteAsset = $this->getMock('\Magento\Framework\View\Asset\Remote', [], [], '', false);
8186
$this->title = $this->getMock('Magento\Framework\View\Page\Title', [], [], '', false);
82-
$locale = $this->getMockForAbstractClass('Magento\Framework\Locale\ResolverInterface', [], '', false);
83-
$locale->expects($this->any())
87+
$this->localeMock = $this->getMockForAbstractClass('Magento\Framework\Locale\ResolverInterface', [], '', false);
88+
$this->localeMock->expects($this->any())
8489
->method('getLocale')
8590
->willReturn(Resolver::DEFAULT_LOCALE);
8691
$this->model = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))
@@ -91,7 +96,7 @@ protected function setUp()
9196
'pageAssets' => $this->pageAssets,
9297
'scopeConfig' => $this->scopeConfig,
9398
'favicon' => $this->favicon,
94-
'localeResolver' => $locale
99+
'localeResolver' => $this->localeMock
95100
]
96101
);
97102

@@ -491,16 +496,43 @@ public function testGetDefaultFavicon()
491496
$this->model->getDefaultFavicon();
492497
}
493498

494-
public function testGetIncludes()
499+
/**
500+
* @param bool $isAvailable
501+
* @param string $result
502+
* @dataProvider getIncludesDataProvider
503+
*/
504+
public function testGetIncludes($isAvailable, $result)
495505
{
496-
$xml = '
497-
<script type="text/javascript">
498-
Fieldset.addToPrefix(1);
499-
</script>
500-
';
501-
$this->scopeConfig->expects($this->once())->method('getValue')->with('design/head/includes', 'store')->will(
502-
$this->returnValue($xml)
503-
);
504-
$this->assertEquals($xml, $this->model->getIncludes());
506+
$model = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))
507+
->getObject(
508+
'Magento\Framework\View\Page\Config',
509+
[
510+
'assetRepo' => $this->assetRepo,
511+
'pageAssets' => $this->pageAssets,
512+
'scopeConfig' => $this->scopeConfig,
513+
'favicon' => $this->favicon,
514+
'localeResolver' => $this->localeMock,
515+
'isIncludesAvailable' => $isAvailable
516+
]
517+
);
518+
519+
$this->scopeConfig->expects($isAvailable ? $this->once() : $this->never())
520+
->method('getValue')
521+
->with('design/head/includes', 'store')
522+
->willReturn($result);
523+
$this->assertEquals($result, $model->getIncludes());
524+
}
525+
526+
public function getIncludesDataProvider()
527+
{
528+
return [
529+
[
530+
true,
531+
'<script type="text/javascript">
532+
Fieldset.addToPrefix(1);
533+
</script>'
534+
],
535+
[false, null]
536+
];
505537
}
506538
}

0 commit comments

Comments
 (0)