X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fsymfony%2Fconfig%2FTests%2FResource%2FFileResourceTest.php;h=97781ffabfcf196414196eb5e56fde1ce54cf72b;hb=4e1bfbf98b844da83b18aca92ef00f11a4735806;hp=9e77c9480b4c3e3b74a4bab82d88af4eae4ad43d;hpb=eba34333e3c89f208d2f72fa91351ad019a71583;p=yaffs-website diff --git a/vendor/symfony/config/Tests/Resource/FileResourceTest.php b/vendor/symfony/config/Tests/Resource/FileResourceTest.php index 9e77c9480..97781ffab 100644 --- a/vendor/symfony/config/Tests/Resource/FileResourceTest.php +++ b/vendor/symfony/config/Tests/Resource/FileResourceTest.php @@ -22,7 +22,7 @@ class FileResourceTest extends TestCase protected function setUp() { - $this->file = realpath(sys_get_temp_dir()).'/tmp.xml'; + $this->file = sys_get_temp_dir().'/tmp.xml'; $this->time = time(); touch($this->file, $this->time); $this->resource = new FileResource($this->file); @@ -30,6 +30,10 @@ class FileResourceTest extends TestCase protected function tearDown() { + if (!file_exists($this->file)) { + return; + } + unlink($this->file); } @@ -38,19 +42,38 @@ class FileResourceTest extends TestCase $this->assertSame(realpath($this->file), $this->resource->getResource(), '->getResource() returns the path to the resource'); } + public function testGetResourceWithScheme() + { + $resource = new FileResource('file://'.$this->file); + $this->assertSame('file://'.$this->file, $resource->getResource(), '->getResource() returns the path to the schemed resource'); + } + public function testToString() { $this->assertSame(realpath($this->file), (string) $this->resource); } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessageRegExp /The file ".*" does not exist./ + */ + public function testResourceDoesNotExist() + { + $resource = new FileResource('/____foo/foobar'.mt_rand(1, 999999)); + } + public function testIsFresh() { $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'.mt_rand(1, 999999)); - $this->assertFalse($resource->isFresh($this->time), '->isFresh() returns false if the resource does not exist'); + public function testIsFreshForDeletedResources() + { + unlink($this->file); + + $this->assertFalse($this->resource->isFresh($this->time), '->isFresh() returns false if the resource does not exist'); } public function testSerializeUnserialize()