Security update for Core, with self-updated composer
[yaffs-website] / vendor / symfony / config / Tests / Resource / FileResourceTest.php
index 9e77c9480b4c3e3b74a4bab82d88af4eae4ad43d..97781ffabfcf196414196eb5e56fde1ce54cf72b 100644 (file)
@@ -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()