Skip to content

Commit 9775468

Browse files
committed
Add test for asset with empty content type
1 parent 2e760d3 commit 9775468

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

lib/internal/Magento/Framework/View/Test/Unit/Page/Config/RendererTest.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,4 +427,48 @@ public function dataProviderRenderAssets()
427427
],
428428
];
429429
}
430+
431+
public function testRenderAssetWithNoContentType() : void
432+
{
433+
$type = '';
434+
435+
$assetMockOne = $this->createMock(\Magento\Framework\View\Asset\AssetInterface::class);
436+
$assetMockOne->expects($this->exactly(1))
437+
->method('getUrl')
438+
->willReturn('url');
439+
440+
$assetMockOne->expects($this->atLeastOnce())->method('getContentType')->willReturn($type);
441+
442+
$groupAssetsOne = [$assetMockOne];
443+
444+
$groupMockOne = $this->getMockBuilder(\Magento\Framework\View\Asset\PropertyGroup::class)
445+
->disableOriginalConstructor()
446+
->getMock();
447+
$groupMockOne->expects($this->once())
448+
->method('getAll')
449+
->willReturn($groupAssetsOne);
450+
$groupMockOne->expects($this->any())
451+
->method('getProperty')
452+
->willReturnMap(
453+
[
454+
[GroupedCollection::PROPERTY_CAN_MERGE, true],
455+
[GroupedCollection::PROPERTY_CONTENT_TYPE, $type],
456+
['attributes', 'rel="some-rel"'],
457+
['ie_condition', null],
458+
]
459+
);
460+
461+
$this->pageConfigMock->expects($this->once())
462+
->method('getAssetCollection')
463+
->willReturn($this->assetsCollection);
464+
465+
$this->assetsCollection->expects($this->once())
466+
->method('getGroups')
467+
->willReturn([$groupMockOne]);
468+
469+
$this->assertEquals(
470+
'<link rel="some-rel" href="url" />' . "\n",
471+
$this->renderer->renderAssets($this->renderer->getAvailableResultGroups())
472+
);
473+
}
430474
}

0 commit comments

Comments
 (0)