当前位置: 首页>>代码示例>>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;未经允许,请勿转载。