Exemplo n.º 1
0
 public function testRemove()
 {
     $root = new Root();
     $root->addDirectory(new Directory('dir1'));
     $root->remove('dir1');
     $this->setExpectedException('\\VirtualFileSystem\\NotFoundException');
     $root->childAt('dir1');
 }
Exemplo n.º 2
0
 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());
 }
Exemplo n.º 3
0
 /**
  * @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;
 }