8000 [Config] Allow schemed path in FileResource · symfony/symfony@c73f34d · GitHub
[go: up one dir, main page]

Skip to content

Commit c73f34d

Browse files
[Config] Allow schemed path in FileResource
1 parent d794f2f commit c73f34d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Symfony/Component/Config/Resource/FileResource.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ public function __construct($resource)
3636
{
3737
$this->resource = realpath($resource);
3838

39+
if (false === $this->resource && file_exists($resource)) {
40+
$this->resource = $resource;
41+
}
42+
3943
if (false === $this->resource) {
4044
throw new \InvalidArgumentException(sprintf('The file "%s" does not exist.', $resource));
4145
}

src/Symfony/Component/Config/Tests/Resource/FileResourceTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class FileResourceTest extends \PHPUnit_Framework_TestCase
2121

2222
protected function setUp()
2323
{
24-
$this->file = realpath(sys_get_temp_dir()).'/tmp.xml';
24+
$this->file = sys_get_temp_dir().'/tmp.xml';
2525
$this->time = time();
2626
touch($this->file, $this->time);
2727
$this->resource = new FileResource($this->file);
@@ -41,6 +41,12 @@ public function testGetResource()
4141
$this->assertSame(realpath($this->file), $this->resource->getResource(), '->getResource() returns the path to the resource');
4242
}
4343

44+
public function testGetResourceWithScheme()
45+
{
46+
$resource = new FileResource('file://'.$this->file);
47+
$this->assertSame('file://'.$this->file, $resource->getResource(), '->getResource() returns the path to the schemed resource');
48+
}
49+
4450
public function testToString()
4551
{
4652
$this->assertSame(realpath($this->file), (string) $this->resource);

0 commit comments

Comments
 (0)
0