Example #1
0
 /**
  * @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);
     }
 }
Example #2
0
 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();
 }
 /**
  * @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));
 }