X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fsymfony%2Fconfig%2FTests%2FResource%2FDirectoryResourceTest.php;h=cf20e43b50027315691ec717d508204ef182745f;hb=4e1bfbf98b844da83b18aca92ef00f11a4735806;hp=60bd616a41de5d842c4a4fb99a72c4ef2c560f71;hpb=eba34333e3c89f208d2f72fa91351ad019a71583;p=yaffs-website diff --git a/vendor/symfony/config/Tests/Resource/DirectoryResourceTest.php b/vendor/symfony/config/Tests/Resource/DirectoryResourceTest.php index 60bd616a4..cf20e43b5 100644 --- a/vendor/symfony/config/Tests/Resource/DirectoryResourceTest.php +++ b/vendor/symfony/config/Tests/Resource/DirectoryResourceTest.php @@ -20,7 +20,7 @@ class DirectoryResourceTest extends TestCase protected function setUp() { - $this->directory = sys_get_temp_dir().DIRECTORY_SEPARATOR.'symfonyDirectoryIterator'; + $this->directory = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'symfonyDirectoryIterator'; if (!file_exists($this->directory)) { mkdir($this->directory); } @@ -54,22 +54,36 @@ class DirectoryResourceTest extends TestCase public function testGetResource() { $resource = new DirectoryResource($this->directory); - $this->assertSame($this->directory, $resource->getResource(), '->getResource() returns the path to the resource'); + $this->assertSame(realpath($this->directory), $resource->getResource(), '->getResource() returns the path to the resource'); } public function testGetPattern() { - $resource = new DirectoryResource('foo', 'bar'); + $resource = new DirectoryResource($this->directory, 'bar'); $this->assertEquals('bar', $resource->getPattern()); } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessageRegExp /The directory ".*" does not exist./ + */ + public function testResourceDoesNotExist() + { + $resource = new DirectoryResource('/____foo/foobar'.mt_rand(1, 999999)); + } + public function testIsFresh() { $resource = new DirectoryResource($this->directory); $this->assertTrue($resource->isFresh(time() + 10), '->isFresh() returns true if the resource has not changed'); $this->assertFalse($resource->isFresh(time() - 86400), '->isFresh() returns false if the resource has been updated'); + } + + public function testIsFreshForDeletedResources() + { + $resource = new DirectoryResource($this->directory); + $this->removeDirectory($this->directory); - $resource = new DirectoryResource('/____foo/foobar'.mt_rand(1, 999999)); $this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if the resource does not exist'); } @@ -155,7 +169,7 @@ class DirectoryResourceTest extends TestCase $unserialized = unserialize(serialize($resource)); - $this->assertSame($this->directory, $resource->getResource()); + $this->assertSame(realpath($this->directory), $resource->getResource()); $this->assertSame('/\.(foo|xml)$/', $resource->getPattern()); } @@ -164,6 +178,6 @@ class DirectoryResourceTest extends TestCase $resourceA = new DirectoryResource($this->directory, '/.xml$/'); $resourceB = new DirectoryResource($this->directory, '/.yaml$/'); - $this->assertEquals(2, count(array_unique(array($resourceA, $resourceB)))); + $this->assertCount(2, array_unique(array($resourceA, $resourceB))); } }