From 9fe0d00735b737fb391f3b2b6a365674569e0b63 Mon Sep 17 00:00:00 2001 From: everzet Date: Fri, 25 Nov 2011 14:48:15 +0100 Subject: [PATCH] [Config] update FileResourceTest --- .../Tests/Resource/FileResourceTest.php | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Component/Config/Tests/Resource/FileResourceTest.php b/src/Symfony/Component/Config/Tests/Resource/FileResourceTest.php index 1c5fa4253b..236dfabf8f 100644 --- a/src/Symfony/Component/Config/Tests/Resource/FileResourceTest.php +++ b/src/Symfony/Component/Config/Tests/Resource/FileResourceTest.php @@ -27,7 +27,9 @@ class FileResourceTest extends \PHPUnit_Framework_TestCase protected function tearDown() { - unlink($this->file); + if ($this->file) { + unlink($this->file); + } } /** @@ -50,22 +52,25 @@ class FileResourceTest extends \PHPUnit_Framework_TestCase $this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if the resource does not exist'); } - /** - * @covers Symfony\Component\Config\Resource\FileResource::exists - */ - public function testExists() - { - $this->assertTrue($this->resource->exists(), '->exists() returns true if the resource does exist'); - - $resource = new FileResource('/____foo/foobar'.rand(1, 999999)); - $this->assertFalse($resource->exists(), '->exists() returns false if the resource does not exist'); - } - /** * @covers Symfony\Component\Config\Resource\FileResource::getModificationTime */ public function testGetModificationTime() { - $this->assertSame(filemtime($this->resource->getResource()), $this->resource->getModificationTime()); + touch($this->file, $time = time() + 100); + $this->assertSame($time, $this->resource->getModificationTime()); + } + + /** + * @covers Symfony\Component\Config\Resource\FileResource::exists + */ + public function testExists() + { + $this->assertTrue($this->resource->exists(), '->exists() returns true if the resource exists'); + + unlink($this->file); + $this->file = null; + + $this->assertFalse($this->resource->exists(), '->exists() returns false if the resource does not exists'); } }