diff --git a/src/Filesystem.php b/src/Filesystem.php index f86f144b..37050ae0 100644 --- a/src/Filesystem.php +++ b/src/Filesystem.php @@ -113,7 +113,10 @@ public function constructLink($path) */ public function getContents($filename) { - return $this->file($filename)->getContents(); + $file = $this->file($filename); + return $file->exists()->then(function () use ($file) { + return $file->getContents(); + }); } /** diff --git a/tests/FilesystemTest.php b/tests/FilesystemTest.php index 0798d76b..96e7b036 100644 --- a/tests/FilesystemTest.php +++ b/tests/FilesystemTest.php @@ -4,6 +4,7 @@ use React\Filesystem\Filesystem; use React\Filesystem\InstantInvoker; +use React\Promise\FulfilledPromise; use React\Promise\RejectedPromise; class FilesystemTest extends TestCase @@ -67,6 +68,11 @@ public function testDir() public function testGetContents() { $adapter = $this->mockAdapter(); + $adapter + ->expects($this->any()) + ->method('stat') + ->will($this->returnValue(new FulfilledPromise([]))) + ; $adapter ->expects($this->any()) ->method('open')