Exemplo n.º 1
0
 public function testIsReadable()
 {
     $file = new File('file');
     $ph = new PermissionHelper();
     $ph->setNode($file);
     $file->chmod(00);
     $file->chown(0);
     $file->chgrp(0);
     $this->assertFalse($ph->isReadable(), 'File is not readable root:root 0000');
     $file->chmod(0400);
     $file->chown(0);
     $file->chgrp(0);
     $this->assertFalse($ph->isReadable(), 'File is not readable root:root 0400');
     $file->chmod(040);
     $file->chown(0);
     $file->chgrp(0);
     $this->assertFalse($ph->isReadable(), 'File is not readable root:root 0040');
     $file->chmod(04);
     $file->chown(0);
     $file->chgrp(0);
     $this->assertTrue($ph->isReadable(), 'File is readable root:root 0004');
     $file->chmod(00);
     $file->chown($this->uid);
     $file->chgrp(0);
     $this->assertFalse($ph->isReadable(), 'File is not readable user:root 0000');
     $file->chmod(0400);
     $file->chown($this->uid);
     $file->chgrp(0);
     $this->assertTrue($ph->isReadable(), 'File is readable user:root 0400');
     $file->chmod(040);
     $file->chown($this->uid);
     $file->chgrp(0);
     $this->assertFalse($ph->isReadable(), 'File is not readable user:root 0040');
     $file->chmod(04);
     $file->chown($this->uid);
     $file->chgrp(0);
     $this->assertTrue($ph->isReadable(), 'File is readable user:root 0004');
     $file->chmod(00);
     $file->chown(0);
     $file->chgrp($this->gid);
     $this->assertFalse($ph->isReadable(), 'File is not readable root:user 0000');
     $file->chmod(040);
     $file->chown(0);
     $file->chgrp($this->gid);
     $this->assertTrue($ph->isReadable(), 'File is readable root:user 0040');
     $file->chmod(0400);
     $file->chown(0);
     $file->chgrp($this->gid);
     $this->assertFalse($ph->isReadable(), 'File is not readable root:user 0400');
     $file->chmod(04);
     $file->chown(0);
     $file->chgrp($this->gid);
     $this->assertTrue($ph->isReadable(), 'File is readable root:user 0004');
 }