46 private $deployService;
56 private $bundleConfig;
61 private $staticContentService;
72 Options::DRY_RUN =>
false,
73 Options::NO_JAVASCRIPT =>
false,
74 Options::NO_CSS =>
false,
75 Options::NO_LESS =>
false,
76 Options::NO_IMAGES =>
false,
77 Options::NO_FONTS =>
false,
78 Options::NO_HTML =>
false,
79 Options::NO_MISC =>
false,
80 Options::NO_HTML_MINIFY =>
false,
81 Options::AREA => [
'frontend'],
82 Options::EXCLUDE_AREA => [
'none'],
83 Options::THEME => [
'Magento/zoom1',
'Magento/zoom2',
'Magento/zoom3'],
84 Options::EXCLUDE_THEME => [
'none'],
85 Options::LANGUAGE => [
'en_US',
'fr_FR',
'pl_PL'],
86 Options::EXCLUDE_LANGUAGE => [
'none'],
87 Options::JOBS_AMOUNT => 0,
88 Options::SYMLINK_LOCALE =>
false,
103 $this->deployService =
$objectManager->create(DeployStaticContent::class, [
107 $this->bundleConfig =
$objectManager->create(BundleConfig::class);
110 $this->staticContentService =
$objectManager->create(DeployStaticContent::class);
123 $this->staticDir->getDriver()->createDirectory($this->staticDir->getAbsolutePath());
133 $this->deployService->deploy($this->options);
135 $this->assertFileExists($this->staticDir->getAbsolutePath(
'frontend/Magento/zoom1/default/css/root.css'));
136 $this->assertFileExists($this->staticDir->getAbsolutePath(
'frontend/Magento/zoom2/default/css/root.css'));
137 $this->assertFileExists($this->staticDir->getAbsolutePath(
'frontend/Magento/zoom3/default/css/root.css'));
138 $this->assertFileExists($this->staticDir->getAbsolutePath(
'frontend/Magento/zoom3/default/css/local.css'));
140 $this->assertFileExistsIsGenerated(
'requirejs-config.js');
141 $this->assertFileExistsIsGenerated(
'requirejs-map.js');
142 $this->assertFileExistsIsGenerated(
'map.json');
143 $this->assertFileExistsIsGenerated(
'js-translation.json');
144 $this->assertFileExistsIsGenerated(
'result_map.json');
146 $actualFileContent = $this->staticDir->readFile(
'frontend/Magento/zoom3/default/css/root.css');
147 $this->assertLessPreProcessor($actualFileContent);
148 $this->assertCssUrlFixerPostProcessor($actualFileContent);
150 foreach ([
'Magento/zoom1',
'Magento/zoom2',
'Magento/zoom3'] as
$theme) {
151 $this->assertBundleSize(
$theme);
152 $this->assertExcluded(
$theme, $this->config->getExcludedFiles());
153 $this->assertExcluded(
$theme, $this->config->getExcludedDir());
163 private function assertFileExistsIsGenerated(
$fileName)
165 foreach ([
'Magento/zoom1',
'Magento/zoom2',
'Magento/zoom3'] as
$theme) {
166 foreach ($this->options[Options::LANGUAGE] as $locale) {
167 $this->assertFileExists(
168 $this->staticDir->getAbsolutePath(
183 private function assertLessPreProcessor($actualRootCssContent)
187 $this->assertContains(
'color:#111', $actualRootCssContent);
196 private function assertCssUrlFixerPostProcessor($actualRootCssContent)
199 $this->assertContains(
200 'url("../../../../../frontend/Magento/zoom1/default/images/logo-magento-1.png")',
201 $actualRootCssContent
203 $this->assertContains(
204 'url("../../../../../frontend/Magento/zoom2/default/images/logo-magento-2.png")',
205 $actualRootCssContent
207 $this->assertContains(
208 'url("../images/logo-magento-3.png")',
209 $actualRootCssContent
213 $this->assertContains(
'color:#111', $actualRootCssContent);
222 private function assertBundleSize(
$theme)
224 $expectedSize = $this->bundleConfig->getBundleFileMaxSize(
'frontend',
$theme);
225 $expectedSize *= 1.15;
227 $iterator = $this->getDirectoryIterator(
"frontend/{$theme}/en_US/js/bundle");
230 if ($file->isFile()) {
231 $size = (int)$file->getSize() / 1024;
232 $this->assertLessThan($expectedSize, $size);
244 private function assertExcluded(
$theme, array $excluded)
246 $iterator = $this->getDirectoryIterator(
"frontend/{$theme}/en_US/js/bundle");
247 foreach ($excluded as $pathData) {
248 $path = $this->splitPath($pathData);
249 if (
$path[
'module'] !==
null) {
256 if ($file->isFile()) {
257 $bundleContent = $this->staticDir->readFile(
258 $this->staticDir->getRelativePath($file->getPathname())
260 $this->assertNotContains(
'"' .
$path .
'":"', $bundleContent);
270 private function getDirectoryIterator(
$path)
272 $dirIterator = new \RecursiveDirectoryIterator(
273 $this->staticDir->getAbsolutePath(
$path),
274 \FilesystemIterator::SKIP_DOTS
276 return new \RecursiveIteratorIterator($dirIterator, \RecursiveIteratorIterator::SELF_FIRST);
285 private function splitPath(
$path)
287 if (strpos(
$path,
'::') !==
false) {
290 'module' => $module !=
'Lib' ? $module :
null,
const TMP_MATERIALIZATION_DIR
const DEPLOY_STRATEGY_COMPACT
static getObjectManager()