10000 [Config] Allow schemed paths in FileResource by nicolas-grekas · Pull Request #18820 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Config] Allow schemed paths in FileResource #18820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Symfony/Component/Config/Resource/FileResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public function __construct($resource)
{
$this->resource = realpath($resource);

if (false === $this->resource && file_exists($resource)) {
$this->resource = $resource;
}

if (false === $this->resource) {
throw new \InvalidArgumentException(sprintf('The file "%s" does not exist.', $resource));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FileResourceTest extends \PHPUnit_Framework_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);
Expand All @@ -41,6 +41,12 @@ public function testGetResource()
$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);
Expand Down
0