Ejemplo n.º 1
0
 public function it_will_create($repoFactory, $commitFactory, $externalServiceFactory, $commitStatusFactory, $githubRepoFacade, $githubCommitFacade, $githubExternalServiceFacade, $githubCommitStatusFacade, $calculateGithubCommitState, $em, StatusPayload $statusPayload, Repo $repoValueObject, Commit $commitValueObject, ExternalService $externalServiceValueObject, CommitStatus $commitStatusValueObject, GithubRepo $githubRepoEntity, GithubCommit $githubCommitEntity, GithubExternalService $githubExternalService, GithubCommitStatus $githubCommitStatus)
 {
     $repoFactory->create($statusPayload)->willReturn($repoValueObject);
     $commitFactory->create($statusPayload)->willReturn($commitValueObject);
     $externalServiceFactory->create($statusPayload)->willReturn($externalServiceValueObject);
     $commitStatusFactory->create($statusPayload)->willReturn($commitStatusValueObject);
     $githubRepoFacade->getOrCreate($repoValueObject)->willReturn($githubRepoEntity);
     $githubCommitFacade->getOrCreate($githubRepoEntity, $commitValueObject)->willReturn($githubCommitEntity);
     $githubExternalServiceFacade->getOrCreate('external-service-context')->willReturn($githubExternalService);
     $externalServiceValueObject->getContext()->willReturn('external-service-context');
     $githubCommitStatusFacade->getOrCreate($githubCommitEntity, $githubExternalService, $commitStatusValueObject)->willReturn($githubCommitStatus);
     $githubCommitStatus->setState(GithubCommitStatusState::convert($commitStatusValueObject->getStatus()));
     $calculateGithubCommitState->calculate($githubCommitEntity)->shouldBeCalled();
     $em->persist($githubCommitStatus)->shouldBeCalled();
     $em->refresh($githubCommitEntity)->shouldBeCalled();
     $em->persist($githubCommitEntity)->shouldBeCalled();
     $em->flush()->shouldBeCalled();
     $this->process($statusPayload)->shouldReturn(true);
 }
Ejemplo n.º 2
0
 /**
  * @param StatusPayload $statusPayload
  *
  * @return bool
  */
 public function process(StatusPayload $statusPayload)
 {
     $repoValueObject = $this->repoFactory->create($statusPayload);
     $githubRepo = $this->githubRepoFacade->getOrCreate($repoValueObject);
     $commitValueObject = $this->commitFactory->create($statusPayload);
     $githubCommit = $this->githubCommitFacade->getOrCreate($githubRepo, $commitValueObject);
     $externalServiceValueObject = $this->externalServiceFactory->create($statusPayload);
     $githubExternalService = $this->githubExternalServiceFacade->getOrCreate($externalServiceValueObject->getContext());
     $commitStatusValueObject = $this->commitStatusFactory->create($statusPayload);
     $githubCommitStatus = $this->githubCommitStatusFacade->getOrCreate($githubCommit, $githubExternalService, $commitStatusValueObject);
     $githubCommitStatus->setState(GithubCommitStatusState::convert($statusPayload->getState()));
     $githubCommitStatus->setTargetUrl($commitStatusValueObject->getTargetUrl());
     $this->em->persist($githubCommitStatus);
     $this->em->flush();
     $this->em->refresh($githubCommit);
     $this->calculateGithubCommitState->calculate($githubCommit);
     $this->em->persist($githubCommit);
     $this->em->flush();
     return true;
 }
Ejemplo n.º 3
0
 /**
  * @return int
  */
 public function getStateColor()
 {
     return GithubCommitStatusState::getColor((int) $this->state);
 }