public function test_should_interpret_data() { $data = new stdClass(); $data->sha = '1234567890qwertyuiop'; $data->url = 'https://api.github.com/path/to/endpoint'; $data->author = new stdClass(); $data->author->email = '*****@*****.**'; $data->committer = new stdClass(); $data->message = 'Commit message'; $data->parents = array('0987654321poiuytrewq'); $data->tree = new stdClass(); $data->tree->sha = 'zxcvbnmasdfghjklpoiuytrewq1234567876543'; $commit = new WordPress_GitHub_Sync_Commit($data); $this->assertSame($data->sha, $commit->sha()); $this->assertSame($data->url, $commit->url()); $this->assertSame($data->author, $commit->author()); $this->assertSame($data->author->email, $commit->author_email()); $this->assertSame($data->committer, $commit->committer()); $this->assertSame($data->message, $commit->message()); $this->assertSame($data->parents, $commit->parents()); $this->assertSame($data->tree->sha, $commit->tree_sha()); $body = $commit->to_body(); $this->assertSame($data->tree->sha, $body['tree']); $this->assertSame($data->message, $body['message']); $this->assertSame($data->parents, $body['parents']); }
/** * Create the commit from tree sha. * * @param WordPress_GitHub_Sync_Commit $commit Commit to create. * * @return mixed */ protected function create_commit(WordPress_GitHub_Sync_Commit $commit) { $body = $commit->to_body(); if ($author = $this->export_user()) { $body['author'] = $author; } return $this->call('POST', $this->commit_endpoint(), $body); }