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)
60
60
return false ;
61
61
}
62
62
63
- return filemtime ($ this ->resource ) < $ timestamp ;
63
+ return filemtime ($ this ->resource ) <= $ timestamp ;
64
64
}
65
65
66
66
public function serialize ()
Original file line number Diff line number Diff line change @@ -128,7 +128,7 @@ private function makeCacheFresh()
128
128
129
129
private function makeCacheStale ()
130
130
{
131
- touch ($ this ->cacheFile , time ( ) - 3600 );
131
+ touch ($ this ->cacheFile , filemtime ( $ this -> resourceFile ) - 3600 );
132
132
}
133
133
134
134
private function generateMetaFile ()
Original file line number Diff line number Diff line change @@ -17,11 +17,13 @@ class FileResourceTest extends \PHPUnit_Framework_TestCase
17
17
{
18
18
protected $ resource ;
19
19
protected $ file ;
20
+ protected $ time ;
20
21
21
22
protected function setUp ()
22
23
{
23
24
$ this ->file = realpath (sys_get_temp_dir ()).'/tmp.xml ' ;
24
- touch ($ this ->file );
25
+ $ this ->time = time ();
26
+ touch ($ this ->file , $ this ->time );
25
27
$ this ->resource = new FileResource ($ this ->file );
26
28
}
27
29
@@ -42,11 +44,12 @@ public function testToString()
42
44
43
45
public function testIsFresh ()
44
46
{
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 ' );
47
50
48
51
$ 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 ' );
50
53
}
51
54
52
55
public function testSerializeUnserialize ()
You can’t perform that action at this time.
0 commit comments