assertSame('ok', $example->writeData('testdata')); $this->assertTrue($root->hasChild('test.txt')); $this->assertSame('testdata', $root->getChild('test.txt')->getContent()); } /** * can't write to file */ public function testNoWrite() { $root = new vfsStreamDirectory('exampleDir'); $file = $this->getMock('vfsStreamFile', array('write'), array('test.txt')); $file->setContent('notoverwritten'); $file->expects($this->once()) ->method('write') ->will($this->returnValue(false)); $root->addChild($file); vfsStreamWrapper::setRoot($root); $example = new FailureExample(vfsStream::url('exampleDir/test.txt')); $this->assertSame('could not write data', $example->writeData('testdata')); $this->assertTrue($root->hasChild('test.txt')); $this->assertSame('notoverwritten', $root->getChild('test.txt')->getContent()); } } ?>