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