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(); }
public function testDebugOutput() { $this->_process->getCommandLine()->willReturn('svn log')->shouldBeCalled(); $this->_process->mustRun(null)->shouldBeCalled(); $this->_process->getOutput()->willReturn('OK')->shouldBeCalled(); $this->_io->isVerbose()->willReturn(false)->shouldBeCalled(); $this->_io->isDebug()->willReturn(true)->shouldBeCalled(); $this->_cacheManager->getCache(Argument::any())->shouldNotBeCalled(); $this->_io->writeln('OK', OutputInterface::OUTPUT_RAW)->shouldBeCalled(); $this->_command->run(); }
public function testGetWorkingCopyUrlOnOldFormatWorkingCopyAndUpgradeRejected() { $this->_io->writeln(array('', '<error>error message</error>', ''))->shouldBeCalled(); $this->_io->askConfirmation('Run "svn upgrade"', false)->willReturn(false)->shouldBeCalled(); $this->_expectCommand("svn --non-interactive info --xml '/path/to/working-copy'", '', 'error message', RepositoryCommandException::SVN_ERR_WC_UPGRADE_REQUIRED); $exception_msg = <<<MESSAGE Command: svn --non-interactive info --xml '/path/to/working-copy' Error #%d: error message MESSAGE; $this->setExpectedException('ConsoleHelpers\\SVNBuddy\\Exception\\RepositoryCommandException', sprintf($exception_msg, RepositoryCommandException::SVN_ERR_WC_UPGRADE_REQUIRED)); $this->_repositoryConnector->getWorkingCopyUrl('/path/to/working-copy'); }
public function testRefreshWithoutCacheWithoutOutput(ConsoleIO $io = null, ProgressBar $database_progress_bar = null, $is_verbose = false) { $this->repositoryConnector->getLastRevision('svn://localhost')->willReturn(400)->shouldBeCalled(); // Create revision log (part 1). $revision_log = $this->createRevisionLog('svn://localhost/projects/project-name/trunk', $io); // Add repository collector plugin. $repository_collector_plugin = $this->prophesize('ConsoleHelpers\\SVNBuddy\\Repository\\RevisionLog\\Plugin\\IRepositoryCollectorPlugin'); $repository_collector_plugin->getName()->willReturn('mocked_repo')->shouldBeCalled(); $repository_collector_plugin->setRevisionLog($revision_log)->shouldBeCalled(); $repository_collector_plugin->whenDatabaseReady()->shouldBeCalled(); $repository_collector_plugin->getLastRevision()->willReturn(0)->shouldBeCalled(); $repository_collector_plugin->getRevisionQueryFlags()->willReturn(array(RevisionLog::FLAG_MERGE_HISTORY, RevisionLog::FLAG_VERBOSE))->shouldBeCalled(); $repository_collector_plugin->parse(new SimpleXMLElementToken($this->expectSvnLogQuery(0, 199)))->shouldBeCalled(); $repository_collector_plugin->parse(new SimpleXMLElementToken($this->expectSvnLogQuery(200, 399)))->shouldBeCalled(); $repository_collector_plugin->parse(new SimpleXMLElementToken($this->expectSvnLogQuery(400, 400)))->shouldBeCalled(); if ($is_verbose) { $repository_collector_plugin->getStatistics()->willReturn(array('rp1' => 10, 'rp2' => 20))->shouldBeCalled(); $this->io->writeln('<debug> * rp1: 10</debug>')->shouldBeCalled(); $this->io->writeln('<debug> * rp2: 20</debug>')->shouldBeCalled(); } // Add database collector plugin. $database_collector_plugin = $this->prophesize('ConsoleHelpers\\SVNBuddy\\Repository\\RevisionLog\\Plugin\\IDatabaseCollectorPlugin'); $database_collector_plugin->getName()->willReturn('mocked_db')->shouldBeCalled(); $database_collector_plugin->setRevisionLog($revision_log)->shouldBeCalled(); $database_collector_plugin->whenDatabaseReady()->shouldBeCalled(); $database_collector_plugin->getLastRevision()->willReturn(0)->shouldBeCalled(); $database_collector_plugin->process(0, 400, $database_progress_bar)->will(function (array $args) { if (isset($args[2])) { $args[2]->advance(); } })->shouldBeCalled(); if ($is_verbose) { $database_collector_plugin->getStatistics()->willReturn(array('dp1' => 3, 'dp2' => 4))->shouldBeCalled(); $this->io->writeln('<debug> * dp1: 3</debug>')->shouldBeCalled(); $this->io->writeln('<debug> * dp2: 4</debug>')->shouldBeCalled(); } // Create revision log (part 2). $revision_log->registerPlugin($repository_collector_plugin->reveal()); $revision_log->registerPlugin($database_collector_plugin->reveal()); $revision_log->refresh(false); }
public static function outputWritesLine(ObjectProphecy $output, $line) { $output->writeln($line)->shouldBeCalled(); }
public function testWriteln() { $this->output->writeln('text', OutputInterface::OUTPUT_NORMAL)->shouldBeCalled(); $this->io->writeln('text', OutputInterface::OUTPUT_NORMAL); }
/** * Expects verbose output. * * @param ObjectProphecy $io ConsoleIO mock. * @param string $regexp Regexp. * * @return void */ protected function expectVerboseOutput(ObjectProphecy $io, $regexp) { $io->writeln(Argument::that(function (array $messages) use($regexp) { return count($messages) === 2 && $messages[0] === '' && preg_match($regexp, $messages[1]); }))->shouldBeCalled(); }