當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。