当前位置: 首页>>代码示例>>PHP>>正文


PHP vfsStream::newFile方法代码示例

本文整理汇总了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'));
 }
开发者ID:stubbles,项目名称:stubbles-reflect,代码行数:12,代码来源:FunctionsTest.php

示例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());
 }
开发者ID:Kron0S,项目名称:php-ansible,代码行数:13,代码来源:AnsibleTest.php

示例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());
 }
开发者ID:oalkhanishvili,项目名称:track2,代码行数:10,代码来源:vfsStreamPrintVisitorTestCase.php

示例4: setUp

 public function setUp()
 {
     vfsStreamWrapper::register();
     $root = vfsStream::setup('logs');
     $mockFile = vfsStream::newFile('logging_helper.log')->at($root);
     $root->addChild($mockFile);
 }
开发者ID:edgarsandi,项目名称:logging-helper,代码行数:7,代码来源:FactoryTest.php

示例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);
 }
开发者ID:jmcclell,项目名称:OryzoneMediaStorage,代码行数:36,代码来源:VimeoProviderTest.php

示例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());
 }
开发者ID:riyan8250,项目名称:Validation,代码行数:11,代码来源:SizeTest.php

示例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'));
 }
开发者ID:ebidtech,项目名称:config-loader,代码行数:11,代码来源:JsonFileLoaderTest.php

示例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));
 }
开发者ID:watonyweng,项目名称:flowjs-tour,代码行数:28,代码来源:FustyRequestTest.php

示例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());
 }
开发者ID:patrickpreuss,项目名称:Braintacle,代码行数:7,代码来源:DirectoryWritableTest.php

示例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());
 }
开发者ID:jezhalford,项目名称:stam,代码行数:7,代码来源:StamFileTest.php

示例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();
 }
开发者ID:nikoms,项目名称:phpunit-fail-lover,代码行数:7,代码来源:FileNameGeneratorTest.php

示例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());
 }
开发者ID:nochso,项目名称:omni,代码行数:7,代码来源:FolderTest.php

示例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");
 }
开发者ID:paulgessinger,项目名称:common,代码行数:7,代码来源:FileIteratorTest.php

示例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'));
 }
开发者ID:jasny,项目名称:invite-code,代码行数:11,代码来源:InviteCodeTest.php

示例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());
 }
开发者ID:nochso,项目名称:omni,代码行数:7,代码来源:DefaultFinderTest.php


注:本文中的org\bovigo\vfs\vfsStream::newFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。