Skip to content

Commit ced7d08

Browse files
Merge branch 'MAGETWO-51185' of https://github.corp.magento.com/magento-tango/magento2ce into MAGETWO-52212
2 parents e5950b6 + 259423a commit ced7d08

File tree

1 file changed

+78
-0
lines changed
  • lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver

1 file changed

+78
-0
lines changed

lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/MinificationTest.php

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,82 @@ public function resolveDataProvider()
9999
[false, 'file.min.css', 'file.min.css', false, false, 'found.css']
100100
];
101101
}
102+
103+
public function testResolveJs()
104+
{
105+
$this->resolverMock
106+
->expects($this->once())
107+
->method('resolve')
108+
->willReturn('/var/test.min.js');
109+
$this->assetMinificationMock->expects($this->once())
110+
->method('isMinifiedFilename')
111+
->willReturn(true);
112+
113+
$this->assertEquals('/var/test.min.js', $this->minification->resolve('', 'test.min.js'));
114+
}
115+
116+
public function testResolveJsWithDisabledMinification()
117+
{
118+
$this->resolverMock
119+
->expects($this->once())
120+
->method('resolve')
121+
->willReturn('/var/test.js');
122+
$this->assetMinificationMock->expects($this->once())
123+
->method('isMinifiedFilename')
124+
->willReturn(false);
125+
126+
$this->assertEquals('/var/test.js', $this->minification->resolve('', 'test.js'));
127+
}
128+
129+
public function testResolveJsToFindMinifiedVersion()
130+
{
131+
$this->resolverMock
132+
->expects($this->exactly(2))
133+
->method('resolve')
134+
->willReturnMap(
135+
[
136+
['', 'test.js', null, null, null, null, '/var/test.js'],
137+
['', 'test.min.js', null, null, null, null, '/var/test.min.js']
138+
]
139+
);
140+
$this->assetMinificationMock->expects($this->once())
141+
->method('isMinifiedFilename')
142+
->willReturn(false);
143+
$this->assetMinificationMock->expects($this->once())
144+
->method('isEnabled')
145+
->with('js')
146+
->willReturn(true);
147+
$this->assetMinificationMock->expects($this->once())
148+
->method('addMinifiedSign')
149+
->with('test.js')
150+
->willReturn('test.min.js');
151+
152+
$this->assertEquals('/var/test.min.js', $this->minification->resolve('', 'test.js'));
153+
}
154+
155+
public function testResolveJsToNotFindMinifiedVersion()
156+
{
157+
$this->resolverMock
158+
->expects($this->exactly(2))
159+
->method('resolve')
160+
->willReturnMap(
161+
[
162+
['', 'test.js', null, null, null, null, '/var/test.js'],
163+
['', 'test.min.js', null, null, null, null, false]
164+
]
165+
);
166+
$this->assetMinificationMock->expects($this->once())
167+
->method('isMinifiedFilename')
168+
->willReturn(false);
169+
$this->assetMinificationMock->expects($this->once())
170+
->method('isEnabled')
171+
->with('js')
172+
->willReturn(true);
173+
$this->assetMinificationMock->expects($this->once())
174+
->method('addMinifiedSign')
175+
->with('test.js')
176+
->willReturn('test.min.js');
177+
178+
$this->assertEquals('/var/test.js', $this->minification->resolve('', 'test.js'));
179+
}
102180
}

0 commit comments

Comments
 (0)