vfsStreamUmaskTestCase.php in Zircon Profile 8
File
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamUmaskTestCase.php
View source
<?php
namespace org\bovigo\vfs;
class vfsStreamUmaskTestCase extends \PHPUnit_Framework_TestCase {
public function setUp() {
vfsStream::umask(00);
}
public function tearDown() {
vfsStream::umask(00);
}
public function gettingUmaskSettingDoesNotChangeUmaskSetting() {
$this
->assertEquals(vfsStream::umask(), vfsStream::umask());
$this
->assertEquals(00, vfsStream::umask());
}
public function changingUmaskSettingReturnsOldUmaskSetting() {
$this
->assertEquals(00, vfsStream::umask(022));
$this
->assertEquals(022, vfsStream::umask());
}
public function createFileWithDefaultUmaskSetting() {
$file = new vfsStreamFile('foo');
$this
->assertEquals(0666, $file
->getPermissions());
}
public function createFileWithDifferentUmaskSetting() {
vfsStream::umask(022);
$file = new vfsStreamFile('foo');
$this
->assertEquals(0644, $file
->getPermissions());
}
public function createDirectoryWithDefaultUmaskSetting() {
$directory = new vfsStreamDirectory('foo');
$this
->assertEquals(0777, $directory
->getPermissions());
}
public function createDirectoryWithDifferentUmaskSetting() {
vfsStream::umask(022);
$directory = new vfsStreamDirectory('foo');
$this
->assertEquals(0755, $directory
->getPermissions());
}
public function createFileUsingStreamWithDefaultUmaskSetting() {
$root = vfsStream::setup();
file_put_contents(vfsStream::url('root/newfile.txt'), 'file content');
$this
->assertEquals(0666, $root
->getChild('newfile.txt')
->getPermissions());
}
public function createFileUsingStreamWithDifferentUmaskSetting() {
$root = vfsStream::setup();
vfsStream::umask(022);
file_put_contents(vfsStream::url('root/newfile.txt'), 'file content');
$this
->assertEquals(0644, $root
->getChild('newfile.txt')
->getPermissions());
}
public function createDirectoryUsingStreamWithDefaultUmaskSetting() {
$root = vfsStream::setup();
mkdir(vfsStream::url('root/newdir'));
$this
->assertEquals(0777, $root
->getChild('newdir')
->getPermissions());
}
public function createDirectoryUsingStreamWithDifferentUmaskSetting() {
$root = vfsStream::setup();
vfsStream::umask(022);
mkdir(vfsStream::url('root/newdir'));
$this
->assertEquals(0755, $root
->getChild('newdir')
->getPermissions());
}
public function createDirectoryUsingStreamWithExplicit0() {
$root = vfsStream::setup();
vfsStream::umask(022);
mkdir(vfsStream::url('root/newdir'), null);
$this
->assertEquals(00, $root
->getChild('newdir')
->getPermissions());
}
public function createDirectoryUsingStreamWithDifferentUmaskSettingButExplicit0777() {
$root = vfsStream::setup();
vfsStream::umask(022);
mkdir(vfsStream::url('root/newdir'), 0777);
$this
->assertEquals(0755, $root
->getChild('newdir')
->getPermissions());
}
public function createDirectoryUsingStreamWithDifferentUmaskSettingButExplicitModeRequestedByCall() {
$root = vfsStream::setup();
vfsStream::umask(022);
mkdir(vfsStream::url('root/newdir'), 0700);
$this
->assertEquals(0700, $root
->getChild('newdir')
->getPermissions());
}
public function defaultUmaskSettingDoesNotInfluenceSetup() {
$root = vfsStream::setup();
$this
->assertEquals(0777, $root
->getPermissions());
}
public function umaskSettingShouldBeRespectedBySetup() {
vfsStream::umask(022);
$root = vfsStream::setup();
$this
->assertEquals(0755, $root
->getPermissions());
}
}