/**
  * @param $groupOne
  * @param $groupTwo
  * @param $expectedResult
  * @dataProvider dataProviderRenderAssets
  */
 public function testRenderAssets($groupOne, $groupTwo, $expectedResult)
 {
     $assetUrl = 'url';
     $assetNoRoutUrl = 'no_route_url';
     $exception = new \Magento\Framework\Exception('my message');
     $assetMockOne = $this->getMock('Magento\\Framework\\View\\Asset\\AssetInterface');
     $assetMockOne->expects($this->exactly(2))->method('getUrl')->willReturn($assetUrl);
     $groupAssetsOne = [$assetMockOne, $assetMockOne];
     $groupMockOne = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\PropertyGroup')->disableOriginalConstructor()->getMock();
     $groupMockOne->expects($this->once())->method('getAll')->willReturn($groupAssetsOne);
     $groupMockOne->expects($this->any())->method('getProperty')->willReturnMap([[GroupedCollection::PROPERTY_CAN_MERGE, true], [GroupedCollection::PROPERTY_CONTENT_TYPE, $groupOne['type']], ['attributes', $groupOne['attributes']], ['ie_condition', $groupOne['condition']]]);
     $assetMockTwo = $this->getMock('Magento\\Framework\\View\\Asset\\AssetInterface');
     $assetMockTwo->expects($this->once())->method('getUrl')->willThrowException($exception);
     $groupAssetsTwo = [$assetMockTwo];
     $groupMockTwo = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\PropertyGroup')->disableOriginalConstructor()->getMock();
     $groupMockTwo->expects($this->once())->method('getAll')->willReturn($groupAssetsTwo);
     $groupMockTwo->expects($this->any())->method('getProperty')->willReturnMap([[GroupedCollection::PROPERTY_CAN_MERGE, true], [GroupedCollection::PROPERTY_CONTENT_TYPE, $groupTwo['type']], ['attributes', $groupTwo['attributes']], ['ie_condition', $groupTwo['condition']]]);
     $this->pageConfigMock->expects($this->once())->method('getAssetCollection')->willReturn($this->assetsCollection);
     $this->assetsCollection->expects($this->once())->method('getGroups')->willReturn([$groupMockOne, $groupMockTwo]);
     $this->assetMinifyServiceMock->expects($this->exactly(2))->method('getAssets')->willReturnArgument(0);
     $this->assetMergeServiceMock->expects($this->exactly(1))->method('getMergedAssets')->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($this->renderer->getAvailableResultGroups()));
 }
Beispiel #2
0
 /**
  * @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());
 }
Beispiel #3
0
 /**
  * Returns rendered HTML for all Assets (CSS before)
  *
  * @param array $resultGroups
  *
  * @return string
  */
 public function renderAssets($resultGroups = [])
 {
     return parent::renderAssets($this->renderLessJsScripts($resultGroups));
 }