예제 #1
0
 /**
  * testCreate method
  *
  * @return void
  */
 public function testCreate()
 {
     $tmpFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'tests/coretyson.file.test.tmp';
     $file = new File($tmpFile, true, 0777);
     $this->assertTrue($file->exists());
     $this->assertFileExists($tmpFile);
     $file->delete();
     $file = new File($tmpFile, false, 0777);
     $file->create();
     $this->assertTrue($file->exists());
     $this->assertFileExists($tmpFile);
 }
예제 #2
0
 /**
  * testChmod method
  *
  * @return void
  */
 public function testChmod()
 {
     $this->skipIf(DS === '\\', 'Folder permissions tests not supported on Windows.');
     $path = TMP . 'tests/';
     $Folder = new Folder($path);
     $subdir = 'test_folder_new';
     $new = $path . $subdir;
     $this->assertTrue($Folder->create($new));
     $this->assertTrue($Folder->create($new . DS . 'test1'));
     $this->assertTrue($Folder->create($new . DS . 'test2'));
     $filePath = $new . DS . 'test1.php';
     $File = new File($filePath);
     $this->assertTrue($File->create());
     $filePath = $new . DS . 'skip_me.php';
     $File = new File($filePath);
     $this->assertTrue($File->create());
     $this->assertTrue($Folder->chmod($new, 0755, true));
     $perms = substr(sprintf('%o', fileperms($new . DS . 'test2')), -4);
     $this->assertEquals('0755', $perms);
     $this->assertTrue($Folder->chmod($new, 0744, true, ['skip_me.php', 'test2']));
     $perms = substr(sprintf('%o', fileperms($new . DS . 'test2')), -4);
     $this->assertEquals('0755', $perms);
     $perms = substr(sprintf('%o', fileperms($new . DS . 'test1')), -4);
     $this->assertEquals('0744', $perms);
 }