Skip to content

Commit 492238d

Browse files
committed
AC-10573: Static deploy doesn't update files
Updated test coverage
1 parent 3e6d389 commit 492238d

File tree

2 files changed

+43
-8
lines changed

2 files changed

+43
-8
lines changed

lib/internal/Magento/Framework/App/Test/Unit/View/Asset/PublisherTest.php

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All rights reserved.
55
*/
66
declare(strict_types=1);
77

@@ -115,6 +115,46 @@ public function testPublish()
115115
$this->assertTrue($this->object->publish($this->getAsset()));
116116
}
117117

118+
public function testPublishWithSourceFileNewer()
119+
{
120+
$this->staticDirRead->expects($this->once())
121+
->method('isExist')
122+
->with('some/file.ext')
123+
->willReturn(true);
124+
$this->staticDirRead->expects($this->once())
125+
->method('stat')
126+
->with('some/file.ext')
127+
->willReturn(['mtime' => 1000]);
128+
129+
$materializationStrategy =
130+
$this->getMockForAbstractClass(StrategyInterface::class);
131+
132+
$this->materializationStrategyFactory->expects($this->once())
133+
->method('create')
134+
->with($this->getAsset())
135+
->willReturn($materializationStrategy);
136+
$materializationStrategy->expects($this->once())
137+
->method('publishFile')
138+
->with($this->sourceDirWrite, $this->staticDirWrite, 'file.ext', 'some/file.ext')
139+
->willReturn(true);
140+
141+
$this->assertTrue($this->object->publish($this->getAsset()));
142+
}
143+
144+
public function testPublishWithSourceFileOlder()
145+
{
146+
$this->staticDirRead->expects($this->once())
147+
->method('isExist')
148+
->with('some/file.ext')
149+
->willReturn(true);
150+
$this->staticDirRead->expects($this->once())
151+
->method('stat')
152+
->with('some/file.ext')
153+
->willReturn(['mtime' => 0]);
154+
155+
$this->assertTrue($this->object->publish($this->getAsset()));
156+
}
157+
118158
/**
119159
* Create an asset mock
120160
*

lib/internal/Magento/Framework/App/View/Asset/Publisher.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,11 @@ private function isSourceFileNewer(Asset\LocalInterface $asset, $dir, $targetPat
7979
{
8080
$sourceFile = $asset->getSourceFile();
8181

82-
// Check if source file exists
83-
if (!file_exists($sourceFile)) {
84-
return false;
85-
}
86-
8782
$sourceMtime = $this->getFileModificationTime($sourceFile);
8883
$targetStat = $dir->stat($targetPath);
8984
$targetMtime = $targetStat['mtime'] ?? 0;
9085

91-
return $sourceMtime > $targetMtime;
86+
return ($sourceMtime > $targetMtime) || ($sourceMtime === 0 && $targetMtime > 0);
9287
}
9388

9489
/**

0 commit comments

Comments
 (0)