You are here

class vfsStreamUmaskTestCase in Zircon Profile 8

Same name and namespace in other branches
  1. 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

Expanded class hierarchy of vfsStreamUmaskTestCase

File

vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamUmaskTestCase.php, line 18

Namespace

org\bovigo\vfs
View 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());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
vfsStreamUmaskTestCase::changingUmaskSettingReturnsOldUmaskSetting public function @test
vfsStreamUmaskTestCase::createDirectoryUsingStreamWithDefaultUmaskSetting public function @test
vfsStreamUmaskTestCase::createDirectoryUsingStreamWithDifferentUmaskSetting public function @test
vfsStreamUmaskTestCase::createDirectoryUsingStreamWithDifferentUmaskSettingButExplicit0777 public function @test
vfsStreamUmaskTestCase::createDirectoryUsingStreamWithDifferentUmaskSettingButExplicitModeRequestedByCall public function @test
vfsStreamUmaskTestCase::createDirectoryUsingStreamWithExplicit0 public function @test
vfsStreamUmaskTestCase::createDirectoryWithDefaultUmaskSetting public function @test
vfsStreamUmaskTestCase::createDirectoryWithDifferentUmaskSetting public function @test
vfsStreamUmaskTestCase::createFileUsingStreamWithDefaultUmaskSetting public function @test
vfsStreamUmaskTestCase::createFileUsingStreamWithDifferentUmaskSetting public function @test
vfsStreamUmaskTestCase::createFileWithDefaultUmaskSetting public function @test
vfsStreamUmaskTestCase::createFileWithDifferentUmaskSetting public function @test
vfsStreamUmaskTestCase::defaultUmaskSettingDoesNotInfluenceSetup public function @test
vfsStreamUmaskTestCase::gettingUmaskSettingDoesNotChangeUmaskSetting public function @test
vfsStreamUmaskTestCase::setUp public function set up test environment
vfsStreamUmaskTestCase::tearDown public function clean up test environment
vfsStreamUmaskTestCase::umaskSettingShouldBeRespectedBySetup public function @test