コード例 #1
0
ファイル: FileSystem.php プロジェクト: mathroc/php-vfs
 /**
  * Class constructor. Will register both, the stream default options and wrapper handler.
  *
  * Note: Each FileSystem instance will create NEW stream wrapper/scheme.
  */
 public function __construct()
 {
     $this->scheme = uniqid('phpvfs');
     /* injecting components */
     $this->container = $container = new Container(new Factory());
     $this->container->root()->setScheme($this->scheme);
     $this->registerContextOptions($container);
     stream_wrapper_register($this->scheme, sprintf('\\%s\\%s', __NAMESPACE__, 'Wrapper'));
 }
コード例 #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'));
 }