コード例 #1
0
ファイル: MessageTest.php プロジェクト: NamelessCoder/gizzle
 /**
  * @return array
  */
 public function getToGitHubApiDataArrayTestValues()
 {
     $commit = new Commit();
     $commit->setId(321);
     $pullRequest = new PullRequest();
     $pullRequest->setId(456);
     $withCommit = new Message('Message');
     $withCommit->setCommit($commit);
     $withCommitAndPath = new Message('Message', '/path/to/file', 123);
     $withCommitAndPath->setCommit($commit);
     $withPullRequest = new Message('Message');
     $withPullRequest->setPullRequest($pullRequest);
     return array(array(new Message('Message'), array('body' => 'Message')), array(new Message('Message', '/path/to/file', 123), array('body' => 'Message')), array($withCommit, array('body' => 'Message')), array($withCommitAndPath, array('body' => 'Message', 'path' => '/path/to/file', 'position' => 123, 'commit_id' => 321)), array($withPullRequest, array('body' => 'Message', 'sha1' => 456)));
 }
コード例 #2
0
 /**
  * @dataProvider getProcessTestValues
  * @param CommentPlugin $plugin
  * @param array $settings
  * @param array $errors
  * @param array $output
  * @param string|NULL $expectedMethod
  * @param string $expectedComment
  */
 public function testProcess(CommentPlugin $plugin, array $settings, array $errors, array $output, $expectedMethod, $expectedComment)
 {
     $payload = $this->getMockBuilder('NamelessCoder\\Gizzle\\Payload')->setMethods(array($expectedMethod))->disableOriginalConstructor()->getMock();
     $propertyReflection = new \ReflectionProperty($payload, 'response');
     $propertyReflection->setAccessible(TRUE);
     $propertyReflection->setValue($payload, new Response());
     $pullRequest = new PullRequest();
     $pullRequest->setId('pull-request-id');
     $commit = new Commit();
     $commit->setId('commit-id');
     $plugin->initialize($settings);
     $payload->setPullRequest($pullRequest);
     $payload->setHead($commit);
     if (0 < count($errors)) {
         $payload->getResponse()->setErrors($errors);
     }
     if (0 < count($output)) {
         $payload->getResponse()->addOutputFromPlugin($plugin, $output);
     }
     if ('dummy' !== $expectedMethod) {
         $payload->expects($this->once())->method($expectedMethod)->with($this->anything(), $expectedComment);
     }
     $plugin->process($payload);
 }
コード例 #3
0
ファイル: Payload.php プロジェクト: NamelessCoder/gizzle
 /**
  * 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));
 }
コード例 #4
0
ファイル: PayloadTest.php プロジェクト: NamelessCoder/gizzle
 /**
  * @return array
  */
 public function getGenerateSummaryOfMessageTestValues()
 {
     $pullRequest = new PullRequest();
     $pullRequest->setId('123');
     $withPullRequest = new Message('Test message with pull request');
     $withPullRequest->setPullRequest($pullRequest);
     $commit = new Commit();
     $commit->setId('456');
     $withCommit = new Message('Test message with commit');
     $withCommit->setCommit($commit);
     $withCommitAndPath = clone $withCommit;
     $withCommitAndPath->setPath('/path/to/file');
     $withCommitAndPath->setPosition(789);
     return array(array($withPullRequest, 'Pull Request: 123' . PHP_EOL . 'Test message with pull request'), array($withCommit, 'Commit: 456' . PHP_EOL . 'Test message with commit'), array($withCommitAndPath, 'Commit: 456' . PHP_EOL . 'File: /path/to/file' . PHP_EOL . 'Line: 789' . PHP_EOL . 'Test message with commit'));
 }