/** * @param Payload $payload * @param Commit $commit * @param string $message * @return void */ protected function storeCommitValidation(Payload $payload, Commit $commit, $message, $file, $line) { $url = $payload->getPullRequest()->getUrlReviewComments(); $urlPath = $this->getUrlPathFromUrl($url); $parameters = array('commit_id' => $commit->getId(), 'body' => $message, 'path' => $file, 'position' => $line); $payload->getApi()->post($urlPath, json_encode($parameters)); }
public function testProcessRethrowsSoapFaultAsRuntimeException() { vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory('temp', 0777)); $settings = array(ExtensionRepositoryReleasePlugin::OPTION_DIRECTORY => vfsStream::url('temp'), ExtensionRepositoryReleasePlugin::OPTION_COMMENT => 'comment', ExtensionRepositoryReleasePlugin::OPTION_REMOVEBUILD => TRUE); $plugin = $this->getMock('NamelessCoder\\GizzleTYPO3Plugins\\GizzlePlugins\\ExtensionRepositoryReleasePlugin', array('validateCredentialsFile', 'getUploader', 'readUploadCredentials', 'getGitClonePlugin')); $payload = $this->getMock('NamelessCoder\\Gizzle\\Payload', array('getRepository', 'getHead', 'getResponse', 'getRef'), array(), '', FALSE); $repository = new Repository(); $repository->setMasterBranch('master'); $repository->setName('repository'); $head = new Commit(); $head->setId('123'); $clone = $this->getMock('NamelessCoder\\GizzleGitPlugins\\GizzlePlugins\\ClonePlugin', array('initialize', 'process')); $clone->expects($this->once())->method('initialize')->with(array(ClonePlugin::OPTION_GITCOMMAND => ClonePlugin::DEFAULT_GITCOMMAND, ClonePlugin::OPTION_DIRECTORY => $settings[ExtensionRepositoryReleasePlugin::OPTION_DIRECTORY] . '/123/repository', ClonePlugin::OPTION_SINGLE => TRUE, ClonePlugin::OPTION_BRANCH => '1.1.1', ClonePlugin::OPTION_DEPTH => 1)); $clone->expects($this->once())->method('process')->with($payload); $response = $this->getMock('NamelessCoder\\Gizzle\\Response', array('addOutputFromPlugin')); $response->expects($this->never())->method('addOutputFromPlugin'); $uploader = $this->getMock('NamelessCoder\\TYPO3RepositoryClient\\Uploader', array('upload')); $uploader->expects($this->once())->method('upload')->with($settings[ExtensionRepositoryReleasePlugin::OPTION_DIRECTORY] . '/' . $head->getId() . '/' . $repository->getName(), 'username', 'password', $settings[ExtensionRepositoryReleasePlugin::OPTION_COMMENT])->willThrowException(new \SoapFault('test', 123)); $payload->expects($this->any())->method('getRepository')->will($this->returnValue($repository)); $payload->expects($this->any())->method('getResponse')->will($this->returnValue($response)); $payload->expects($this->any())->method('getHead')->will($this->returnValue($head)); $payload->expects($this->any())->method('getRef')->will($this->returnValue('refs/tags/1.1.1')); $plugin->expects($this->once())->method('getGitClonePlugin')->will($this->returnValue($clone)); $plugin->expects($this->once())->method('validateCredentialsFile'); $plugin->expects($this->once())->method('getUploader')->will($this->returnValue($uploader)); $plugin->expects($this->once())->method('readUploadCredentials')->will($this->returnValue(array('username', 'password'))); $plugin->initialize($settings); $this->setExpectedException('RuntimeException'); $plugin->process($payload); }
/** * Store a pull request specific validation of a single * line in a commit. * * Use this method to quickly add comments about any line * in a commit that is part of the pull request, both of * which must be provided. The message requires a file * path (repository root relative) and line number. * * @param PullRequest $pullRequest * @param Commit $commit * @param string $message * @param string $file * @param integer $line * @return void */ public function storeCommitValidation(PullRequest $pullRequest, Commit $commit, $message, $file, $line) { $url = $pullRequest->resolveApiUrl(PullRequest::API_URL_REVIEW_COMMENTS); $parameters = array('commit_id' => $commit->getId(), 'body' => $message, 'path' => $file, 'position' => $line); $this->getApi()->post($url, json_encode($parameters)); }