Added the Search API Synonym module to deal specifically with licence and license...
[yaffs-website] / vendor / symfony / config / Tests / Resource / DirectoryResourceTest.php
index 60bd616a41de5d842c4a4fb99a72c4ef2c560f71..cf20e43b50027315691ec717d508204ef182745f 100644 (file)
@@ -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)));
     }
 }