Ejemplo n.º 1
0
 public function testIsDirOnDirectorySuccess()
 {
     $protocol = 'mfs';
     $mockFs = new \MockFs\MockFs($protocol);
     $mockFs->getFileSystem()->addDirectory('test', '/directory');
     $this->assertTrue(is_dir($protocol . '://directory/test'));
 }
Ejemplo n.º 2
0
 public function testFileExistsForFileSuccess()
 {
     $protocol = 'mfs';
     $mockFs = new \MockFs\MockFs($protocol);
     $mockFs->getFileSystem()->addFile('test.txt', 'Sample File', '/directory');
     $this->assertTrue(file_exists($protocol . '://directory/test.txt'));
 }
Ejemplo n.º 3
0
 public function testCommandRenameSuccess()
 {
     $protocol = 'mfs';
     $fs = new \MockFs\MockFs($protocol);
     $fs->getFileSystem()->addFile('foo.jpg');
     $success = rename($protocol . '://foo.jpg', $protocol . '://bar.jpg');
     $this->assertTrue($success);
 }
Ejemplo n.º 4
0
 public function testCommandMkdirWithInvalidParentOwner()
 {
     $directoryName = 'Invalid Owner';
     $protocol = 'mfs';
     $mockFs = new \MockFs\MockFs($protocol);
     $mockFs->getFileSystem()->addDirectory($directoryName);
     $directory = $mockFs->getFileSystem()->getChild($directoryName);
     $directory->setPermissions(0700)->setOwnerId(100)->setGroupId(200);
     $this->assertFalse(mkdir('mfs://Invalid Owner/New Directory'));
 }
Ejemplo n.º 5
0
 public function testCommandRmdirSuccess()
 {
     $protocol = 'mfs';
     $mockFs = new \MockFs\MockFs($protocol);
     $mockFs->getFileSystem()->addDirectory('test', '/level 1');
     $this->assertTrue($mockFs->getFileSystem()->hasChildByPath('/level 1/test'));
     rmdir($protocol . '://' . 'level 1/test');
     $this->assertTrue($mockFs->getFileSystem()->hasChildByPath('level 1'));
     $this->assertFalse($mockFs->getFileSystem()->hasChildByPath('level 1/test'));
 }
Ejemplo n.º 6
0
 public function testFoldersParentLockedToOnlyReadableByOwnerFails()
 {
     $this->markTestSkipped('Have to work out how to factor this');
     $protocol = 'mfs';
     $mockFs = new \MockFs\MockFs($protocol);
     $mockFs->getFileSystem()->addDirectory('test', '/directory');
     $directory = $mockFs->getFileSystem()->getChildByPath('/directory');
     $directory->setOwnerId(100);
     $directory->setPermissions(0600);
     $this->assertFalse(is_readable($protocol . '://directory/test'));
 }
Ejemplo n.º 7
0
 public function testGetFileSystem()
 {
     $mockFs = new \MockFs\MockFs();
     $this->assertInstanceOf('MockFs\\Object\\FileSystem', $mockFs->getFileSystem());
 }