From 4c0c08c5aef8618f81cbcb508873ce3a4e2e7d15 Mon Sep 17 00:00:00 2001 From: Mohamed Said Date: Tue, 6 Sep 2016 00:50:30 +0200 Subject: [PATCH] This closes #14832 by adding isReadable --- src/Illuminate/Filesystem/Filesystem.php | 11 +++++++++++ tests/Filesystem/FilesystemTest.php | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/Illuminate/Filesystem/Filesystem.php b/src/Illuminate/Filesystem/Filesystem.php index 89a0ad379aa5..260076774e14 100644 --- a/src/Illuminate/Filesystem/Filesystem.php +++ b/src/Illuminate/Filesystem/Filesystem.php @@ -316,6 +316,17 @@ public function isWritable($path) return is_writable($path); } + /** + * Determine if the given path is readable. + * + * @param string $path + * @return bool + */ + public function isReadable($path) + { + return is_readable($path); + } + /** * Determine if the given path is a file. * diff --git a/tests/Filesystem/FilesystemTest.php b/tests/Filesystem/FilesystemTest.php index 8e0199fcb079..04b6dd35b7ee 100755 --- a/tests/Filesystem/FilesystemTest.php +++ b/tests/Filesystem/FilesystemTest.php @@ -267,6 +267,17 @@ public function testIsWritable() $this->assertTrue($files->isWritable($this->tempDir.'/foo.txt')); } + public function testIsReadable() + { + file_put_contents($this->tempDir.'/foo.txt', 'foo'); + $files = new Filesystem(); + @chmod($this->tempDir.'/foo.txt', 0000); + $this->assertFalse($files->isReadable($this->tempDir.'/foo.txt')); + $this->assertFalse($files->isReadable($this->tempDir.'/bar.txt')); + @chmod($this->tempDir.'/foo.txt', 0777); + $this->assertTrue($files->isReadable($this->tempDir.'/foo.txt')); + } + public function testGlobFindsFiles() { file_put_contents($this->tempDir.'/foo.txt', 'foo');