本文整理汇总了PHP中org\bovigo\vfs\vfsStream::newFile方法的典型用法代码示例。如果您正苦于以下问题:PHP vfsStream::newFile方法的具体用法?PHP vfsStream::newFile怎么用?PHP vfsStream::newFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org\bovigo\vfs\vfsStream
的用法示例。
在下文中一共展示了vfsStream::newFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: canEnableFileAnnotationCache
/**
* @since 3.0.0
* @group issue_58
* @test
*/
public function canEnableFileAnnotationCache()
{
$root = vfsStream::setup();
$file = vfsStream::newFile('annotations.cache')->withContent(serialize($this->createdCachedAnnotation()))->at($root);
persistAnnotationsInFile($file->url());
assertTrue(AnnotationCache::has('foo', 'bar'));
}
示例2: testAnsibleCommandNotExecutableException
/**
* @expectedException \ErrorException
* @covers \Asm\Ansible\Ansible::checkCommand
* @covers \Asm\Ansible\Ansible::checkDir
* @covers \Asm\Ansible\Ansible::__construct
*/
public function testAnsibleCommandNotExecutableException()
{
$vfs = vfsStream::setup('/tmp');
$ansiblePlaybook = vfsStream::newFile('ansible-playbook', 600)->at($vfs);
$ansibleGalaxy = vfsStream::newFile('ansible-galaxy', 444)->at($vfs);
$ansible = new Ansible($this->getProjectUri(), $ansiblePlaybook->url(), $ansibleGalaxy->url());
}
示例3: visitDirectoryWritesDirectoryNameToStream
/**
* @test
*/
public function visitDirectoryWritesDirectoryNameToStream()
{
$output = vfsStream::newFile('foo.txt')->at(vfsStream::setup());
$printVisitor = new vfsStreamPrintVisitor(fopen('vfs://root/foo.txt', 'wb'));
$this->assertSame($printVisitor, $printVisitor->visitDirectory(vfsStream::newDirectory('baz')));
$this->assertEquals("- baz\n", $output->getContent());
}
示例4: setUp
public function setUp()
{
vfsStreamWrapper::register();
$root = vfsStream::setup('logs');
$mockFile = vfsStream::newFile('logging_helper.log')->at($root);
$root->addChild($mockFile);
}
示例5: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->dir = vfsStream::setup();
$dir = $this->dir;
$tempDir = vfsStream::url($dir->getName()) . '/';
$this->media = $this->getMock('\\Oryzone\\MediaStorage\\Model\\MediaInterface');
$this->media->expects($this->any())->method('getContext')->will($this->returnValue('default'));
$this->media->expects($this->any())->method('getName')->will($this->returnValue('sample'));
$this->media->expects($this->any())->method('getContent')->will($this->returnValue('http://vimeo.com/56974716'));
$this->media->expects($this->any())->method('getMetaValue')->will($this->returnValueMap(array(array('id', null, '56974716'))));
$this->variant = $this->getMock('\\Oryzone\\MediaStorage\\Variant\\VariantInterface');
$this->variant->expects($this->any())->method('getName')->will($this->returnValue('default'));
$this->variant->expects($this->any())->method('getOptions')->will($this->returnValue(array('width' => 50, 'height' => 30, 'resize' => 'stretch')));
$this->variant->expects($this->any())->method('getMetaValue')->will($this->returnValueMap(array(array('width', null, 50), array('height', null, 30))));
$image = $this->getMock('\\Imagine\\Image\\ImageInterface');
$image->expects($this->any())->method('save')->will($this->returnCallback(function ($destFile) use($dir) {
$temp = vfsStream::newFile(basename($destFile));
$dir->addChild($temp);
return true;
}));
$imagine = $this->getMock('\\Imagine\\Image\\ImagineInterface');
$imagine->expects($this->any())->method('open')->will($this->returnValue($image));
$downloader = $this->getMock('\\Oryzone\\MediaStorage\\Downloader\\DownloaderInterface');
$downloader->expects($this->any())->method('download')->will($this->returnCallback(function ($url, $destination) use($dir) {
$temp = vfsStream::newFile(basename($destination));
$temp->setContent(file_get_contents(__DIR__ . '/../fixtures/images/sample.jpg'));
$dir->addChild($temp);
return true;
}));
$videoService = $this->getMock('\\Oryzone\\MediaStorage\\Integration\\Video\\VideoServiceInterface');
$this->provider = new VimeoProvider($tempDir, $imagine, $videoService, $downloader);
}
示例6: testShouldThrowsSizeExceptionWhenAsserting
/**
* @expectedException Respect\Validation\Exceptions\SizeException
* @expectedExceptionMessage "vfs://root/1gb.txt" must be greater than 2pb
*/
public function testShouldThrowsSizeExceptionWhenAsserting()
{
$root = vfsStream::setup();
$file1Gb = vfsStream::newFile('1gb.txt')->withContent(LargeFileContent::withGigabytes(1))->at($root);
$rule = new Size('2pb');
$rule->assert($file1Gb->url());
}
示例7: testLoadFileNotReadable
/**
* @expectedException \EBT\ConfigLoader\Exception\InvalidArgumentException
* @expectedExceptionMessage not readable
*/
public function testLoadFileNotReadable()
{
$this->root->addChild(vfsStream::newFile('file1'));
// make sure is not readable
$this->root->getChild('file1')->chown('testuser')->chgrp('testuser')->chmod(0750);
(new JsonFileLoader())->load(vfsStream::url('test/file1'));
}
示例8: testFustyRequest_ValidateUpload
/**
*/
public function testFustyRequest_ValidateUpload()
{
//// Setup test
$firstChunk = vfsStream::newFile('temp_file');
$firstChunk->setContent('1234567890');
$this->vfs->addChild($firstChunk);
$fileInfo = new \ArrayObject(array('size' => 10, 'error' => UPLOAD_ERR_OK, 'tmp_name' => $firstChunk->url()));
$request = new \ArrayObject(array('flowIdentifier' => '13632-prettifyjs', 'flowFilename' => 'prettify.js', 'flowRelativePath' => 'home/prettify.js'));
$fustyRequest = new FustyRequest($request, $fileInfo);
$config = new Config();
$config->setTempDir($this->vfs->url());
/** @var File $file */
$file = $this->getMock('Flow\\File', array('_move_uploaded_file'), array($config, $fustyRequest));
/** @noinspection PhpUndefinedMethodInspection */
$file->expects($this->once())->method('_move_uploaded_file')->will($this->returnCallback(function ($filename, $destination) {
return rename($filename, $destination);
}));
//// Actual test
$this->assertTrue($file->validateChunk());
$this->assertFalse($file->validateFile());
$this->assertTrue($file->saveChunk());
$this->assertTrue($file->validateFile());
$path = $this->vfs->url() . DIRECTORY_SEPARATOR . 'new';
$this->assertTrue($file->save($path));
$this->assertEquals(10, filesize($path));
}
示例9: testFileReadOnly
public function testFileReadOnly()
{
$url = vfsStream::newFile('test', 00)->at($this->_root)->url();
$validator = new DirectoryWritable();
$this->assertFalse($validator->isValid($url));
$this->assertEquals(array(DirectoryWritable::DIRECTORY => "'{$url}' ist kein Verzeichnis oder nicht zugänglich"), $validator->getMessages());
}
示例10: setUp
public function setUp()
{
$this->root = vfsStream::setup('dir');
$this->file = vfsStream::newFile('stam.yml');
$this->root->addChild($this->file);
$this->stamFile = new StamFile($this->root->getChild('stam.yml')->url());
}
示例11: testCreate_WhenPatternHasLastOnFile_ThrowsException
public function testCreate_WhenPatternHasLastOnFile_ThrowsException()
{
vfsStream::newFile('file.csv')->at($this->root);
$pathToFile = $this->root->url() . '/file.csv';
$this->setExpectedException('\\InvalidArgumentException');
$this->getFileNameGenerator($pathToFile . ':last')->getGeneratedFileName();
}
示例12: testDelete_FailToDeleteFile_MustThrow
public function testDelete_FailToDeleteFile_MustThrow()
{
$root = vfsStream::setup('root', 0400);
vfsStream::newFile('test', 0444)->at($root);
$this->expectException('RuntimeException');
Folder::delete($root->url());
}
示例13: setUp
public function setUp()
{
$this->root = vfsStream::setup('root', 0777);
$this->someFile = vfsStream::newFile('multiline2.txt', 0777);
$this->root->addChild($this->someFile);
$this->someFile->setContent("LINE1" . PHP_EOL . "LINE2" . PHP_EOL . "LINE3");
}
示例14: setUp
/**
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
*/
public function setUp()
{
$dir = vfsStream::setup('invite-codes');
vfsStream::newFile('UNUSED')->at($dir);
vfsStream::newFile('USED')->at($dir)->setContent("user@example.com\n2014-12-01T02:15:00+00:00\n");
InviteCode::setDir(vfsStream::url('invite-codes'));
}
示例15: testReadExcludeLines_WhenNoReadPermission_MustNotThrow
public function testReadExcludeLines_WhenNoReadPermission_MustNotThrow()
{
$root = vfsStream::setup();
$file = vfsStream::newFile('.gitignore')->at($root)->setContent('foo');
$finder = DefaultFinder::createIn($root->url());
$this->assertSame(0, $finder->count());
}