本文整理汇总了PHP中org\bovigo\vfs\vfsStreamWrapper类的典型用法代码示例。如果您正苦于以下问题:PHP vfsStreamWrapper类的具体用法?PHP vfsStreamWrapper怎么用?PHP vfsStreamWrapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vfsStreamWrapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
示例2: setUp
/**
* Sets up the test fixture.
*
* @return void
*/
public function setUp()
{
vfsStreamWrapper::register();
vfsStreamWrapper::setRoot(new vfsStreamDirectory('test'));
$this->forum = 'test';
$this->contents = new Forum_Contents(vfsStream::url('test'));
}
示例3: 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;
}
示例4: setUp
public function setUp()
{
vfsStreamWrapper::register();
$root = vfsStream::setup('logs');
$mockFile = vfsStream::newFile('logging_helper.log')->at($root);
$root->addChild($mockFile);
}
示例5: 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);
}
示例6: setFileSystem
protected function setFileSystem()
{
vfsStreamWrapper::register();
$root = vfsStream::newDirectory('build');
vfsStreamWrapper::setRoot($root);
return $root;
}
示例7: testDiscovery
/**
* Tests the YAML file discovery.
*/
public function testDiscovery()
{
vfsStreamWrapper::register();
$root = new vfsStreamDirectory('modules');
vfsStreamWrapper::setRoot($root);
$url = vfsStream::url('modules');
mkdir($url . '/test_1');
file_put_contents($url . '/test_1/test_1.test.yml', 'name: test');
file_put_contents($url . '/test_1/test_2.test.yml', 'name: test');
mkdir($url . '/test_2');
file_put_contents($url . '/test_2/test_3.test.yml', 'name: test');
// Write an empty YAML file.
file_put_contents($url . '/test_2/test_4.test.yml', '');
// Set up the directories to search.
$directories = array('test_1' => $url . '/test_1', 'test_2' => $url . '/test_1', 'test_3' => $url . '/test_2', 'test_4' => $url . '/test_2');
$discovery = new YamlDiscovery('test', $directories);
$data = $discovery->findAll();
$this->assertEquals(count($data), count($directories));
$this->assertArrayHasKey('test_1', $data);
$this->assertArrayHasKey('test_2', $data);
$this->assertArrayHasKey('test_3', $data);
$this->assertArrayHasKey('test_4', $data);
foreach (array('test_1', 'test_2', 'test_3') as $key) {
$this->assertArrayHasKey('name', $data[$key]);
$this->assertEquals($data[$key]['name'], 'test');
}
$this->assertSame(array(), $data['test_4']);
}
示例8: setUp
protected function setUp()
{
parent::setUp();
vfsStreamWrapper::register();
$this->vfs = new vfsStreamDirectory('chunks');
vfsStreamWrapper::setRoot($this->vfs);
}
示例9: 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);
}
示例10: getPartialPathAndFilenameThrowsExceptionIfPartialFileIsADirectory
/**
* @test
* @expectedException \Neos\FluidAdaptor\View\Exception\InvalidTemplateResourceException
*/
public function getPartialPathAndFilenameThrowsExceptionIfPartialFileIsADirectory()
{
vfsStreamWrapper::register();
mkdir('vfs://MyPartials/NotAFile');
$this->standaloneView->setPartialRootPath('vfs://MyPartials');
$this->standaloneView->getTemplatePaths()->getPartialSource('NotAFile');
}
示例11: 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'));
}
示例12: setUp
public function setUp()
{
$this->rootDir = new vfsStreamDirectory('queries');
vfsStreamWrapper::register();
vfsStreamWrapper::setRoot($this->rootDir);
$this->loader = new FilesystemQueryLoader($this->rootDir->url());
}
示例13: setUp
/**
* Sets up this testcase
*
* @return void
*/
protected function setUp()
{
if (!class_exists('org\\bovigo\\vfs\\vfsStreamWrapper')) {
$this->markTestSkipped('File backend tests are not available with this phpunit version.');
}
vfsStreamWrapper::register();
vfsStreamWrapper::setRoot(new vfsStreamDirectory('Foo'));
}
示例14: 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);
}
示例15: 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);
}