Merge pull request #16 from adlawson/basic-permissions

Set basic permission bits
This commit is contained in:
Andrew Lawson 2015-08-03 20:21:26 +01:00
commit 75e2fde9b7
5 changed files with 48 additions and 4 deletions

View File

@ -30,7 +30,7 @@ class Directory implements NodeContainerInterface
*/
public function __construct(array $nodes = [])
{
$this->mode = self::TYPE_DIR;
$this->mode = self::TYPE_DIR | self::OTHER_FULL;
$this->dateAccessed = new DateTime();
$this->dateCreated = $this->dateAccessed;

View File

@ -25,7 +25,7 @@ class DirectoryLink implements NodeContainerInterface, LinkInterface
public function __construct(NodeContainerInterface $directory)
{
$this->directory = $directory;
$this->mode = self::TYPE_LINK;
$this->mode = self::TYPE_LINK | self::OTHER_FULL;
$this->dateAccessed = new DateTime();
$this->dateCreated = clone $this->dateAccessed;

View File

@ -25,7 +25,7 @@ class File implements FileInterface
public function __construct($content = '')
{
$this->content = (string) $content;
$this->mode = self::TYPE_FILE;
$this->mode = self::TYPE_FILE | self::OTHER_FULL;
$this->dateAccessed = new DateTime();
$this->dateCreated = clone $this->dateAccessed;

View File

@ -25,7 +25,7 @@ class FileLink implements FileInterface, LinkInterface
public function __construct(FileInterface $file)
{
$this->file = $file;
$this->mode = self::TYPE_LINK;
$this->mode = self::TYPE_LINK | self::OTHER_FULL;
$this->dateAccessed = new DateTime();
$this->dateCreated = clone $this->dateAccessed;

View File

@ -0,0 +1,44 @@
<?php
namespace Vfs\Stream\StreamWrapper;
use Vfs\Test\AcceptanceTestCase;
class PermissionAcceptanceTest extends AcceptanceTestCase
{
protected $tree = [
'foo' => [
'bar' => 'baz'
]
];
public function testDirIsReadable()
{
$this->assertTrue(is_readable("$this->scheme:///foo"));
}
public function testDirIsWritable()
{
$this->assertTrue(is_writable("$this->scheme:///foo"));
}
public function testDirIsExecutable()
{
// Directory can't be executable
$this->assertFalse(is_executable("$this->scheme:///foo"));
}
public function testFileIsReadable()
{
$this->assertTrue(is_readable("$this->scheme:///foo/bar"));
}
public function testFileIsWritable()
{
$this->assertTrue(is_writable("$this->scheme:///foo/bar"));
}
public function testFileIsExecutable()
{
$this->assertTrue(is_executable("$this->scheme:///foo/bar"));
}
}