/** * @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))); }
/** * @param Message $message * @return string */ protected function generateSummaryOfMessage(Message $message) { $commit = $message->getCommit(); $pullRequest = $message->getPullRequest(); $preamble = ''; if (TRUE === $commit instanceof Commit) { $preamble = 'Commit: ' . $commit->getId(); $path = $message->getPath(); if (NULL !== $path) { $preamble .= PHP_EOL; $preamble .= 'File: ' . $path . PHP_EOL; $preamble .= 'Line: ' . $message->getPosition(); } } elseif (TRUE === $pullRequest instanceof PullRequest) { $preamble = 'Pull Request: ' . $pullRequest->getId(); } $summary = $preamble . PHP_EOL . $message->getBody(); return $summary; }
/** * @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')); }