class vfsStreamUmaskTestCase in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamUmaskTestCase.php \org\bovigo\vfs\vfsStreamUmaskTestCase
Test for umask settings.
@group permissions @group umask @since 0.8.0
Hierarchy
- class \org\bovigo\vfs\vfsStreamUmaskTestCase extends \org\bovigo\vfs\PHPUnit_Framework_TestCase
Expanded class hierarchy of vfsStreamUmaskTestCase
File
- vendor/
mikey179/ vfsStream/ src/ test/ php/ org/ bovigo/ vfs/ vfsStreamUmaskTestCase.php, line 18
Namespace
org\bovigo\vfsView source
class vfsStreamUmaskTestCase extends \PHPUnit_Framework_TestCase {
/**
* set up test environment
*/
public function setUp() {
vfsStream::umask(00);
}
/**
* clean up test environment
*/
public function tearDown() {
vfsStream::umask(00);
}
/**
* @test
*/
public function gettingUmaskSettingDoesNotChangeUmaskSetting() {
$this
->assertEquals(vfsStream::umask(), vfsStream::umask());
$this
->assertEquals(00, vfsStream::umask());
}
/**
* @test
*/
public function changingUmaskSettingReturnsOldUmaskSetting() {
$this
->assertEquals(00, vfsStream::umask(022));
$this
->assertEquals(022, vfsStream::umask());
}
/**
* @test
*/
public function createFileWithDefaultUmaskSetting() {
$file = new vfsStreamFile('foo');
$this
->assertEquals(0666, $file
->getPermissions());
}
/**
* @test
*/
public function createFileWithDifferentUmaskSetting() {
vfsStream::umask(022);
$file = new vfsStreamFile('foo');
$this
->assertEquals(0644, $file
->getPermissions());
}
/**
* @test
*/
public function createDirectoryWithDefaultUmaskSetting() {
$directory = new vfsStreamDirectory('foo');
$this
->assertEquals(0777, $directory
->getPermissions());
}
/**
* @test
*/
public function createDirectoryWithDifferentUmaskSetting() {
vfsStream::umask(022);
$directory = new vfsStreamDirectory('foo');
$this
->assertEquals(0755, $directory
->getPermissions());
}
/**
* @test
*/
public function createFileUsingStreamWithDefaultUmaskSetting() {
$root = vfsStream::setup();
file_put_contents(vfsStream::url('root/newfile.txt'), 'file content');
$this
->assertEquals(0666, $root
->getChild('newfile.txt')
->getPermissions());
}
/**
* @test
*/
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());
}
/**
* @test
*/
public function createDirectoryUsingStreamWithDefaultUmaskSetting() {
$root = vfsStream::setup();
mkdir(vfsStream::url('root/newdir'));
$this
->assertEquals(0777, $root
->getChild('newdir')
->getPermissions());
}
/**
* @test
*/
public function createDirectoryUsingStreamWithDifferentUmaskSetting() {
$root = vfsStream::setup();
vfsStream::umask(022);
mkdir(vfsStream::url('root/newdir'));
$this
->assertEquals(0755, $root
->getChild('newdir')
->getPermissions());
}
/**
* @test
*/
public function createDirectoryUsingStreamWithExplicit0() {
$root = vfsStream::setup();
vfsStream::umask(022);
mkdir(vfsStream::url('root/newdir'), null);
$this
->assertEquals(00, $root
->getChild('newdir')
->getPermissions());
}
/**
* @test
*
*/
public function createDirectoryUsingStreamWithDifferentUmaskSettingButExplicit0777() {
$root = vfsStream::setup();
vfsStream::umask(022);
mkdir(vfsStream::url('root/newdir'), 0777);
$this
->assertEquals(0755, $root
->getChild('newdir')
->getPermissions());
}
/**
* @test
*/
public function createDirectoryUsingStreamWithDifferentUmaskSettingButExplicitModeRequestedByCall() {
$root = vfsStream::setup();
vfsStream::umask(022);
mkdir(vfsStream::url('root/newdir'), 0700);
$this
->assertEquals(0700, $root
->getChild('newdir')
->getPermissions());
}
/**
* @test
*/
public function defaultUmaskSettingDoesNotInfluenceSetup() {
$root = vfsStream::setup();
$this
->assertEquals(0777, $root
->getPermissions());
}
/**
* @test
*/
public function umaskSettingShouldBeRespectedBySetup() {
vfsStream::umask(022);
$root = vfsStream::setup();
$this
->assertEquals(0755, $root
->getPermissions());
}
}