Skip to content

Commit 60719a8

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-49766' into BUGS
2 parents 6047576 + b206bd5 commit 60719a8

File tree

3 files changed

+60
-15
lines changed

3 files changed

+60
-15
lines changed

app/code/Magento/Backend/etc/adminhtml/di.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,9 @@
133133
</arguments>
134134
</type>
135135
<preference for="Magento\Framework\App\Router\PathConfigInterface" type="Magento\Backend\Model\AdminPathConfig" />
136+
<type name="Magento\Framework\View\Page\Config">
137+
<arguments>
138+
<argument name="isIncludesAvailable" xsi:type="boolean">false</argument>
139+
</arguments>
140+
</type>
136141
</config>

lib/internal/Magento/Framework/View/Page/Config.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ class Config
122122
*/
123123
private $areaResolver;
124124

125+
/**
126+
* @var bool
127+
*/
128+
private $isIncludesAvailable;
129+
125130
/**
126131
* This getter serves as a workaround to add this dependency to this class without breaking constructor structure.
127132
*
@@ -145,21 +150,24 @@ private function getAreaResolver()
145150
* @param \Magento\Framework\View\Page\FaviconInterface $favicon
146151
* @param Title $title
147152
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver
153+
* @param bool $isIncludesAvailable
148154
*/
149155
public function __construct(
150156
View\Asset\Repository $assetRepo,
151157
View\Asset\GroupedCollection $pageAssets,
152158
App\Config\ScopeConfigInterface $scopeConfig,
153159
View\Page\FaviconInterface $favicon,
154160
Title $title,
155-
\Magento\Framework\Locale\ResolverInterface $localeResolver
161+
\Magento\Framework\Locale\ResolverInterface $localeResolver,
162+
$isIncludesAvailable = true
156163
) {
157164
$this->assetRepo = $assetRepo;
158165
$this->pageAssets = $pageAssets;
159166
$this->scopeConfig = $scopeConfig;
160167
$this->favicon = $favicon;
161168
$this->title = $title;
162169
$this->localeResolver = $localeResolver;
170+
$this->isIncludesAvailable = $isIncludesAvailable;
163171
$this->setElementAttribute(
164172
self::ELEMENT_TYPE_HTML,
165173
self::HTML_ATTRIBUTE_LANG,
@@ -555,7 +563,7 @@ public function getDefaultFavicon()
555563
*/
556564
public function getIncludes()
557565
{
558-
if (empty($this->includes)) {
566+
if (empty($this->includes) && $this->isIncludesAvailable) {
559567
$this->includes = $this->scopeConfig->getValue(
560568
'design/head/includes',
561569
\Magento\Store\Model\ScopeInterface::SCOPE_STORE

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

@@ -498,16 +503,43 @@ public function testGetDefaultFavicon()
498503
$this->model->getDefaultFavicon();
499504
}
500505

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

0 commit comments

Comments
 (0)