36 $this->adapterMock = $this->getMockBuilder(\
Magento\Framework\Code\Minifier\AdapterInterface::class)
37 ->setMethods([
'minify'])
38 ->disableOriginalConstructor()
39 ->getMockForAbstractClass();
40 $this->minificationMock = $this->getMockBuilder(\
Magento\Framework\View\
Asset\Minification::class)
41 ->disableOriginalConstructor()
44 $this->minify =
new Minify(
46 $this->minificationMock
59 public function testProcess($targetPath, $originalPath, $minifyCalls, $setContentCalls, $isEnabled)
61 $chainMock = $this->getMockBuilder(\
Magento\Framework\View\
Asset\PreProcessor\Chain::class)
62 ->disableOriginalConstructor()
65 ->expects($this->any())
66 ->method(
'getTargetAssetPath')
67 ->willReturn($targetPath);
69 ->expects($this->exactly($setContentCalls))
70 ->method(
'setContent')
71 ->with(
'minified content');
73 ->expects($this->any())
74 ->method(
'getContent')
75 ->willReturn(
'original content');
77 ->expects($this->any())
78 ->method(
'getOrigAssetPath')
79 ->willReturn($originalPath);
82 ->expects($this->exactly($minifyCalls))
84 ->with(
'original content')
85 ->willReturn(
'minified content');
87 $this->minificationMock
88 ->expects($this->any())
90 ->willReturnMap([[
'css', $isEnabled]]);
92 $this->minificationMock
93 ->expects($this->any())
94 ->method(
'isMinifiedFilename')
97 [
'test.min.css',
true],
103 $this->minify->process($chainMock);
112 [
'test.min.css',
'test.css', 1, 1,
true],
113 [
'test.min.css',
'test.min.css', 0, 0,
true],
114 [
'test.jpeg',
'test.jpeg', 0, 0,
true],
115 [
'test.css',
'test.css', 0, 0,
true],
116 [
'test.jpeg',
'test.jpeg', 0, 0,
true],
117 [
'test.css',
'test.css', 0, 0,
true],
118 [
'test.css',
'test.css', 0, 0,
false]
testProcess($targetPath, $originalPath, $minifyCalls, $setContentCalls, $isEnabled)