Skip to content

Commit abd6d63

Browse files
author
Bohdan Korablov
committed
Merge remote-tracking branch 'tangoc/MAGETWO-44469' into new_pr_bugs
2 parents d617106 + bb0d99a commit abd6d63

File tree

3 files changed

+36
-30
lines changed

3 files changed

+36
-30
lines changed

app/code/Magento/Deploy/Model/Deployer.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,11 @@ private function deployFile($filePath, $area, $themePath, $locale, $module)
312312
}
313313
}
314314

315-
$logMessage = "Processing file '$filePath' for area '$area', theme '$themePath', locale '$locale'";
316-
if ($module) {
317-
$logMessage .= ", module '$module'";
318-
}
319-
320315
if ($this->output->isVeryVerbose()) {
316+
$logMessage = "Processing file '$filePath' for area '$area', theme '$themePath', locale '$locale'";
317+
if ($module) {
318+
$logMessage .= ", module '$module'";
319+
}
321320
$this->output->writeln($logMessage);
322321
}
323322

lib/internal/Magento/Framework/View/Asset/Source.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,12 @@ private function preProcess(LocalInterface $asset)
128128
$this->preProcessorPool->process($chain);
129129
$chain->assertValid();
130130
$dirCode = DirectoryList::ROOT;
131-
if ($chain->isChanged()) {
131+
$directoryReader = $this->filesystem->getDirectoryRead(DirectoryList::STATIC_VIEW);
132+
$targetPath = DirectoryList::TMP_MATERIALIZATION_DIR . '/source/' . $chain->getTargetAssetPath();
133+
134+
if ($chain->isChanged() || !$directoryReader->isExist($targetPath)) {
132135
$dirCode = DirectoryList::VAR_DIR;
133-
$path = DirectoryList::TMP_MATERIALIZATION_DIR . '/source/' . $chain->getTargetAssetPath();
136+
$path = $targetPath;
134137
$this->varDir->writeFile($path, $chain->getContent());
135138
}
136139
$result = [$dirCode, $path];

lib/internal/Magento/Framework/View/Test/Unit/Asset/SourceTest.php

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ protected function setUp()
9494
$themeList->expects($this->any())
9595
->method('getThemeByFullPath')
9696
->with('frontend/magento_theme')
97-
->will($this->returnValue($this->theme));
97+
->willReturn($this->theme);
9898

9999
$this->initFilesystem();
100100

@@ -104,32 +104,36 @@ protected function setUp()
104104
}
105105

106106
/**
107-
* @param $origFile
108-
* @param $origPath
109-
* @param $origContent
110-
* @param $isMaterialization
107+
* @param string $origFile
108+
* @param string $origPath
109+
* @param string $origContent
110+
* @param bool $isMaterialization
111+
* @param bool $isExist
111112
*
112113
* @dataProvider getFileDataProvider
113114
*/
114-
public function testGetFile($origFile, $origPath, $origContent, $isMaterialization)
115+
public function testGetFile($origFile, $origPath, $origContent, $isMaterialization, $isExist)
115116
{
116117
$filePath = 'some/file.ext';
117118
$this->viewFileResolution->expects($this->once())
118119
->method('getFile')
119120
->with('frontend', $this->theme, 'en_US', $filePath, 'Magento_Module')
120-
->will($this->returnValue($origFile));
121+
->willReturn($origFile);
121122
$this->rootDirRead->expects($this->once())
122123
->method('getRelativePath')
123124
->with($origFile)
124-
->will($this->returnValue($origPath));
125+
->willReturn($origPath);
125126
$this->rootDirRead->expects($this->once())
126127
->method('readFile')
127128
->with($origPath)
128-
->will($this->returnValue($origContent));
129+
->willReturn($origContent);
129130
$this->preProcessorPool->expects($this->once())
130131
->method('process')
131132
->with($this->chain);
132-
if ($isMaterialization) {
133+
$this->staticDirRead->expects($this->any())
134+
->method('isExist')
135+
->willReturn($isExist);
136+
if ($isMaterialization || !$isExist) {
133137
$this->chain
134138
->expects($this->once())
135139
->method('isChanged')
@@ -147,13 +151,13 @@ public function testGetFile($origFile, $origPath, $origContent, $isMaterializati
147151
->with('view_preprocessed/source/some/file.ext', 'processed');
148152
$this->varDir->expects($this->once())
149153
->method('getAbsolutePath')
150-
->with('view_preprocessed/source/some/file.ext')->will($this->returnValue('result'));
154+
->with('view_preprocessed/source/some/file.ext')->willReturn('result');
151155
} else {
152156
$this->varDir->expects($this->never())->method('writeFile');
153157
$this->rootDirRead->expects($this->once())
154158
->method('getAbsolutePath')
155159
->with('source/some/file.ext')
156-
->will($this->returnValue('result'));
160+
->willReturn('result');
157161
}
158162
$this->assertSame('result', $this->object->getFile($this->getAsset()));
159163
}
@@ -197,10 +201,10 @@ public function chainTestCallback(Chain $chain)
197201
public function getFileDataProvider()
198202
{
199203
return [
200-
['/root/some/file.ext', 'source/some/file.ext', 'processed', false],
201-
['/root/some/file.ext', 'source/some/file.ext', 'not_processed', true],
202-
['/root/some/file.ext2', 'source/some/file.ext2', 'processed', true],
203-
['/root/some/file.ext2', 'source/some/file.ext2', 'not_processed', true],
204+
['/root/some/file.ext', 'source/some/file.ext', 'processed', false, true],
205+
['/root/some/file.ext', 'source/some/file.ext', 'not_processed', true, false],
206+
['/root/some/file.ext2', 'source/some/file.ext2', 'processed', true, true],
207+
['/root/some/file.ext2', 'source/some/file.ext2', 'not_processed', true, false],
204208
];
205209
}
206210

@@ -219,11 +223,11 @@ protected function initFilesystem()
219223

220224
$this->filesystem->expects($this->any())
221225
->method('getDirectoryRead')
222-
->will($this->returnValueMap($readDirMap));
226+
->willReturnMap($readDirMap);
223227
$this->filesystem->expects($this->any())
224228
->method('getDirectoryWrite')
225229
->with(DirectoryList::VAR_DIR)
226-
->will($this->returnValue($this->varDir));
230+
->willReturn($this->varDir);
227231
}
228232

229233
/**
@@ -252,19 +256,19 @@ protected function getAsset($isFallback = true)
252256
$asset = $this->getMock('Magento\Framework\View\Asset\File', [], [], '', false);
253257
$asset->expects($this->any())
254258
->method('getContext')
255-
->will($this->returnValue($context));
259+
->willReturn($context);
256260
$asset->expects($this->any())
257261
->method('getFilePath')
258-
->will($this->returnValue('some/file.ext'));
262+
->willReturn('some/file.ext');
259263
$asset->expects($this->any())
260264
->method('getPath')
261-
->will($this->returnValue('some/file.ext'));
265+
->willReturn('some/file.ext');
262266
$asset->expects($this->any())
263267
->method('getModule')
264-
->will($this->returnValue('Magento_Module'));
268+
->willReturn('Magento_Module');
265269
$asset->expects($this->any())
266270
->method('getContentType')
267-
->will($this->returnValue('ext'));
271+
->willReturn('ext');
268272

269273
return $asset;
270274
}

0 commit comments

Comments
 (0)