示例#1
0
 public function create($title, Ref $head, Ref $base, $body = '')
 {
     $status = StringUtil::jsonDecode($this->connector->post('/repos/:owner/:repo/pulls', json_encode(array('title' => $title, 'body' => $body, 'head' => $head->getRefName(), 'base' => $base->getRefName()))));
     if (isset($status->number)) {
         return $this->jsonToEntity($status);
     }
     PhpHubExceptionFactory::throwNewGithubException($status);
 }
示例#2
0
 public function createBranch(Ref $from, $name)
 {
     if ($from instanceof Commit) {
         $from = $from->getSha();
     }
     $status = StringUtil::jsonDecode($this->connector->post('/repos/:owner/:repo/git/refs', json_encode(array('ref' => "refs/heads/{$name}", 'sha' => (string) $from))));
     if (isset($status->ref)) {
         return;
     }
     PhpHubExceptionFactory::throwNewGithubException($status);
 }
 /**
  * @test
  * @expectedException PhpHubApi\Exception\PullRequestHasInvalidBaseException
  */
 public function testFunctionality()
 {
     PhpHubExceptionFactory::throwNewGithubException((object) array('message' => 'Validation Failed', 'documentation_url' => 'https://developer.github.com/v3/pulls/#create-a-pull-request', 'errors' => array((object) array('resource' => 'PullRequest', 'field' => 'base', 'code' => 'invalid'))));
 }