/** * @param GithubCommitDataInterface $remote * @param GithubCommit $entity * * @return bool */ public function map(GithubCommitDataInterface $remote, GithubCommit $entity) { $entity->setSha($remote->getSha()); $entity->setAuthorDate($remote->getAuthorDate()); $entity->setCommitterDate($remote->getCommitterDate()); $entity->setMessage($remote->getMessage()); return true; }
public function it_will_fetch_commit_details_from_github($authenticatedClientFactory, $githubCommitDataFactory, GithubCommitDataInterface $githubCommit, GithubRepo $githubRepo, User $user, Client $client, Repo $repositoryApi, Commits $commitApi, GithubCommitData $githubCommitData) { $githubRepo->getOwner()->willReturn('owner'); $githubRepo->getName()->willReturn('name'); $githubCommit->getSha()->willReturn('sha'); $authenticatedClientFactory->create($user)->willReturn($client); $client->api('repository')->willReturn($repositoryApi); $repositoryApi->commits()->willReturn($commitApi); $commitApi->show('owner', 'name', 'sha')->willReturn(['data']); $githubCommitDataFactory->create($githubRepo, ['data'])->willReturn($githubCommitData); $this->fetch($githubCommit, $githubRepo, $user)->shouldReturn($githubCommitData); }
public function it_will_map_property_values_from_remote_to_entity(GithubCommitDataInterface $remote, GithubCommit $entity, DateTime $authorDate, DateTime $committerDate) { $remote->getSha()->willReturn('name'); $remote->getAuthorDate()->willReturn($authorDate); $remote->getCommitterDate()->willReturn($committerDate); $remote->getMessage()->willReturn('message'); $entity->setSha('name')->shouldBeCalled(); $entity->setAuthorDate($authorDate)->shouldBeCalled(); $entity->setCommitterDate($committerDate)->shouldBeCalled(); $entity->setMessage('message')->shouldBeCalled(); $this->map($remote, $entity)->shouldReturn(true); }
/** * @param GithubCommitDataInterface $githubCommit * @param GithubRepoDataInterface $githubRepo * @param User $user * * @return mixed */ public function fetch(GithubCommitDataInterface $githubCommit, GithubRepoDataInterface $githubRepo, User $user) { $client = $this->createClient($user); $remoteData = $client->api('repository')->commits()->show($githubRepo->getOwner(), $githubRepo->getName(), $githubCommit->getSha()); return $this->githubCommitDataFactory->create($githubRepo, $remoteData); }