Ejemplo n.º 1
0
 public function it_will_create($repoFactory, $pullRequestFactory, $commitFactory, $pullRequestCreatorFactory, $pullRequestAssigneeFactory, $githubRepoFacade, $githubPullRequestFacade, $githubCommitFacade, $githubUserFacade, $em, PullRequestPayload $pullRequestPayload, Repo $repoValueObject, PullRequest $pullRequestValueObject, Commit $commitValueObject, CommitAuthor $pullRequestCreatorValueObject, CommitCommitter $pullRequestAssigneeValueObject, GithubRepo $githubRepoEntity, GithubPullRequest $githubPullRequestEntity, GithubCommit $githubCommitEntity, GithubUser $githubPullRequestCreatorEntity, GithubUser $githubPullRequestAssigneeEntity)
 {
     $pullRequestPayload->getPullRequestAssigneeDetails()->willReturn(['assignee-details']);
     $repoFactory->create($pullRequestPayload)->willReturn($repoValueObject);
     $pullRequestFactory->create($pullRequestPayload)->willReturn($pullRequestValueObject);
     $commitFactory->create($pullRequestPayload)->willReturn($commitValueObject);
     $pullRequestCreatorFactory->create($pullRequestPayload)->willReturn($pullRequestCreatorValueObject);
     $pullRequestAssigneeFactory->create($pullRequestPayload)->willReturn($pullRequestAssigneeValueObject);
     $githubRepoFacade->getOrCreate($repoValueObject)->willReturn($githubRepoEntity);
     $githubPullRequestFacade->getOrCreate($githubRepoEntity, $pullRequestValueObject)->willReturn($githubPullRequestEntity);
     $githubCommitFacade->getOrCreate($githubRepoEntity, $commitValueObject)->willReturn($githubCommitEntity);
     $githubUserFacade->getOrCreate($pullRequestCreatorValueObject)->willReturn($githubPullRequestCreatorEntity);
     $githubUserFacade->getOrCreate($pullRequestAssigneeValueObject)->willReturn($githubPullRequestAssigneeEntity);
     $githubPullRequestEntity->setCreatedBy($githubPullRequestCreatorEntity)->shouldBeCalled();
     $githubPullRequestEntity->setAssignedTo($githubPullRequestAssigneeEntity)->shouldBeCalled();
     $githubPullRequestEntity->setLastCommit($githubCommitEntity)->shouldBeCalled();
     $githubPullRequestEntity->setState(GithubPullRequestState::OPENED)->shouldBeCalled();
     $pullRequestValueObject->getState()->willReturn('open');
     $em->persist($githubPullRequestEntity)->shouldBeCalled();
     $em->persist($githubCommitEntity)->shouldBeCalled();
     $em->flush()->shouldBeCalled();
     $this->process($pullRequestPayload)->shouldReturn(true);
 }
 /**
  * @param PullRequestPayload $pullRequestPayload
  *
  * @return CommitCommitter
  */
 public function create(PullRequestPayload $pullRequestPayload)
 {
     $data = $pullRequestPayload->getPullRequestAssigneeDetails();
     return new PullRequestAssignee($data['id'], $data['login'], $data['avatar_url']);
 }