File tree Expand file tree Collapse file tree 3 files changed +9
-6
lines changed
src/Symfony/Component/Config Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Original file line number Diff line number Diff 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 ()
Original file line number Diff line number Diff 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 ()
Original file line number Diff line number Diff 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 ()
You can’t perform that action at this time.
0 commit comments