當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ObjectProphecy::setCache方法代碼示例

本文整理匯總了PHP中Prophecy\Prophecy\ObjectProphecy::setCache方法的典型用法代碼示例。如果您正苦於以下問題:PHP ObjectProphecy::setCache方法的具體用法?PHP ObjectProphecy::setCache怎麽用?PHP ObjectProphecy::setCache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Prophecy\Prophecy\ObjectProphecy的用法示例。


在下文中一共展示了ObjectProphecy::setCache方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testRunWithExistingCache

 /**
  * @dataProvider runWithCacheDataProvider
  */
 public function testRunWithExistingCache($duration, $invalidator, $use_callback, $is_xml)
 {
     if ($is_xml) {
         $command_line = 'svn log --xml';
         $process_output = '<log><logentry/></log>';
     } else {
         $command_line = 'svn log';
         $process_output = 'OK';
     }
     $callback_output = null;
     $callback = $this->createRunCallback($use_callback, $callback_output);
     $this->_process->getCommandLine()->willReturn($command_line)->shouldBeCalled();
     $this->_process->mustRun($callback)->shouldNotBeCalled();
     $this->_cacheManager->getCache('command:' . $command_line, $invalidator)->willReturn($process_output)->shouldBeCalled();
     $this->_cacheManager->setCache(Argument::any())->shouldNotBeCalled();
     if (isset($duration)) {
         $this->_command->setCacheDuration($duration);
     }
     if (isset($invalidator)) {
         $this->_command->setCacheInvalidator($invalidator);
     }
     $this->assertCommandOutput($callback, $is_xml, $process_output);
     if ($use_callback) {
         $this->assertEquals($process_output, $callback_output);
     }
 }
開發者ID:aik099,項目名稱:svn-buddy,代碼行數:29,代碼來源:CommandTest.php

示例2: testRefreshWithoutCache

 public function testRefreshWithoutCache()
 {
     $new_collected_data = array('mocked' => array('NEW_COLLECTED'));
     $cache_invalidator = new RegExToken('/^main:[\\d]+;plugin\\(mocked\\):[\\d]+$/');
     $this->repositoryConnector->getFirstRevision('svn://localhost')->willReturn(1000)->shouldBeCalled();
     $this->repositoryConnector->getLastRevision('svn://localhost')->willReturn(3000)->shouldBeCalled();
     $this->repositoryConnector->getProjectUrl('svn://localhost/trunk')->willReturn('svn://localhost')->shouldBeCalled();
     $this->cacheManager->getCache('log:svn://localhost', $cache_invalidator)->shouldBeCalled();
     $this->cacheManager->setCache('log:svn://localhost', $new_collected_data, $cache_invalidator)->shouldBeCalled();
     $progress_bar = $this->prophesize('Symfony\\Component\\Console\\Helper\\ProgressBar');
     $progress_bar->setFormat(' * Reading missing revisions: %current%/%max% [%bar%] %percent:3s%%')->shouldBeCalled();
     $progress_bar->start()->shouldBeCalled();
     $progress_bar->advance()->shouldBeCalled();
     $progress_bar->finish()->shouldBeCalled();
     $this->io->createProgressBar(2)->willReturn($progress_bar)->shouldBeCalled();
     $this->io->writeln('')->shouldBeCalled();
     $plugin = $this->prophesize('ConsoleHelpers\\SVNBuddy\\Repository\\RevisionLog\\IRevisionLogPlugin');
     $plugin->getName()->willReturn('mocked')->shouldBeCalled();
     $plugin->getCacheInvalidator()->willReturn(5)->shouldBeCalled();
     $plugin->getLastRevision()->shouldBeCalled();
     $plugin->parse(new SimpleXMLElementToken($this->expectSvnLogQuery(1000, 2000)))->shouldBeCalled();
     $plugin->parse(new SimpleXMLElementToken($this->expectSvnLogQuery(2001, 3000)))->shouldBeCalled();
     $plugin->getCollectedData()->willReturn($new_collected_data['mocked'])->shouldBeCalled();
     $revision_log = $this->createRevisionLog('svn://localhost/trunk');
     $revision_log->registerPlugin($plugin->reveal());
     $revision_log->refresh();
 }
開發者ID:aik099,項目名稱:svn-buddy,代碼行數:27,代碼來源:RevisionLogTest.php

示例3: testGetLastRevisionWithAutomaticCaching

 /**
  * @dataProvider svnInfoBasedMethodDataProvider
  */
 public function testGetLastRevisionWithAutomaticCaching($given_repository_url, $used_repository_url)
 {
     $raw_command = "svn --non-interactive --username a --password b info --xml '" . $used_repository_url . "'";
     $raw_command_output = $this->getFixture('svn_info_remote.xml');
     $this->_cacheManager->getCache('repository.com/command:' . $raw_command, null, '1 minute')->willReturn(null)->shouldBeCalled();
     $this->_cacheManager->setCache('repository.com/command:' . $raw_command, $raw_command_output, null, '1 minute')->shouldBeCalled();
     $repository_connector = $this->_createRepositoryConnector('a', 'b', '1 minute');
     $this->_expectCommand($raw_command, $raw_command_output);
     $this->assertEquals(100, $repository_connector->getLastRevision($given_repository_url));
 }
開發者ID:console-helpers,項目名稱:svn-buddy,代碼行數:13,代碼來源:ConnectorTest.php


注:本文中的Prophecy\Prophecy\ObjectProphecy::setCache方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。