Esempio n. 1
0
 public function testGroupPermissionsAreCalculatedCorrectly()
 {
     $file = new File('file');
     $file->chgrp($this->gid);
     $ph = new PermissionHelper();
     $ph->setNode($file);
     $file->chmod(00);
     $this->assertFalse($ph->groupCanRead(), 'group can\'t read with 0000');
     $this->assertFalse($ph->groupCanWrite(), 'group can\'t write with 0000');
     $file->chmod(010);
     $this->assertFalse($ph->groupCanRead(), 'group can\'t read with 0010');
     $this->assertFalse($ph->groupCanWrite(), 'group can\'t write with 0010');
     $file->chmod(020);
     $this->assertFalse($ph->groupCanRead(), 'group can\'t read with 0020');
     $this->assertTrue($ph->groupCanWrite(), 'group can write with 0020');
     $file->chmod(040);
     $this->assertTrue($ph->groupCanRead(), 'group can read with 0040');
     $this->assertFalse($ph->groupCanWrite(), 'group can\'t write with 0040');
     $file->chmod(050);
     $this->assertTrue($ph->groupCanRead(), 'group can read with 0050');
     $this->assertFalse($ph->groupCanWrite(), 'group can\'t write with 0050');
     $file->chmod(060);
     $this->assertTrue($ph->groupCanRead(), 'group can read with 0060');
     $this->assertTrue($ph->groupCanWrite(), 'group can read with 0060');
     $file->chgrp(0);
     $file->chmod(0666);
     $this->assertFalse($ph->groupCanRead(), 'group can\'t read without ownership');
     $this->assertFalse($ph->groupCanWrite(), 'group can\'t without ownership');
 }
Esempio n. 2
0
 public function testOffsetPositionMovesPointerCorrectly()
 {
     $file = new File('/file');
     $file->setData('data');
     $handler = new FileHandler();
     $handler->setFile($file);
     $handler->offsetPosition(2);
     $this->assertEquals(2, $handler->position());
     $handler->offsetPosition(2);
     $this->assertEquals(4, $handler->position());
 }
Esempio n. 3
0
 /**
  * Removed all data from file and sets pointer to 0
  *
  * @param int $new_size
  *
  * @return void
  */
 public function truncate($new_size = 0)
 {
     $this->position(0);
     $newData = substr($this->file->data(), 0, $new_size);
     $newData = false === $newData ? '' : $newData;
     $this->file->setData($newData);
     $this->file->setModificationTime(time());
     $this->file->setChangeTime(time());
     return;
 }