public function testRemove() { $root = new Root(); $root->addDirectory(new Directory('dir1')); $root->remove('dir1'); $this->setExpectedException('\\VirtualFileSystem\\NotFoundException'); $root->childAt('dir1'); }
public function testURLConstruction() { $root = new Root(); $root->setScheme('s://'); $root->addDirectory($dir = new Directory('dir')); $dir->addDirectory($dir = new Directory('dir')); $dir->addFile($file = new File('file')); $this->assertEquals('s://dir/dir/file', $file->url()); }
/** * @param Root $root * * @return Root */ private function hydrateDirectory(Root $root) { $basePath = $root->getBasePath(); foreach ($root->getFileCollection() as $file) { $dirpath = $file->getDirectory($basePath); if ($root->hasDirectory($dirpath)) { $directory = $root->getDirectoryByName($dirpath); } else { $directory = new Directory(); $directory->setPath($dirpath); } $directory->addFile($file); $root->addDirectory($directory); } return $root; }