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


PHP vfsStream::newFile方法代码示例

本文整理汇总了PHP中vfsStream::newFile方法的典型用法代码示例。如果您正苦于以下问题:PHP vfsStream::newFile方法的具体用法?PHP vfsStream::newFile怎么用?PHP vfsStream::newFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vfsStream的用法示例。


在下文中一共展示了vfsStream::newFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testProviderReturnsAResultForEveryInstalledLanguage

 /**
  * @param ilTermsOfServiceAgreementByLanguageProvider $provider
  * @depends testAgreementByLanguageProviderCanBeCreatedByFactory
  */
 public function testProviderReturnsAResultForEveryInstalledLanguage(ilTermsOfServiceAgreementByLanguageProvider $provider)
 {
     $client_rel_path = implode('/', array('clients', 'default', 'agreement'));
     $global_rel_path = implode('/', array('global', 'agreement'));
     $root = vfsStreamWrapper::setRoot(new vfsStreamDirectory('root'));
     $customizing_dir = vfsStream::newDirectory('Customizing')->at($root);
     $client_dir = vfsStream::newDirectory($client_rel_path)->at($customizing_dir);
     vfsStream::newFile('agreement_de.html', 0777)->at($client_dir);
     file_put_contents(vfsStream::url('root/Customizing/' . $client_rel_path . '/agreement_de.html'), 'phpunit');
     $global_dir = vfsStream::newDirectory($global_rel_path)->at($customizing_dir);
     vfsStream::newFile('agreement_en.html', 0777)->at($global_dir);
     file_put_contents(vfsStream::url('root/Customizing/' . $global_rel_path . '/agreement_en.html'), 'phpunit');
     $provider->setSourceDirectories(array(vfsStream::url('root/Customizing/' . $client_rel_path), vfsStream::url('root/Customizing/' . $global_rel_path)));
     $lng = $this->getMockBuilder('ilLanguage')->disableOriginalConstructor()->getMock();
     $installed_languages = array('en', 'de', 'fr');
     $lng->expects($this->once())->method('getInstalledLanguages')->will($this->onConsecutiveCalls($installed_languages));
     $provider->setLanguageAdapter($lng);
     $data = $provider->getList(array(), array());
     $this->assertArrayHasKey('items', $data);
     $this->assertArrayHasKey('cnt', $data);
     $this->assertCount(count($installed_languages), $data['items']);
     $this->assertEquals(count($installed_languages), $data['cnt']);
     for ($i = 0; $i < count($installed_languages); $i++) {
         $this->assertArrayHasKey('language', $data['items'][$i]);
         $this->assertArrayHasKey('agreement', $data['items'][$i]);
         $this->assertArrayHasKey('agreement_document', $data['items'][$i]);
         $this->assertArrayHasKey('agreement_document_modification_ts', $data['items'][$i]);
         if ($installed_languages[$i] == 'fr') {
             $this->assertFalse(file_exists($data['items'][$i]['agreement_document']));
         } else {
             $this->assertTrue(file_exists($data['items'][$i]['agreement_document']));
         }
     }
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:38,代码来源:ilTermsOfServiceAgreementsByLanguageTableDataProviderTest.php

示例2: setLogFileSetsLogFile

 /**
  * @test
  */
 public function setLogFileSetsLogFile()
 {
     $this->setUpVfsStream();
     vfsStream::newFile($this->logFileName)->at(vfsStreamWrapper::getRoot());
     $writer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter');
     $writer->setLogFile($this->getDefaultFileName());
     $this->assertAttributeEquals($this->getDefaultFileName(), 'logFile', $writer);
 }
开发者ID:noxludo,项目名称:TYPO3v4-Core,代码行数:11,代码来源:class.t3lib_log_writer_fileTest.php

示例3: testScriptExistsAndFails

 function testScriptExistsAndFails()
 {
     vfsStream::newFile('script')->at(vfsStreamWrapper::getRoot());
     $script_runner = new TryLib_Precheck_ScriptRunner(vfsStream::url('testDir/script'));
     $this->mock_cmd_runner->expects($this->once())->method('run')->with('vfs://testDir/script', false, true)->will($this->returnValue(255));
     $this->mock_cmd_runner->expects($this->once())->method('terminate')->with('Failed running pre-check script vfs://testDir/script');
     $script_runner->check($this->mock_cmd_runner, 'repoPath', 'origin/master');
 }
开发者ID:seanly,项目名称:TryLib,代码行数:8,代码来源:ScriptRunnerTest.php

示例4: setUp

 /**
  * Prepares the environment before running a test.
  */
 protected function setUp()
 {
     parent::setUp();
     vfsStream::setup('exampleDir');
     $file = vfsStream::newFile('test1.php');
     vfsStreamWrapper::getRoot()->addChild($file);
     $file->setContent('__' . '("test1"); __' . '(\'test2\')');
     $this->Translation_File_Source = new Translation_File_Source(vfsStream::url('exampleDir/test1.php'));
 }
开发者ID:spalax,项目名称:zf2-translation-scanner,代码行数:12,代码来源:SourceTest.php

示例5: specialClassNamesAndPathsSettingsOverrideClassLoaderBehaviour

 /**
  * @test
  * @author Karsten Dambekalns <karsten@typo3.org>
  */
 public function specialClassNamesAndPathsSettingsOverrideClassLoaderBehaviour()
 {
     $root = \vfsStream::newDirectory('Packages/Virtual/Resources/PHP');
     \vfsStreamWrapper::setRoot($root);
     $vfsClassFile = \vfsStream::newFile('Bar.php')->withContent('<?php ?>')->at($root->getChild('Virtual/Resources/PHP'));
     $this->classLoader->setSpecialClassNameAndPath('Baz', \vfsStream::url('Virtual/Resources/PHP/Bar.php'));
     $this->classLoader->loadClass('Baz');
     $this->assertTrue($vfsClassFile->eof());
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:13,代码来源:ClassLoaderTest.php

示例6: selectStream

 /**
  * @test
  * @expectedException \PHPUnit_Framework_Error
  */
 public function selectStream()
 {
     $root = vfsStream::setup();
     $file = vfsStream::newFile('foo.txt')->at($root)->withContent('testContent');
     $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
     $readarray = array($fp);
     $writearray = array();
     $exceptarray = array();
     stream_select($readarray, $writearray, $exceptarray, 1);
 }
开发者ID:oalkhanishvili,项目名称:track2,代码行数:14,代码来源:vfsStreamWrapperStreamSelectTestCase.php

示例7: _test_get_file_info

 private function _test_get_file_info($vals)
 {
     $content = 'Jack and Jill went up the mountain to fight a billy goat.';
     $last_modified = time() - 86400;
     $file = vfsStream::newFile('my_file.txt', 0777)->withContent($content)->lastModified($last_modified)->at($this->_test_dir);
     $ret_values = array('name' => 'my_file.txt', 'server_path' => 'vfs://my_file.txt', 'size' => 57, 'date' => $last_modified, 'readable' => TRUE, 'writable' => TRUE, 'executable' => TRUE, 'fileperms' => 33279);
     $info = get_file_info(vfsStream::url('my_file.txt'), $vals);
     foreach ($info as $k => $v) {
         $this->assertEquals($ret_values[$k], $v);
     }
 }
开发者ID:ishawge,项目名称:No-CMS,代码行数:11,代码来源:file_helper_test.php

示例8: testExtractSource

 /**
  * @dataProvider extractSource_dp
  */
 public function testExtractSource($units, $file_content, $expected)
 {
     $f = vfsStream::newFile('file.php', 0664);
     $f->withContent($file_content);
     vfsStreamWrapper::getRoot()->addChild($f);
     $this->sa->extractSource($units[0]);
     $this->assertEquals(explode("\n", $expected['src']), explode("\n", $units[0]['src']));
     $this->assertEquals(explode("\n", $expected['src_strip']), explode("\n", $units[0]['src_strip']));
     $this->assertEquals(explode("\n", $expected['sloc']), explode("\n", $units[0]['sloc']));
     $this->assertEquals(explode("\n", $expected['err']), explode("\n", $units[0]['err']));
 }
开发者ID:noseglid,项目名称:phpa,代码行数:14,代码来源:SATest.php

示例9: setUp

 protected function setUp()
 {
     $root = vfsStream::setup('PasswordLibTest');
     //Setup Folders
     $core = vfsStream::newDirectory('Core')->at($root);
     $af = vfsStream::newDirectory('AbstractFactory')->at($core);
     // Create Files
     vfsStream::newFile('test.php')->at($af);
     vfsStream::newFile('Some234Foo234Bar98Name.php')->at($af);
     vfsStream::newFile('Invalid.csv')->at($af);
     vfsStream::newFile('badlocation.php')->at($core);
 }
开发者ID:nhemsley,项目名称:PHP-PasswordLib,代码行数:12,代码来源:AbstractFactoryTest.php

示例10: newFile

 public static function newFile($contents, $fileName = null, $root = null)
 {
     $root = is_null($root) ? 'root' : $root;
     $fileName = is_null($fileName) ? 'test.txt' : $fileName;
     \vfsStreamWrapper::register();
     \vfsStreamWrapper::setRoot(new \vfsStreamDirectory($root));
     $file = \vfsStream::newFile($fileName);
     $file->setContent($contents);
     \vfsStreamWrapper::getRoot()->addChild($file);
     $virtualPath = \vfsStream::url($root . '/' . $fileName);
     return $virtualPath;
 }
开发者ID:jdruid,项目名称:Microsoft-Azure-PHP-SDK-Storage,代码行数:12,代码来源:VirtualFileSystem.php

示例11: setUp

 public function setUp()
 {
     if (class_exists('vfsStream', false) === false) {
         $this->markTestSkipped('vfsStream not installed.');
     }
     vfsStreamWrapper::register();
     $root = vfsStream::newDirectory('home/test');
     $root->getChild('test')->addChild(vfsStream::newFile('succeed.php'));
     $root->getChild('test')->addChild(vfsStream::newFile('succeed2.php'));
     $root->getChild('test')->addChild(vfsStream::newFile('succeed3.php'));
     vfsStreamWrapper::setRoot($root);
 }
开发者ID:radiosilence,项目名称:core,代码行数:12,代码来源:ImportTest.php

示例12: setUp

 /**
  * Prepares the environment before running a test.
  */
 protected function setUp()
 {
     parent::setUp();
     vfsStream::setup('exampleDir');
     $dir = vfsStream::newDirectory('subDir1');
     vfsStreamWrapper::getRoot()->addChild($dir);
     vfsStreamWrapper::getRoot()->addChild(vfsStream::newFile('test1.php'));
     $dir->addChild(vfsStream::newFile('test2.php'));
     $dir->addChild(vfsStream::newFile('test3.js'));
     $dir->addChild(vfsStream::newFile('test4.xml'));
     $extentions = array('php' => array('PHP'));
     $this->Translation_Collector_Source_Files = new Translation_Collector_Source_Files(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(vfsStream::url('exampleDir'))), $extentions);
 }
开发者ID:spalax,项目名称:zf2-translation-scanner,代码行数:16,代码来源:FilesTest.php

示例13: setUp

 public function setUp()
 {
     if (class_exists('vfsStream', false) === false) {
         $this->markTestSkipped('vfsStream not installed.');
     }
     vfsStreamWrapper::register();
     $root = vfsStream::newDirectory('home/config');
     $root->getChild('config')->addChild(vfsStream::newFile('crypto.php')->withContent('
         <?php $config_auth["keyphrase"] = "moo"; $config_auth["base_salt"] = "baa"; ?>
     '));
     vfsStreamWrapper::setRoot($root);
     self::$slc = $this->getMock('\\Core\\Session\\LocalStorage', array('get', 'set', 'destroy'));
     self::$srp = $this->getMock('\\Core\\Session\\RemoteStorage', array('set_remote_addr', '__set', '__get', 'save', 'add', 'load', 'destroy'));
     self::$sh = new \Core\Session\Handler();
     self::$sh->set_remote_addr(TEST_IP)->attach_local_storage(self::$slc)->attach_remote_storage(self::$srp)->initialize_remote_storage()->attach_crypto_config('vfs://config/crypto.php');
 }
开发者ID:radiosilence,项目名称:core,代码行数:16,代码来源:SessionTest.php

示例14: setUp

 /**
  * set up test environment
  */
 public function setUp()
 {
     $this->fooURL = vfsStream::url('foo');
     $this->barURL = vfsStream::url('foo/bar');
     $this->baz1URL = vfsStream::url('foo/bar/baz1');
     $this->baz2URL = vfsStream::url('foo/baz2');
     $this->foo = new vfsStreamDirectory('foo');
     $this->bar = new vfsStreamDirectory('bar');
     $this->baz1 = vfsStream::newFile('baz1')->lastModified(300)->lastAccessed(300)->lastAttributeModified(300)->withContent('baz 1');
     $this->baz2 = vfsStream::newFile('baz2')->withContent('baz2')->lastModified(400)->lastAccessed(400)->lastAttributeModified(400);
     $this->bar->addChild($this->baz1);
     $this->foo->addChild($this->bar);
     $this->foo->addChild($this->baz2);
     $this->foo->lastModified(100)->lastAccessed(100)->lastAttributeModified(100);
     $this->bar->lastModified(200)->lastAccessed(100)->lastAttributeModified(100);
     vfsStreamWrapper::register();
     vfsStreamWrapper::setRoot($this->foo);
 }
开发者ID:sunkangtaichi,项目名称:PHPAPPLISTION_START,代码行数:21,代码来源:vfsStreamWrapperBaseTestCase.php

示例15: testGetInputStream

 /**
  * @covers WindowsAzure\ServiceRuntime\Internal\FileInputChannel::getInputStream
  * @covers WindowsAzure\ServiceRuntime\Internal\FileInputChannel::closeInputStream
  */
 public function testGetInputStream()
 {
     $rootDirectory = 'root';
     $fileName = 'test.txt';
     $fileContent = 'somecontent';
     // Setup
     \vfsStreamWrapper::register();
     \vfsStreamWrapper::setRoot(new \vfsStreamDirectory($rootDirectory));
     $file = \vfsStream::newFile($fileName);
     $file->setContent($fileContent);
     \vfsStreamWrapper::getRoot()->addChild($file);
     // Test
     $fileInputChannel = new FileInputChannel();
     $inputStream = $fileInputChannel->getInputStream(\vfsStream::url($rootDirectory . '/' . $fileName));
     $inputChannelContents = stream_get_contents($inputStream);
     $this->assertEquals($fileContent, $inputChannelContents);
     $fileInputChannel->closeInputStream();
     // invalid file
     $this->setExpectedException(get_class(new ChannelNotAvailableException()));
     $fileInputChannel->getInputStream(\vfsStream::url($rootDirectory . '/' . 'fakeinput'));
 }
开发者ID:bitmovin,项目名称:azure-sdk-for-php,代码行数:25,代码来源:FileInputChannelTest.php


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