diff --git a/src/Symfony/Component/Config/Resource/FileResource.php b/src/Symfony/Component/Config/Resource/FileResource.php index b828e7d37f..4c00ae4140 100644 --- a/src/Symfony/Component/Config/Resource/FileResource.php +++ b/src/Symfony/Component/Config/Resource/FileResource.php @@ -60,7 +60,7 @@ class FileResource implements ResourceInterface, \Serializable return false; } - return filemtime($this->resource) < $timestamp; + return filemtime($this->resource) <= $timestamp; } public function serialize() diff --git a/src/Symfony/Component/Config/Tests/ConfigCacheTest.php b/src/Symfony/Component/Config/Tests/ConfigCacheTest.php index 27434f13c9..8508763185 100644 --- a/src/Symfony/Component/Config/Tests/ConfigCacheTest.php +++ b/src/Symfony/Component/Config/Tests/ConfigCacheTest.php @@ -128,7 +128,7 @@ class ConfigCacheTest extends \PHPUnit_Framework_TestCase private function makeCacheStale() { - touch($this->cacheFile, time() - 3600); + touch($this->cacheFile, filemtime($this->resourceFile) - 3600); } private function generateMetaFile() diff --git a/src/Symfony/Component/Config/Tests/Resource/FileResourceTest.php b/src/Symfony/Component/Config/Tests/Resource/FileResourceTest.php index 1f1ddee23f..d152806d0c 100644 --- a/src/Symfony/Component/Config/Tests/Resource/FileResourceTest.php +++ b/src/Symfony/Component/Config/Tests/Resource/FileResourceTest.php @@ -17,11 +17,13 @@ class FileResourceTest extends \PHPUnit_Framework_TestCase { protected $resource; protected $file; + protected $time; protected function setUp() { $this->file = realpath(sys_get_temp_dir()).'/tmp.xml'; - touch($this->file); + $this->time = time(); + touch($this->file, $this->time); $this->resource = new FileResource($this->file); } @@ -42,11 +44,12 @@ class FileResourceTest extends \PHPUnit_Framework_TestCase public function testIsFresh() { - $this->assertTrue($this->resource->isFresh(time() + 10), '->isFresh() returns true if the resource has not changed'); - $this->assertFalse($this->resource->isFresh(time() - 86400), '->isFresh() returns false if the resource has been updated'); + $this->assertTrue($this->resource->isFresh($this->time), '->isFresh() returns true if the resource has not changed in same second'); + $this->assertTrue($this->resource->isFresh($this->time + 10), '->isFresh() returns true if the resource has not changed'); + $this->assertFalse($this->resource->isFresh($this->time - 86400), '->isFresh() returns false if the resource has been updated'); $resource = new FileResource('/____foo/foobar'.rand(1, 999999)); - $this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if the resource does not exist'); + $this->assertFalse($resource->isFresh($this->time), '->isFresh() returns false if the resource does not exist'); } public function testSerializeUnserialize()