/**
  * @test
  */
 public function testSetChmod()
 {
     $file = new Filesystem();
     // Test 0755
     $dir = static::getTempPath(__FUNCTION__);
     $file1 = rand(1, 10) . rand(0, getrandmax());
     $filepath1 = $dir . DIRECTORY_SEPARATOR . $file1;
     mkdir($dir);
     file_put_contents($filepath1, __FUNCTION__, FILE_APPEND);
     $this->assertEquals(true, $file->setChmod($filepath1, 0755));
     $this->assertEquals(755, $file->getFileSystemInfo($filepath1)->getFilePermission());
     // Test 0644
     $dir2 = static::getTempPath(__FUNCTION__);
     $file2 = rand(1, 10) . rand(0, getrandmax());
     $filepath2 = $dir2 . DIRECTORY_SEPARATOR . $file2;
     mkdir($dir2);
     file_put_contents($filepath2, __FUNCTION__, FILE_APPEND);
     $this->assertEquals(true, $file->setChmod($filepath2, 0644));
     $this->assertEquals(644, $file->getFileSystemInfo($filepath2)->getFilePermission());
     // CHMOD 0755
     $dir3 = static::getTempPath(__FUNCTION__);
     $file3 = rand(1, 10) . rand(0, getrandmax());
     $filepath3 = $dir3 . DIRECTORY_SEPARATOR . $file3;
     mkdir($dir3);
     file_put_contents($filepath3, __FUNCTION__, FILE_APPEND);
     $file->setChmod($filepath3, 0755);
     $this->assertEquals(755, $file->getFileSystemInfo($filepath3)->getFilePermission());
     // CHMOD 511 octal
     $dir4 = static::getTempPath(__FUNCTION__);
     $file4 = rand(1, 10) . rand(0, getrandmax());
     $filepath4 = $dir4 . DIRECTORY_SEPARATOR . $file4;
     mkdir($dir4);
     file_put_contents($filepath4, __FUNCTION__, FILE_APPEND);
     // those `511` is octal as `0777`. `511` is octal
     $file->setChmod($filepath4, 511);
     $this->assertEquals(777, $file->getFileSystemInfo($filepath4)->getFilePermission());
     // Test mode rwxsStT-`chmod($file, 511)`
     $dir5 = static::getTempPath(__FUNCTION__);
     $file5 = rand(1, 10) . rand(0, getrandmax());
     $filepath5 = $dir5 . DIRECTORY_SEPARATOR . $file5;
     mkdir($dir5);
     file_put_contents($filepath5, __FUNCTION__, FILE_APPEND);
     $file->setChmod($filepath5, '-rwxr-xr-x');
     $this->assertEquals(755, $file->getFileSystemInfo($filepath5)->getFilePermission());
     $dir6 = static::getTempPath(__FUNCTION__);
     $file6 = rand(1, 10) . rand(0, getrandmax());
     $filepath6 = $dir6 . DIRECTORY_SEPARATOR . $file6;
     mkdir($dir6);
     file_put_contents($filepath6, __FUNCTION__, FILE_APPEND);
     $file->setChmod($filepath6, '-rw-r--r--');
     $this->assertEquals(644, $file->getFileSystemInfo($filepath6)->getFilePermission());
 }