/**
  * @test
  */
 public function directoryCanBeCreatedUsingWinDirSeparator()
 {
     mkdir('vfs://root/dir\\bar\\foo', true, 0777);
     $this->assertTrue($this->root->hasChild('dir'));
     $this->assertTrue($this->root->getChild('dir')->hasChild('bar'));
     $this->assertTrue($this->root->getChild('dir/bar')->hasChild('foo'));
 }
 /**
  * Test: should rename directory name as string internal
  *
  * @small
  */
 public function testShouldRenameDirectoryNameAsStringInternal()
 {
     $dir = $this->rootDirectory->getChild('var/log/app');
     $dir->addChild(vfsStream::newDirectory(80));
     $child = $this->rootDirectory->getChild('var/log/app/80');
     $child->rename(90);
     static::assertNotNull($this->rootDirectory->getChild('var/log/app/90'));
 }
 /**
  * dd
  *
  * @test
  * @group  regression
  * @group  bug_5
  */
 public function addChildReplacesChildWithSameName_Bug_5()
 {
     $mockChild1 = $this->getMock('org\\bovigo\\vfs\\vfsStreamContent');
     $mockChild1->expects($this->any())->method('getType')->will($this->returnValue(vfsStreamContent::TYPE_FILE));
     $mockChild1->expects($this->any())->method('getName')->will($this->returnValue('bar'));
     $mockChild2 = $this->getMock('org\\bovigo\\vfs\\vfsStreamContent');
     $mockChild2->expects($this->any())->method('getType')->will($this->returnValue(vfsStreamContent::TYPE_FILE));
     $mockChild2->expects($this->any())->method('getName')->will($this->returnValue('bar'));
     $this->dir->addChild($mockChild1);
     $this->assertTrue($this->dir->hasChild('bar'));
     $this->assertSame($mockChild1, $this->dir->getChild('bar'));
     $this->dir->addChild($mockChild2);
     $this->assertTrue($this->dir->hasChild('bar'));
     $this->assertSame($mockChild2, $this->dir->getChild('bar'));
 }
 /**
  * @test
  */
 public function shouldContainSubdirectoryApp2()
 {
     $this->assertTrue($this->rootDirectory->getChild('var/log/app')->hasChild('app2'));
     $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamDirectory', $this->rootDirectory->getChild('var/log/app')->getChild('app2'));
 }
Exemplo n.º 5
0
 /**
  * Prepare a virtual filesystem for testing.
  */
 protected function setUp()
 {
     // @codeCoverageIgnoreStart
     if (!$this->_started) {
         $config = parse_ini_file(dirname(__FILE__) . '/../../paths.ini', true);
         require_once $config['Opl'] . 'Opl/Class.php';
         Opl_Loader::register();
         $this->_started = true;
     }
     vfsStreamWrapper::register();
     vfsStreamWrapper::setRoot($root = new vfsStreamDirectory('libs'));
     $root->addChild(new vfsStreamDirectory('Foo'));
     $root->addChild(new vfsStreamDirectory('Bar'));
     $root->addChild(new vfsStreamDirectory('Joe'));
     $root->addChild(new vfsStreamDirectory('NewLib'));
     $root->addChild(new vfsStreamDirectory('Opl'));
     $root->addChild($this->_createFile('Bar.php', 'BAR.PHP'));
     // Contents of Opl/
     $root->getChild('Opl')->addChild(vfsStream::newFile('Test.php')->withContent(''));
     // Contents of NewLib/
     $root->getChild('NewLib')->addChild($this->_createFile('Class.php', 'NEWLIB/CLASS.PHP'));
     $root->getChild('NewLib')->addChild($this->_createFile('Foo.php', 'NEWLIB/FOO.PHP'));
     // Contents of Joe/
     $root->getChild('Joe')->addChild($this->_createFile('Class.php', 'JOE/CLASS.PHP'));
     $root->getChild('Joe')->addChild($this->_createFile('Foo.php', 'JOE/FOO.PHP'));
     $root->getChild('Joe')->addChild($this->_createFile('Bar.php', 'JOE/BAR.PHP'));
     $root->getChild('Joe')->addChild($this->_createFile('Exception.php', 'JOE/EXCEPTION.PHP'));
     $root->getChild('Joe')->addChild(new vfsStreamDirectory('Foo'));
     $root->getChild('Joe/Foo')->addChild($this->_createFile('Exception.php', 'JOE/FOO/EXCEPTION.PHP'));
     // Contents of Bar/
     $root->getChild('Bar')->addChild($this->_createFile('Class.php', 'BAR/CLASS.PHP'));
     // Contents of Foo/
     $root->getChild('Foo')->addChild($this->_createFile('Bar.php', 'FOO/BAR.PHP'));
     $root->getChild('Foo')->addChild($this->_createFile('Class.php', 'FOO/CLASS.PHP'));
     // @codeCoverageIgnoreStop
 }