@@ -51,6 +51,15 @@ public function testCssMinifierLibrary()
51
51
);
52
52
}
53
53
54
+ /**
55
+ * Test CSS minification
56
+ *
57
+ * @param string $requestedUri
58
+ * @param string $requestedFilePath
59
+ * @param string $testFile
60
+ * @param callable $assertionCallback
61
+ * @throws \Magento\Framework\Exception
62
+ */
54
63
protected function _testCssMinification ($ requestedUri , $ requestedFilePath , $ testFile , $ assertionCallback )
55
64
{
56
65
/** @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject $appState */
@@ -171,4 +180,68 @@ function ($path) {
171
180
}
172
181
);
173
182
}
183
+
184
+ /**
185
+ * @magentoConfigFixture current_store dev/css/minify_files 1
186
+ */
187
+ public function testDeploymentWithMinifierEnabled ()
188
+ {
189
+ $ initDirectories = Bootstrap::getInstance ()
190
+ ->getAppInitParams ()[\Magento \Framework \App \Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS ];
191
+
192
+ $ designPath = $ initDirectories ['design ' ]['path ' ];
193
+
194
+ $ staticPath = $ initDirectories ['static ' ]['path ' ];
195
+
196
+ $ fileToBePublished = $ staticPath . '/frontend/Magento/blank/en_US/css/styles.css ' ;
197
+ $ destFile = $ designPath . '/frontend/Magento/blank/web/css/styles.css ' ;
198
+ $ fileToTestPublishing = dirname (__DIR__ ) . '/_files/static/css/styles.css ' ;
199
+
200
+ if (!is_readable (dirname ($ destFile ))) {
201
+ mkdir (dirname ($ destFile ), 777 , true );
202
+ }
203
+
204
+ copy ($ fileToTestPublishing , $ destFile );
205
+
206
+ $ omFactory = $ this ->getMock ('\Magento\Framework\App\ObjectManagerFactory ' , ['create ' ], [], '' , false );
207
+ $ omFactory ->expects ($ this ->any ())
208
+ ->method ('create ' )
209
+ ->will ($ this ->returnValue ($ this ->objectManager ));
210
+
211
+ $ logger = $ this ->objectManager ->create (
212
+ 'Magento\Tools\View\Deployer\Log ' ,
213
+ ['verbosity ' => \Magento \Tools \View \Deployer \Log::SILENT ]
214
+ );
215
+
216
+ $ filesUtil = $ this ->getMock ('\Magento\Framework\Test\Utility\Files ' , [], [], '' , false );
217
+ $ filesUtil ->expects ($ this ->any ())
218
+ ->method ('getStaticLibraryFiles ' )
219
+ ->will ($ this ->returnValue ([]));
220
+
221
+ $ filesUtil ->expects ($ this ->any ())
222
+ ->method ('getStaticPreProcessingFiles ' )
223
+ ->will ($ this ->returnValue (
224
+ [
225
+ ['frontend ' , 'Magento/blank ' , '' , '' , 'css/styles.css ' , $ destFile ]
226
+ ]
227
+ ));
228
+
229
+ /** @var \Magento\Tools\View\Deployer $deployer */
230
+ $ deployer = $ this ->objectManager ->create (
231
+ 'Magento\Tools\View\Deployer ' ,
232
+ ['filesUtil ' => $ filesUtil , 'logger ' => $ logger , 'isDryRun ' => false ]
233
+ );
234
+
235
+ $ deployer ->deploy ($ omFactory , ['en_US ' ]);
236
+
237
+ $ this ->assertFileExists ($ fileToBePublished );
238
+ $ this ->assertEquals (
239
+ file_get_contents (dirname (__DIR__ ) . '/_files/static/css/styles.magento.min.css ' ),
240
+ file_get_contents ($ fileToBePublished ),
241
+ 'Minified file is not equal or minification did not work for deployed CSS '
242
+ );
243
+
244
+ unlink ($ destFile );
245
+ unlink ($ fileToBePublished );
246
+ }
174
247
}
0 commit comments