9 use \Magento\Framework\View\Asset\MergeStrategy\Direct;
42 $this->cssUrlResolver = $this->createMock(\
Magento\Framework\View\
Url\CssResolver::class);
44 $this->staticDir = $this->getMockBuilder(WriteInterface::class)->getMockForAbstractClass();
45 $this->tmpDir = $this->getMockBuilder(WriteInterface::class)->getMockForAbstractClass();
47 ->method(
'getDirectoryWrite')
52 $this->resultAsset = $this->createMock(\
Magento\Framework\View\
Asset\File::class);
58 $this->resultAsset->expects($this->once())->method(
'getPath')->will($this->returnValue(
'foo/result'));
59 $this->staticDir->expects($this->never())->method(
'writeFile');
60 $this->tmpDir->expects($this->once())->method(
'writeFile')->with(
'foo/result',
'');
61 $this->tmpDir->expects($this->once())->method(
'renameFile')->with(
'foo/result',
'foo/result', $this->staticDir);
62 $this->
object->merge([], $this->resultAsset);
67 $this->resultAsset->expects($this->once())->method(
'getPath')->will($this->returnValue(
'foo/result'));
68 $assets = $this->prepareAssetsToMerge([
' one',
'two']);
69 $this->staticDir->expects($this->never())->method(
'writeFile');
70 $this->tmpDir->expects($this->once())->method(
'writeFile')->with(
'foo/result',
'onetwo');
71 $this->tmpDir->expects($this->once())->method(
'renameFile')->with(
'foo/result',
'foo/result', $this->staticDir);
72 $this->
object->merge($assets, $this->resultAsset);
77 $this->resultAsset->expects($this->exactly(3))
79 ->will($this->returnValue(
'foo/result'));
80 $this->resultAsset->expects($this->any())->method(
'getContentType')->will($this->returnValue(
'css'));
81 $assets = $this->prepareAssetsToMerge([
'one',
'two']);
82 $this->cssUrlResolver->expects($this->exactly(2))
83 ->method(
'relocateRelativeUrls')
84 ->will($this->onConsecutiveCalls(
'1',
'2'));
85 $this->cssUrlResolver->expects($this->once())
86 ->method(
'aggregateImportDirectives')
88 ->will($this->returnValue(
'1020'));
89 $this->staticDir->expects($this->never())->method(
'writeFile');
90 $this->tmpDir->expects($this->once())->method(
'writeFile')->with(
'foo/result',
'1020');
91 $this->tmpDir->expects($this->once())->method(
'renameFile')->with(
'foo/result',
'foo/result', $this->staticDir);
92 $this->
object->merge($assets, $this->resultAsset);
101 private function prepareAssetsToMerge(array
$data)
105 $asset = $this->getMockForAbstractClass(\
Magento\Framework\View\
Asset\LocalInterface::class);
106 $asset->expects($this->once())->method(
'getContent')->will($this->returnValue(
$content));