/** * @param $contentType * @param $attributes * @param $ieCondition * @param $expectedResult * @dataProvider dataProviderRenderAsset */ public function testRenderAsset($contentType, $attributes, $ieCondition, $expectedResult) { $assetUrl = 'url'; $assetNoRoutUrl = 'no_route_url'; $exception = new \Magento\Framework\Exception('my message'); $assetMock1 = $this->getMock('Magento\\Framework\\View\\Asset\\AssetInterface'); $assetMock1->expects($this->once())->method('getUrl')->willReturn($assetUrl); $assetMock2 = $this->getMock('Magento\\Framework\\View\\Asset\\AssetInterface'); $assetMock2->expects($this->once())->method('getUrl')->willThrowException($exception); $groupAssets = [$assetMock1, $assetMock2]; $this->pageConfigMock->expects($this->once())->method('getAssetCollection')->willReturn($this->assetsCollection); $this->assetsCollection->expects($this->once())->method('getGroups')->willReturn([$this->propertyGroupMock]); $this->propertyGroupMock->expects($this->once())->method('getAll')->willReturn($groupAssets); $this->propertyGroupMock->expects($this->any())->method('getProperty')->willReturnMap([[GroupedCollection::PROPERTY_CAN_MERGE, true], [GroupedCollection::PROPERTY_CONTENT_TYPE, $contentType], ['attributes', $attributes], ['ie_condition', $ieCondition]]); $this->assetMinifyServiceMock->expects($this->once())->method('getAssets')->with($groupAssets)->willReturn($groupAssets); $this->assetMergeServiceMock->expects($this->once())->method('getMergedAssets')->with($groupAssets, $contentType)->willReturnArgument(0); $this->loggerMock->expects($this->once())->method('critical')->with($exception); $this->urlBuilderMock->expects($this->once())->method('getUrl')->with('', ['_direct' => 'core/index/notFound'])->willReturn($assetNoRoutUrl); $this->assertEquals($expectedResult, $this->renderer->renderAssets()); }
/** * @param string $groupHtml * @param \Magento\Framework\View\Asset\PropertyGroup $group * @return string */ protected function processIeCondition($groupHtml, $group) { $ieCondition = $group->getProperty('ie_condition'); if (!empty($ieCondition)) { $groupHtml = '<!--[if ' . $ieCondition . ']>' . "\n" . $groupHtml . '<![endif]-->' . "\n"; } return $groupHtml; }
public function testGetProperty() { $this->assertEquals('test_value', $this->_object->getProperty('test_property')); $this->assertNull($this->_object->getProperty('non_existing_property')); }