本文整理汇总了PHP中org\bovigo\vfs\vfsStreamWrapper::getRoot方法的典型用法代码示例。如果您正苦于以下问题:PHP vfsStreamWrapper::getRoot方法的具体用法?PHP vfsStreamWrapper::getRoot怎么用?PHP vfsStreamWrapper::getRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org\bovigo\vfs\vfsStreamWrapper
的用法示例。
在下文中一共展示了vfsStreamWrapper::getRoot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createFile
private function createFile($filePath, $body = 'hello')
{
vfsStream::newFile($filePath)->at(vfsStreamWrapper::getRoot());
$path = vfsStream::url('root/' . $filePath);
file_put_contents($path, $body);
return $path;
}
示例2: test_create_token_folder_if_it_does_not_exist
public function test_create_token_folder_if_it_does_not_exist()
{
$this->assertFalse(vfsStreamWrapper::getRoot()->hasChild('tokens'), 'Folder should not exists');
$tokenizer = $this->instantiateClass('token_filename_retrieve.token', vfsStream::url('testDir/tokens'), $this->token_content, new Filesystem());
$tokenizer->retrieve();
$this->assertTrue(vfsStreamWrapper::getRoot()->hasChild('tokens'), 'Folder should now exists even if retrieve notes file does not');
}
示例3: testConstruct
public function testConstruct()
{
// test non existent file
$nonExistentFilePath = "non/existent/file.php";
try {
new ConsoleRunner($nonExistentFilePath, $this->pidFactory, []);
$this->fail("Should not be able to create a console runner without a console file that exists");
} catch (RunnerException $e) {
$this->assertContains($nonExistentFilePath, $e->getMessage());
}
// test non executable file
$nonExecutableFilePath = "nonExecutableFile.php";
$nonExecutableFile = vfsStream::newFile($nonExecutableFilePath, 00);
vfsStreamWrapper::getRoot()->addChild($nonExecutableFile);
$nonExecutableFilePath = $this->getPath($nonExecutableFilePath);
try {
new ConsoleRunner($nonExecutableFilePath, $this->pidFactory, []);
$this->fail("Should not be able to create a console runner without a console file that is executable");
} catch (RunnerException $e) {
$this->assertContains($nonExecutableFilePath, $e->getMessage());
}
// test valid file
$consolePath = "console.php";
$nonExecutableFile = vfsStream::newFile($consolePath, 0444);
vfsStreamWrapper::getRoot()->addChild($nonExecutableFile);
$consolePath = $this->getPath($consolePath);
$runner = new ConsoleRunner($consolePath, $this->pidFactory, []);
$this->assertAttributeEquals($consolePath, "consolePath", $runner);
}
示例4: testFactoryCreateServiceWithName
public function testFactoryCreateServiceWithName()
{
$this->init(array('logger' => array($this->key => array('path' => vfsStream::url('logs/default.log')))));
$this->assertFalse(vfsStreamWrapper::getRoot()->hasChild('default.log'));
$this->assertInstanceOf('Zend\\Log\\Logger', $this->factory->createServiceWithName($this->serviceLocator, $this->key, $this->key));
$this->assertTrue(vfsStreamWrapper::getRoot()->hasChild('default.log'));
}
示例5: setUp
public function setUp(DiInterface $di = NULL, Config $config = NULL)
{
vfsStream::setup('root');
vfsStream::newFile('file.php')->at(vfsStreamWrapper::getRoot());
$this->file = vfsStream::url('root/file.php');
parent::setUp($di, $config);
}
示例6: writeShouldWriteIfFileIsInDirectory
/**
* @test
*
* @covers Cocur\Bundle\BuildBundle\Writer\FilesystemWriter::write()
* @covers Cocur\Bundle\BuildBundle\Writer\FilesystemWriter::getRealName()
*/
public function writeShouldWriteIfFileIsInDirectory()
{
$root = vfsStreamWrapper::getRoot();
$this->writer->write('/foo', 'Foobar');
$this->assertTrue($root->hasChild('foo'));
$this->assertTrue($root->getChild('foo')->hasChild('index.html'));
$this->assertEquals('Foobar', $root->getChild('foo')->getChild('index.html')->getContent());
}
示例7: passwordShouldBeAddToRsaIfPasswordPassed
/**
* @test
*/
public function passwordShouldBeAddToRsaIfPasswordPassed()
{
vfsStream::newFile('id_rsa')->at(vfsStreamWrapper::getRoot());
$authentication = new Rsa('root', vfsStream::url('root/id_rsa'), 'password');
/** @var \Crypt_RSA $rsa */
$rsa = $authentication->getAuthentication();
$this->assertEquals('password', $rsa->password);
}
示例8: vfsPath
/**
* Retrieves the virtual file system path
*
* @param string $path The path relative to the root folder
*
* @return string
*/
protected function vfsPath($path = '')
{
$root = vfsStreamWrapper::getRoot()->getName();
if (empty($path)) {
return vfsStream::url($root);
}
return vfsStream::url($root . '/' . $path);
}
示例9: testSetLastUidCorrectly
public function testSetLastUidCorrectly()
{
$this->initRoot();
$file = vfsStream::url('home/lastui.json');
$lastUidPersistFile = new LastUidPersistFile($file);
$lastUidPersistFile->setLastUid(12);
$this->assertTrue(vfsStreamWrapper::getRoot()->hasChild('lastui.json'), 'The file is not created');
$this->assertTrue(file_get_contents($file) == json_encode(array('lastUid' => 12)), 'The file content is not correct');
}
示例10: testInitWithExistingIdxFile
public function testInitWithExistingIdxFile()
{
vfsStreamWrapper::getRoot()->addChild(new vfsStreamFile('idxfile.php'));
$idx = $this->getMock('\\Idephix\\IdephixInterface');
$idx->output = $this->getMock('Symfony\\Component\\Console\\Output\\OutputInterface');
$idx->output->expects($this->exactly(1))->method('writeln')->with("<error>An idxfile.php already exists, generation skipped.</error>");
$initIdxFile = new InitIdxFile('vfs://root');
$initIdxFile->setIdephix($idx);
$initIdxFile->initFile();
}
示例11: testExceptionThrownWhenConfigFileNotReadable
/**
* @expectedException Message\Cog\Config\Exception
* @expectedExceptionMessage Config file `vfs://config/myconfig.yml` is not readable
*/
public function testExceptionThrownWhenConfigFileNotReadable()
{
vfsStream::setup('config');
vfsStream::newFile('myconfig.yml', 0333)->at(vfsStreamWrapper::getRoot());
$env = new FauxEnvironment();
$env->set('staging');
$loader = new Loader(vfsStream::url('config'), $env);
$registry = new NonLoadingRegistry($loader);
$loader->load($registry);
}
示例12: testPartial
/**
* testPartial
*
* @since 2.3.0
*/
public function testPartial()
{
/* setup */
Stream::setup('root');
$file = new StreamFile('partial.phtml');
StreamWrapper::getRoot()->addChild($file);
/* actual */
$actual = Template::partial(Stream::url('root/partial.phtml'));
/* compare */
$this->assertTrue(is_string($actual));
}
示例13:
function it_checks_whether_a_file_is_writable()
{
$root = vfsStreamWrapper::getRoot();
vfsStream::newFile('writable.txt', 0666)->at($root);
vfsStream::newFile('not_writable.txt', 0444)->at($root);
$rootPath = vfsStream::url('root') . DIRECTORY_SEPARATOR;
$file1 = $rootPath . 'writable.txt';
$this->writable($file1)->shouldBe(true);
$file2 = $rootPath . 'not_writable.txt';
$this->writable($file2)->shouldBe(false);
}
示例14: setUp
public function setUp(DiInterface $di = NULL, Config $config = NULL)
{
vfsStream::setup('root');
vfsStream::newFile('modules/module1/config/services.yml')->at(vfsStreamWrapper::getRoot());
vfsStream::newFile('modules/module2/config/services.yml')->at(vfsStreamWrapper::getRoot());
vfsStream::newFile('config/config.yml')->at(vfsStreamWrapper::getRoot());
$this->module1 = vfsStream::url('root/modules/module1');
$this->module2 = vfsStream::url('root/modules/module2');
$this->configFile = vfsStream::url('root/config/config.yml');
parent::setUp($di, $config);
}
示例15: generateShouldReturnListOfParameters
/**
* @test
*
* @covers Cocur\Bundle\BuildBundle\Generator\FileGenerator::generate()
*/
public function generateShouldReturnListOfParameters()
{
$file = vfsStream::newFile('parameters.txt')->at(vfsStreamWrapper::getRoot());
$generator = new FileGenerator(['filename' => vfsStream::url('data/parameters.txt'), 'parameter' => 'var']);
$file->setContent("param1\nparam2\nparam3\n");
$parameters = $generator->generate();
$this->assertCount(3, $parameters);
$this->assertEquals('param1', $parameters[0]['var']);
$this->assertEquals('param2', $parameters[1]['var']);
$this->assertEquals('param3', $parameters[2]['var']);
}