public function testRunError() { $this->_process->getCommandLine()->willReturn('svn log')->shouldBeCalled(); $process = $this->_process; $this->_process->mustRun(null)->will(function () use($process) { $mock_definition = array('isSuccessful' => false, 'getExitCode' => 1, 'getExitCodeText' => 'exit code text', 'isOutputDisabled' => false, 'getOutput' => 'normal output', 'getErrorOutput' => 'error output'); foreach ($mock_definition as $method_name => $return_value) { $process->{$method_name}()->willReturn($return_value)->shouldBeCalled(); } throw new ProcessFailedException($process->reveal()); })->shouldBeCalled(); $this->_process->getOutput()->shouldNotBeCalled(); $this->_io->isVerbose()->shouldNotBeCalled(); $this->_io->isDebug()->shouldNotBeCalled(); $this->_cacheManager->getCache(Argument::any())->shouldNotBeCalled(); $thrown_exception = null; try { $this->_command->run(); } catch (\Exception $thrown_exception) { $this->assertEquals('ConsoleHelpers\\SVNBuddy\\Exception\\RepositoryCommandException', get_class($thrown_exception), 'Exception of correct class was thrown'); } $this->assertNotNull($thrown_exception, 'Exception was thrown when command execution failed'); $error_msg = <<<MSG Command: svn log Error #0: error output MSG; $this->assertEquals($error_msg, $thrown_exception->getMessage()); }
public function testGetLastRevisionNoAutomaticCachingForPaths() { $path = '/path/to/working-copy'; $raw_command = "svn --non-interactive --username a --password b info --xml '" . $path . "'"; $this->_cacheManager->getCache('command:' . $raw_command, null)->shouldNotBeCalled(); $repository_connector = $this->_createRepositoryConnector('a', 'b', '1 minute'); $this->_expectCommand($raw_command, $this->getFixture('svn_info_16.xml')); $this->assertEquals(100, $repository_connector->getLastRevision($path)); }
/** * @dataProvider repositoryUrlDataProvider */ public function testRefreshWithCache($repository_url, $plugin_last_revision) { $collected_data = array('mocked' => array('OLD_COLLECTED')); $cache_invalidator = new RegExToken('/^main:[\\d]+;plugin\\(mocked\\):[\\d]+$/'); if (!isset($plugin_last_revision)) { $this->repositoryConnector->getFirstRevision('svn://localhost')->willReturn(1000)->shouldBeCalled(); } $this->repositoryConnector->getLastRevision('svn://localhost')->willReturn(1000)->shouldBeCalled(); $this->repositoryConnector->getProjectUrl($repository_url)->willReturn('svn://localhost')->shouldBeCalled(); $this->cacheManager->getCache('log:svn://localhost', $cache_invalidator)->willReturn($collected_data)->shouldBeCalled(); $plugin = $this->prophesize('ConsoleHelpers\\SVNBuddy\\Repository\\RevisionLog\\IRevisionLogPlugin'); $plugin->getName()->willReturn('mocked')->shouldBeCalled(); $plugin->getCacheInvalidator()->willReturn(5)->shouldBeCalled(); $plugin->setCollectedData($collected_data['mocked'])->shouldBeCalled(); $plugin->getLastRevision()->willReturn($plugin_last_revision)->shouldBeCalled(); $revision_log = $this->createRevisionLog($repository_url); $revision_log->registerPlugin($plugin->reveal()); $revision_log->refresh(); }