getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class);
$theme->expects($this->once())->method('getArea')->will($this->returnValue('area'));
$layoutMergeFactory = $this->_getLayoutMergeFactory($theme, $layoutStr);
$assetRepo = $this->createPartialMock(\Magento\Framework\View\Asset\Repository::class, ['createAsset']);
$assetRepo->expects($this->any())
->method('createAsset')
->will($this->returnArgument(0));
$helper = new \Magento\Theme\Helper\Theme(
$this->createMock(\Magento\Framework\App\Helper\Context::class),
$layoutMergeFactory,
$assetRepo
);
$result = $helper->getCssAssets($theme);
$this->assertSame($expectedResult, $result);
}
/**
* @return array
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function getCssAssetsDataProvider()
{
// @codingStandardsIgnoreStart
return [
[
'
test1.css
',
['test1.css' => 'test1.css'],
],
[
'
Magento_Theme::test3.css
',
['Magento_Theme::test3.css' => 'Magento_Theme::test3.css'],
],
[
'
test.css
Magento_Theme::test.css
testh.css
Magento_Theme::test.css
testa.css
Magento_Theme::testa.css
testb.css
Magento_Theme::testb.css
',
[
'Magento_Theme::test.css' => 'Magento_Theme::test.css',
'test.css' => 'test.css',
'testh.css' => 'testh.css',
],
],
];
// @codingStandardsIgnoreEnd
}
/**
* @param \PHPUnit_Framework_MockObject_MockObject $theme
* @param string $layoutStr
* @return \Magento\Framework\View\Layout\ProcessorFactory|\PHPUnit_Framework_MockObject_MockObject
*/
protected function _getLayoutMergeFactory($theme, $layoutStr)
{
/** @var $layoutProcessor \Magento\Framework\View\Layout\ProcessorInterface */
$layoutProcessor = $this->getMockBuilder(\Magento\Framework\View\Layout\ProcessorInterface::class)
->getMockForAbstractClass();
$xml = '' . $layoutStr . '';
$layoutElement = simplexml_load_string($xml);
$layoutProcessor->expects(
$this->any()
)->method(
'getFileLayoutUpdatesXml'
)->will(
$this->returnValue($layoutElement)
);
/** @var $processorFactory \Magento\Framework\View\Layout\ProcessorFactory */
$processorFactory = $this->createPartialMock(
\Magento\Framework\View\Layout\ProcessorFactory::class,
['create']
);
$processorFactory->expects($this->any())
->method('create')
->with(['theme' => $theme])
->will($this->returnValue($layoutProcessor));
return $processorFactory;
}
}