Skip to content

Commit fc6d1ad

Browse files
author
Alex Paliarush
committed
MAGETWO-62567: Make static file versioning number not based on timestamp
1 parent 9d1048b commit fc6d1ad

File tree

3 files changed

+50
-18
lines changed

3 files changed

+50
-18
lines changed

app/code/Magento/Deploy/Test/Unit/Service/DeployStaticContentTest.php

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ protected function setUp()
9696
'',
9797
false
9898
);
99-
$this->versionStorage->expects($this->once())->method('save');
10099

101100
$this->service = new DeployStaticContent(
102101
$this->objectManager,
@@ -107,14 +106,13 @@ protected function setUp()
107106
);
108107
}
109108

110-
public function testDeploy()
109+
/**
110+
* @param array $options
111+
* @param string $expectedContentVersion
112+
* @dataProvider deployDataProvider
113+
*/
114+
public function testDeploy($options, $expectedContentVersion)
111115
{
112-
$options = [
113-
'strategy' => 'compact',
114-
'no-javascript' => false,
115-
'no-html-minify' => false
116-
];
117-
118116
$package = $this->getMock(Package::class, [], [], '', false);
119117
$package->expects($this->exactly(1))->method('isVirtual')->willReturn(false);
120118
$package->expects($this->exactly(3))->method('getArea')->willReturn('area');
@@ -125,7 +123,11 @@ public function testDeploy()
125123
'package' => $package
126124
];
127125

128-
$this->versionStorage->expects($this->once())->method('save');
126+
if ($expectedContentVersion) {
127+
$this->versionStorage->expects($this->once())->method('save')->with($expectedContentVersion);
128+
} else {
129+
$this->versionStorage->expects($this->once())->method('save');
130+
}
129131

130132
$queue = $this->getMockBuilder(Queue::class)
131133
->disableOriginalConstructor()
@@ -193,4 +195,27 @@ public function testDeploy()
193195
$this->service->deploy($options)
194196
);
195197
}
198+
199+
public function deployDataProvider()
200+
{
201+
return [
202+
[
203+
[
204+
'strategy' => 'compact',
205+
'no-javascript' => false,
206+
'no-html-minify' => false
207+
],
208+
null // content version value should not be asserted in this case
209+
],
210+
[
211+
[
212+
'strategy' => 'compact',
213+
'no-javascript' => false,
214+
'no-html-minify' => false,
215+
'content-version' => '123456',
216+
],
217+
'123456'
218+
]
219+
];
220+
}
196221
}

dev/tests/integration/testsuite/Magento/Deploy/DeployTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ protected function tearDown()
130130
*/
131131
public function testDeploy()
132132
{
133-
//$this->markTestSkipped('Test blocked since it must be run in isolated Filesystem');
134133
$this->deployService->deploy($this->options);
135134

136135
$this->assertFileExists($this->staticDir->getAbsolutePath('frontend/Magento/zoom1/default/css/root.css'));

setup/src/Magento/Setup/Test/Unit/Console/Command/DeployStaticContentCommandTest.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ class DeployStaticContentCommandTest extends \PHPUnit_Framework_TestCase
4949
*/
5050
private $deployService;
5151

52-
/**
53-
* @var DeployStaticOptions|Mock
54-
*/
55-
private $options;
56-
5752
/**
5853
* Object manager to create various objects
5954
*
@@ -75,7 +70,6 @@ protected function setUp()
7570
$this->inputValidator = $this->getMock(InputValidator::class, [], [], '', false);
7671
$this->consoleLoggerFactory = $this->getMock(ConsoleLoggerFactory::class, [], [], '', false);
7772
$this->logger = $this->getMock(ConsoleLogger::class, [], [], '', false);
78-
$this->options = $this->getMock(DeployStaticOptions::class, [], [], '', false);
7973
$this->objectManager = $this->getMockForAbstractClass(ObjectManagerInterface::class);
8074
$this->appState = $this->getMock(State::class, [], [], '', false);
8175
$this->deployService = $this->getMock(DeployStaticContent::class, [], [], '', false);
@@ -99,9 +93,11 @@ protected function setUp()
9993
}
10094

10195
/**
96+
* @param array $input
10297
* @see DeployStaticContentCommand::execute()
98+
* @dataProvider executeDataProvider
10399
*/
104-
public function testExecute()
100+
public function testExecute($input)
105101
{
106102
$this->appState->expects($this->once())
107103
->method('getMode')
@@ -118,7 +114,19 @@ public function testExecute()
118114
$this->deployService->expects($this->once())->method('deploy');
119115

120116
$tester = new CommandTester($this->command);
121-
$tester->execute([]);
117+
$tester->execute($input);
118+
}
119+
120+
public function executeDataProvider()
121+
{
122+
return [
123+
'No options' => [
124+
[]
125+
],
126+
'With static content version option' => [
127+
['--content-version' => '123456']
128+
]
129+
];
122130
}
123131

124132
/**

0 commit comments

Comments
 (0)