mirror of
https://github.com/adlawson/php-vfs.git
synced 2024-06-02 16:40:52 +00:00
Cover use of file_get_contents
with a directory
This commit is contained in:
parent
b8d8ddf714
commit
e3f60f663e
|
@ -78,6 +78,8 @@ class FileHandle extends AbstractHandle
|
||||||
{
|
{
|
||||||
if (!$this->node) {
|
if (!$this->node) {
|
||||||
throw new UnopenedHandleException($this, $this->url);
|
throw new UnopenedHandleException($this, $this->url);
|
||||||
|
} elseif (!$this->node instanceof FileInterface) {
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $length) {
|
if (null !== $length) {
|
||||||
|
|
|
@ -11,6 +11,11 @@ class FileGetContentsAcceptanceTest extends AcceptanceTestCase
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function testGetDirectory()
|
||||||
|
{
|
||||||
|
$this->assertEquals('', file_get_contents("$this->scheme://foo"));
|
||||||
|
}
|
||||||
|
|
||||||
public function testGetFile()
|
public function testGetFile()
|
||||||
{
|
{
|
||||||
$this->assertEquals($this->tree['foo']['bar'], file_get_contents("$this->scheme://foo/bar"));
|
$this->assertEquals($this->tree['foo']['bar'], file_get_contents("$this->scheme://foo/bar"));
|
||||||
|
|
|
@ -219,6 +219,18 @@ class FileHandleTest extends UnitTestCase
|
||||||
$this->assertEquals($expected, $handle->read($offset, $length));
|
$this->assertEquals($expected, $handle->read($offset, $length));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testReadNonFile()
|
||||||
|
{
|
||||||
|
$handle = new FileHandle($this->fs, 'foo://bar');
|
||||||
|
|
||||||
|
$file = Mockery::mock('Vfs\Node\NodeInterface');
|
||||||
|
|
||||||
|
$this->fs->shouldReceive('get')->once()->with('/bar')->andReturn($file);
|
||||||
|
|
||||||
|
$handle->open();
|
||||||
|
$this->assertEquals('', $handle->read(0, PHP_INT_MAX));
|
||||||
|
}
|
||||||
|
|
||||||
public function testReadThrowsWithoutOpening()
|
public function testReadThrowsWithoutOpening()
|
||||||
{
|
{
|
||||||
$handle = new FileHandle($this->fs, 'foo://bar');
|
$handle = new FileHandle($this->fs, 'foo://bar');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user