Пример #1
0
 public function testIsDirOnDirectorySuccess()
 {
     $protocol = 'mfs';
     $mockFs = new \MockFs\MockFs($protocol);
     $mockFs->getFileSystem()->addDirectory('test', '/directory');
     $this->assertTrue(is_dir($protocol . '://directory/test'));
 }
Пример #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'));
 }
Пример #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);
 }
Пример #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'));
 }
Пример #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'));
 }
Пример #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'));
 }
Пример #7
0
 public function testGetFileSystem()
 {
     $mockFs = new \MockFs\MockFs();
     $this->assertInstanceOf('MockFs\\Object\\FileSystem', $mockFs->getFileSystem());
 }