Skip to content

Commit 87800ae

Browse files
committed
minor #13377 [Console] Change greater by greater or equal for isFresh in FileResource
1 parent 19aa6dc commit 87800ae

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/Symfony/Component/Config/Resource/FileResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function isFresh($timestamp)
6060
return false;
6161
}
6262

63-
return filemtime($this->resource) < $timestamp;
63+
return filemtime($this->resource) <= $timestamp;
6464
}
6565

6666
public function serialize()

src/Symfony/Component/Config/Tests/ConfigCacheTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ private function makeCacheFresh()
128128

129129
private function makeCacheStale()
130130
{
131-
touch($this->cacheFile, time() - 3600);
131+
touch($this->cacheFile, filemtime($this->resourceFile) - 3600);
132132
}
133133

134134
private function generateMetaFile()

src/Symfony/Component/Config/Tests/Resource/FileResourceTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ class FileResourceTest extends \PHPUnit_Framework_TestCase
1717
{
1818
protected $resource;
1919
protected $file;
20+
protected $time;
2021

2122
protected function setUp()
2223
{
2324
$this->file = realpath(sys_get_temp_dir()).'/tmp.xml';
24-
touch($this->file);
25+
$this->time = time();
26+
touch($this->file, $this->time);
2527
$this->resource = new FileResource($this->file);
2628
}
2729

@@ -42,11 +44,12 @@ public function testToString()
4244

4345
public function testIsFresh()
4446
{
45-
$this->assertTrue($this->resource->isFresh(time() + 10), '->isFresh() returns true if the resource has not changed');
46-
$this->assertFalse($this->resource->isFresh(time() - 86400), '->isFresh() returns false if the resource has been updated');
47+
$this->assertTrue($this->resource->isFresh($this->time), '->isFresh() returns true if the resource has not changed in same second');
48+
$this->assertTrue($this->resource->isFresh($this->time + 10), '->isFresh() returns true if the resource has not changed');
49+
$this->assertFalse($this->resource->isFresh($this->time - 86400), '->isFresh() returns false if the resource has been updated');
4750

4851
$resource = new FileResource('/____foo/foobar'.rand(1, 999999));
49-
$this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if the resource does not exist');
52+
$this->assertFalse($resource->isFresh($this->time), '->isFresh() returns false if the resource does not exist');
5053
}
5154

5255
public function testSerializeUnserialize()

0 commit comments

Comments
 (0)