Skip to content
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

[5.3] Adding Filesystem::isReadable() #15289

Merged
merged 1 commit into from
Sep 6, 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
11 changes: 11 additions & 0 deletions src/Illuminate/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
11 changes: 11 additions & 0 deletions tests/Filesystem/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,17 @@ public function testIsWritable()
$this->assertTrue($files->isWritable($this->tempDir.'/foo.txt'));
}

public function testIsReadable()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is not strong enough since it past before when the implementation was wrong. Make sure the test files arn't writable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmmm, what do you suggest?

{
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');
Expand Down