[Config] Allow schemed path in FileResource
This commit is contained in:
parent
d794f2f267
commit
c73f34d2bc
@ -36,6 +36,10 @@ class FileResource implements SelfCheckingResourceInterface, \Serializable
|
||||
{
|
||||
$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));
|
||||
}
|
||||
|
@ -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);
|
||||
@ -41,6 +41,12 @@ class FileResourceTest extends \PHPUnit_Framework_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);
|
||||
|
Reference in New Issue
Block a user