Skip to content

Commit 1c36424

Browse files
committed
MAGETWO-52660: Improve performance of static assets deployment
- MAGETWO-57185: Porting to 2.1
1 parent 5dac51f commit 1c36424

File tree

2 files changed

+16
-55
lines changed

2 files changed

+16
-55
lines changed

app/code/Magento/Deploy/Test/Unit/Console/Command/DeployStaticContentCommandTest.php

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Symfony\Component\Console\Tester\CommandTester;
1010
use Magento\Framework\Validator\Locale;
1111
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
12-
use Magento\Framework\App\State;
1312

1413
require 'FunctionExistMock.php';
1514

@@ -45,11 +44,6 @@ class DeployStaticContentCommandTest extends \PHPUnit_Framework_TestCase
4544
*/
4645
private $validator;
4746

48-
/**
49-
* @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject
50-
*/
51-
private $appState;
52-
5347
protected function setUp()
5448
{
5549
$this->objectManager = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class);
@@ -62,20 +56,17 @@ protected function setUp()
6256
);
6357
$this->deployer = $this->getMock(\Magento\Deploy\Model\Deployer::class, [], [], '', false);
6458
$this->filesUtil = $this->getMock(\Magento\Framework\App\Utility\Files::class, [], [], '', false);
65-
$this->appState = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false);
6659

6760
$this->validator = $this->getMock(\Magento\Framework\Validator\Locale::class, [], [], '', false);
6861
$this->command = (new ObjectManager($this))->getObject(DeployStaticContentCommand::class, [
6962
'objectManagerFactory' => $this->objectManagerFactory,
7063
'validator' => $this->validator,
7164
'objectManager' => $this->objectManager,
72-
'appState' => $this->appState,
7365
]);
7466
}
7567

7668
public function testExecute()
7769
{
78-
$this->appState->expects($this->once())->method('getMode')->willReturn(State::MODE_PRODUCTION);
7970
$this->filesUtil->expects(self::any())->method('getStaticPreProcessingFiles')->willReturn([]);
8071
$this->deployer->expects($this->once())->method('deploy');
8172
$this->objectManager->expects($this->at(0))->method('create')->willReturn($this->filesUtil);
@@ -87,7 +78,6 @@ public function testExecute()
8778

8879
public function testExecuteValidateLanguages()
8980
{
90-
$this->appState->expects($this->once())->method('getMode')->willReturn(State::MODE_PRODUCTION);
9181
$this->filesUtil->expects(self::any())->method('getStaticPreProcessingFiles')->willReturn([]);
9282
$this->deployer->expects($this->once())->method('deploy');
9383
$this->objectManager->expects($this->at(0))->method('create')->willReturn($this->filesUtil);
@@ -107,7 +97,6 @@ public function testExecuteValidateLanguages()
10797
*/
10898
public function testExecuteIncludedExcludedLanguages()
10999
{
110-
$this->appState->expects($this->once())->method('getMode')->willReturn(State::MODE_PRODUCTION);
111100
$this->filesUtil->expects(self::any())->method('getStaticPreProcessingFiles')->willReturn([]);
112101
$this->objectManager->expects($this->at(0))->method('create')->willReturn($this->filesUtil);
113102
$this->validator->expects(self::exactly(2))->method('isValid')->willReturnMap([
@@ -125,7 +114,6 @@ public function testExecuteIncludedExcludedLanguages()
125114
*/
126115
public function testExecuteIncludedExcludedAreas()
127116
{
128-
$this->appState->expects($this->once())->method('getMode')->willReturn(State::MODE_PRODUCTION);
129117
$this->filesUtil->expects(self::any())->method('getStaticPreProcessingFiles')->willReturn([]);
130118
$this->objectManager->expects($this->at(0))->method('create')->willReturn($this->filesUtil);
131119

@@ -139,7 +127,6 @@ public function testExecuteIncludedExcludedAreas()
139127
*/
140128
public function testExecuteIncludedExcludedThemes()
141129
{
142-
$this->appState->expects($this->once())->method('getMode')->willReturn(State::MODE_PRODUCTION);
143130
$this->filesUtil->expects(self::any())->method('getStaticPreProcessingFiles')->willReturn([]);
144131
$this->objectManager->expects($this->at(0))->method('create')->willReturn($this->filesUtil);
145132

@@ -153,7 +140,6 @@ public function testExecuteIncludedExcludedThemes()
153140
*/
154141
public function testExecuteInvalidLanguageArgument()
155142
{
156-
$this->appState->expects($this->once())->method('getMode')->willReturn(State::MODE_PRODUCTION);
157143
$this->filesUtil->expects(self::any())->method('getStaticPreProcessingFiles')->willReturn([]);
158144
$this->objectManager->expects($this->at(0))
159145
->method('create')
@@ -162,30 +148,4 @@ public function testExecuteInvalidLanguageArgument()
162148
$commandTester = new CommandTester($this->command);
163149
$commandTester->execute($wrongParam);
164150
}
165-
166-
/**
167-
* @param string $mode
168-
* @return void
169-
* @expectedException \Magento\Framework\Exception\LocalizedException
170-
* @dataProvider executionInNonProductionModeDataProvider
171-
*/
172-
public function testExecuteInNonProductionMode($mode)
173-
{
174-
$this->appState->expects($this->any())->method('getMode')->willReturn($mode);
175-
$this->objectManager->expects($this->never())->method('create');
176-
177-
$tester = new CommandTester($this->command);
178-
$tester->execute([]);
179-
}
180-
181-
/**
182-
* @return array
183-
*/
184-
public function executionInNonProductionModeDataProvider()
185-
{
186-
return [
187-
[State::MODE_DEFAULT],
188-
[State::MODE_DEVELOPER],
189-
];
190-
}
191151
}

dev/tests/integration/testsuite/Magento/Framework/View/Asset/MinifierTest.php

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -140,43 +140,44 @@ protected function _testCssMinification($requestedUri, $assertionCallback)
140140
}
141141

142142
/**
143-
* @magentoConfigFixture current_store dev/css/minify_files 1
143+
* @magentoConfigFixture current_store dev/css/minify_files 0
144+
* @magentoAppIsolation enabled
144145
*/
145-
public function testCssMinification()
146+
public function testCssMinificationOff()
146147
{
147148
$this->_testCssMinification(
148-
'/frontend/FrameworkViewMinifier/default/en_US/css/styles.min.css',
149+
'/frontend/FrameworkViewMinifier/default/en_US/css/styles.css',
149150
function ($path) {
150-
$this->assertEquals(
151+
$content = file_get_contents($path);
152+
$this->assertNotEmpty($content);
153+
$this->assertContains('FrameworkViewMinifier/frontend', $content);
154+
$this->assertNotEquals(
151155
file_get_contents(
152156
dirname(__DIR__)
153157
. '/_files/static/expected/styles.magento.min.css'
154158
),
155-
file_get_contents($path),
156-
'Minified files are not equal or minification did not work for requested CSS'
159+
$content,
160+
'CSS is minified when minification turned off'
157161
);
158162
}
159163
);
160164
}
161165

162166
/**
163-
* @magentoConfigFixture current_store dev/css/minify_files 0
167+
* @magentoConfigFixture current_store dev/css/minify_files 1
164168
*/
165-
public function testCssMinificationOff()
169+
public function testCssMinification()
166170
{
167171
$this->_testCssMinification(
168-
'/frontend/FrameworkViewMinifier/default/en_US/css/styles.css',
172+
'/frontend/FrameworkViewMinifier/default/en_US/css/styles.min.css',
169173
function ($path) {
170-
$content = file_get_contents($path);
171-
$this->assertNotEmpty($content);
172-
$this->assertContains('FrameworkViewMinifier/frontend', $content);
173-
$this->assertNotEquals(
174+
$this->assertEquals(
174175
file_get_contents(
175176
dirname(__DIR__)
176177
. '/_files/static/expected/styles.magento.min.css'
177178
),
178-
$content,
179-
'CSS is minified when minification turned off'
179+
file_get_contents($path),
180+
'Minified files are not equal or minification did not work for requested CSS'
180181
);
181182
}
182183
);

0 commit comments

Comments
 (0)