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