コード例 #1
0
ファイル: WrapperTest.php プロジェクト: mathroc/php-vfs
 public function testIsFile()
 {
     $fs = new FileSystem();
     $fs->root()->addDirectory($d = new Directory('dir'));
     $d->addFile(new File('file'));
     $fs->root()->addFile(new File('file2'));
     $d->addDirectory(new Directory('dir'));
     $this->assertTrue(is_file($fs->path('/dir/file')));
     $this->assertFalse(is_file($fs->path('/dir')));
     $this->assertFalse(is_file($fs->path('/dir/dir')));
     $this->assertFalse(is_file($fs->path('/')));
     $this->assertTrue(is_file($fs->path('/file2')));
 }
コード例 #2
0
ファイル: ContainerTest.php プロジェクト: mathroc/php-vfs
 public function testMovingOntoDirectoryMovesIntoThatDirectory()
 {
     $container = new Container(new Factory());
     $container->root()->addDirectory($dir = new Directory('dir1'));
     $container->root()->addDirectory(new Directory('dir2'));
     $dir->addDirectory(new Directory('dir11'));
     $dir->addDirectory(new Directory('dir12'));
     $dir->addFile(new File('file'));
     $container->move('/dir1', '/dir2');
     $this->assertTrue($container->hasFileAt('/dir2'), 'Other parent directories not moved');
     $this->assertTrue($container->hasFileAt('/dir2/dir1'), 'Directory moved to new location');
     $this->assertFalse($container->hasFileAt('/dir1'), 'Directory does not exist at old location');
     $this->assertTrue($container->hasFileAt('/dir2/dir1/dir11'), 'Directory child of type Dir moved');
     $this->assertTrue($container->hasFileAt('/dir2/dir1/file'), 'Directory child of type File moved');
     $this->assertEquals('/dir2/dir1', $dir->path(), 'Moved dir has correct ancestors.');
     $container->move('/dir2/dir1/file', '/dir2/');
     $this->assertTrue($container->hasFileAt('/dir2/file'));
     $container->move('/dir2/file', '/');
     $this->assertTrue($container->hasFileAt('/file'));
 }
コード例 #3
0
ファイル: DirectoryHandler.php プロジェクト: mathroc/php-vfs
 /**
  * Sets directory in context.
  *
  * @param Directory $directory
  */
 public function setDirectory(Directory $directory)
 {
     $this->directory = $directory;
     $this->iterator = new \ArrayIterator($directory->children());
 }