/** * @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 * @group rendering * @group small * @group dev */ public function test_setUnitValueCreatesDirForUnit() { // ARRANGE $unit = new \Render\Unit('unit-id', 'unit_module_id', 'unit name'); $fileCache = new FileBasedJsonCache(vfsStream::url('virtualTestCacheDir')); // ACT $fileCache->setUnitValue($unit, 'key', array('value' => '#test')); // ASSERT $this->assertTrue($this->root->hasChild('unit-id')); }
public function testCreateConfigFound() { // Confirm mock filesystem contains config.php vfsStream::create(array('config.php' => 'config without secure data'), $this->root); $this->assertTrue($this->root->hasChild('config.php')); $output = array('Reviewing your Flaming Archer environment . . .', 'Found config.php.'); // Configure expectations foreach ($output as $index => $message) { $this->outputMock->expects($this->at($index))->method('write')->with($this->equalTo($message), $this->equalTo(true)); } $this->composerMock->expects($this->once())->method('getConfig')->will($this->returnValue($this->composerConfig)); $result = Config::create($this->event); }
public function testUnlink() { $filePath = vfsStream::url('root/old_file.txt'); $fileSystem = new FileSystem(); $fileSystem->putContents($filePath, 'Old content'); $this->assertTrue($this->root->hasChild('old_file.txt')); $fileSystem->unlink($filePath); $this->assertFalse($this->root->hasChild('old_file.txt')); }
/** * When testing for a nested path, verify that directory separators are respected properly * so that subdir1/subdir2 is not considered equal to subdir1Xsubdir2. * * @test * @group bug_24 * @group regression */ public function explicitTestForSeparatorWithNestedPaths_Bug_24() { $mockChild = $this->getMock('org\\bovigo\\vfs\\vfsStreamContent'); $mockChild->expects($this->any())->method('getType')->will($this->returnValue(vfsStreamContent::TYPE_FILE)); $mockChild->expects($this->any())->method('getName')->will($this->returnValue('bar')); $subdir1 = new vfsStreamDirectory('subdir1'); $this->dir->addChild($subdir1); $subdir2 = new vfsStreamDirectory('subdir2'); $subdir1->addChild($subdir2); $subdir2->addChild($mockChild); $this->assertTrue($this->dir->hasChild('subdir1'), "Level 1 path with separator exists"); $this->assertTrue($this->dir->hasChild('subdir1/subdir2'), "Level 2 path with separator exists"); $this->assertTrue($this->dir->hasChild('subdir1/subdir2/bar'), "Level 3 path with separator exists"); $this->assertFalse($this->dir->hasChild('subdir1.subdir2'), "Path with period does not exist"); $this->assertFalse($this->dir->hasChild('subdir1.subdir2/bar'), "Nested path with period does not exist"); }
public function testTouch() { $dir = '/path/to/app'; $mFS = m::mock('Illuminate\\Filesystem\\Filesystem'); $mCmd = m::mock('Console\\BuildCommand'); $touches = [vfsStream::url('touchDir') . DIRECTORY_SEPARATOR . 'one.txt', vfsStream::url('touchDir') . DIRECTORY_SEPARATOR . 'two.txt']; $config = $this->getConfig(); $config['touch'] = $touches; foreach ($touches as $touchFile) { $mCmd->shouldReceive('comment')->once()->with("Touch", $touchFile); } $this->assertFalse($this->root->hasChild('one.txt')); $this->assertFalse($this->root->hasChild('two.txt')); $structure = new Structure($dir, $config, $mFS, $mCmd); $structure->touch(); $this->assertTrue($this->root->hasChild('one.txt')); $this->assertTrue($this->root->hasChild('two.txt')); }