Skip to content

Commit 2ed2246

Browse files
vkholoshenkoRoman Ganin
authored andcommitted
MAGETWO-33052: Fix backend admin.css minification
1 parent ff1c60a commit 2ed2246

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

dev/tests/unit/testsuite/Magento/Framework/View/Asset/Minified/AbstractAssetTestCase.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,18 @@ protected function setUp()
7070

7171
protected function prepareAttemptToMinifyMock($fileExists, $rootDirExpectations = true)
7272
{
73-
$this->_asset->expects($this->atLeastOnce())->method('getPath')->will($this->returnValue('test/library.js'));
73+
$this->_asset->expects($this->atLeastOnce())->method('getPath')->will($this->returnValue('test/admin.js'));
7474
$this->_asset->expects($this->atLeastOnce())
7575
->method('getSourceFile')
76-
->will($this->returnValue('/foo/bar/test/library.js'));
76+
->will($this->returnValue('/foo/bar/test/admin.js'));
7777
if ($rootDirExpectations) {
7878
$this->_rootDir->expects($this->once())
7979
->method('getRelativePath')
80-
->with('/foo/bar/test/library.min.js')
81-
->will($this->returnValue('test/library.min.js'));
80+
->with('/foo/bar/test/admin.min.js')
81+
->will($this->returnValue('test/admin.min.js'));
8282
$this->_rootDir->expects($this->once())
8383
->method('isExist')
84-
->with('test/library.min.js')
84+
->with('test/admin.min.js')
8585
->will($this->returnValue(false));
8686
}
8787
$this->_baseUrl->expects($this->once())->method('getBaseUrl')->will($this->returnValue('http://example.com/'));

dev/tests/unit/testsuite/Magento/Framework/View/Asset/Minified/MutablePathAssetTest.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testInMemoryDecorator($method, $expected)
4545
*/
4646
private function prepareRequestedAsMinifiedMock()
4747
{
48-
$this->_asset->expects($this->exactly(2))->method('getPath')->will($this->returnValue('test/library.min.js'));
48+
$this->_asset->expects($this->exactly(2))->method('getPath')->will($this->returnValue('test/admin.min.js'));
4949
$this->_asset->expects($this->once())->method('getSourceFile')->will($this->returnValue('source_file'));
5050
$this->_asset->expects($this->once())->method('getFilePath')->will($this->returnValue('file_path'));
5151
$this->_asset->expects($this->once())->method('getContext')->will($this->returnValue('context'));
@@ -60,7 +60,7 @@ public function inMemoryDecoratorDataProvider()
6060
return [
6161
['getUrl', 'url'],
6262
['getSourceFile', 'source_file'],
63-
['getPath', 'test/library.min.js'],
63+
['getPath', 'test/admin.min.js'],
6464
['getFilePath', 'file_path'],
6565
['getContext', 'context'],
6666
];
@@ -95,31 +95,31 @@ public function testGetContent()
9595
$this->_adapter->expects($this->never())->method('minify');
9696
$this->_staticViewDir->expects($this->exactly(2))
9797
->method('readFile')
98-
->with('test/library.min.js')
98+
->with('test/admin.min.js')
9999
->will($this->returnValue('content'));
100100
$this->assertEquals('content', $this->_model->getContent());
101101
$this->assertEquals('content', $this->_model->getContent());
102102
}
103103

104104
public function testHasPreminifiedFile()
105105
{
106-
$this->_asset->expects($this->exactly(2))->method('getPath')->will($this->returnValue('test/library.js'));
106+
$this->_asset->expects($this->exactly(2))->method('getPath')->will($this->returnValue('test/admin.js'));
107107
$this->_asset->expects($this->atLeastOnce())
108108
->method('getSourceFile')
109-
->will($this->returnValue('/foo/bar/test/library.js'));
109+
->will($this->returnValue('/foo/bar/test/admin.js'));
110110
$this->_asset->expects($this->once())->method('getFilePath')->will($this->returnValue('file_path'));
111111
$this->_asset->expects($this->once())->method('getContext')->will($this->returnValue('context'));
112112
$this->_asset->expects($this->once())->method('getUrl')->will($this->returnValue('url'));
113113
$this->_rootDir->expects($this->once())
114114
->method('getRelativePath')
115-
->with('/foo/bar/test/library.min.js')
116-
->will($this->returnValue('test/library.min.js'));
115+
->with('/foo/bar/test/admin.min.js')
116+
->will($this->returnValue('test/admin.min.js'));
117117
$this->_rootDir->expects($this->once())
118118
->method('isExist')
119-
->with('test/library.min.js')
119+
->with('test/admin.min.js')
120120
->will($this->returnValue(true));
121121
$this->_adapter->expects($this->never())->method('minify');
122-
$this->assertEquals('test/library.min.js', $this->_model->getPath());
122+
$this->assertEquals('test/admin.min.js', $this->_model->getPath());
123123
}
124124

125125
public function testMinify()
@@ -128,7 +128,7 @@ public function testMinify()
128128
$this->_asset->expects($this->once())->method('getContent')->will($this->returnValue('content'));
129129
$this->_adapter->expects($this->once())->method('minify')->with('content')->will($this->returnValue('mini'));
130130
$this->_staticViewDir->expects($this->once())->method('writeFile')->with($this->anything(), 'mini');
131-
$this->assertStringMatchesFormat('%s_library.min.js', $this->_model->getFilePath());
131+
$this->assertStringMatchesFormat('%s_admin.min.js', $this->_model->getFilePath());
132132
}
133133

134134
public function testMinificationFailed()
@@ -142,15 +142,15 @@ public function testMinificationFailed()
142142
$this->_asset->expects($this->once())->method('getFilePath')->will($this->returnValue('file_path'));
143143
$this->_asset->expects($this->once())->method('getContext')->will($this->returnValue('context'));
144144
$this->_asset->expects($this->once())->method('getUrl')->will($this->returnValue('url'));
145-
$this->assertEquals('test/library.js', $this->_model->getPath());
145+
$this->assertEquals('test/admin.js', $this->_model->getPath());
146146
}
147147

148148
public function testShouldNotMinifyCozExists()
149149
{
150150
$this->prepareAttemptToMinifyMock(true);
151151
// IS_EXISTS is assumed by default, so nothing to mock here
152152
$this->_adapter->expects($this->never())->method('minify');
153-
$this->assertStringMatchesFormat('%s_library.min.js', $this->_model->getFilePath());
153+
$this->assertStringMatchesFormat('%s_admin.min.js', $this->_model->getFilePath());
154154
}
155155

156156
/**
@@ -173,16 +173,16 @@ public function testMinifyMtime($mtimeOrig, $mtimeMinified, $isMinifyExpected)
173173
$this->_rootDir->expects($this->any())
174174
->method('getRelativePath')
175175
->will($this->returnValueMap([
176-
['/foo/bar/test/library.min.js', 'test/library.min.js'],
177-
['/foo/bar/test/library.js', 'test/library.js'],
176+
['/foo/bar/test/admin.min.js', 'test/admin.min.js'],
177+
['/foo/bar/test/admin.js', 'test/admin.js'],
178178
]));
179179
$this->_rootDir->expects($this->once())
180180
->method('isExist')
181-
->with('test/library.min.js')
181+
->with('test/admin.min.js')
182182
->will($this->returnValue(false));
183183
$this->_rootDir->expects($this->once())
184184
->method('stat')
185-
->with('test/library.js')
185+
->with('test/admin.js')
186186
->will($this->returnValue(['mtime' => $mtimeOrig]));
187187
$this->_staticViewDir->expects($this->once())
188188
->method('stat')
@@ -198,7 +198,7 @@ public function testMinifyMtime($mtimeOrig, $mtimeMinified, $isMinifyExpected)
198198
} else {
199199
$this->_adapter->expects($this->never())->method('minify');
200200
}
201-
$this->assertStringMatchesFormat('%s_library.min.js', $model->getFilePath());
201+
$this->assertStringMatchesFormat('%s_admin.min.js', $model->getFilePath());
202202
}
203203

204204
/**

lib/internal/Magento/Framework/View/Asset/Minified/AbstractAsset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ protected function process()
247247
*/
248248
protected function isFileMinified($fileName)
249249
{
250-
return (bool)preg_match('#.min.\w+$#', $fileName);
250+
return (bool)preg_match('#\.min\.\w+$#', $fileName);
251251
}
252252

253253
/**

0 commit comments

Comments
 (0)