/**
  * @dataProvider provideAllVariations
  *
  * @param $statuses
  */
 public function testNoUnknown($statuses)
 {
     $commit = new GithubCommit();
     $commit->setCommitStatuses($statuses);
     $this->calculator->calculate($commit);
     $this->assertNotSame(InternalStatus::UNKNOWN, $commit->getInternalStatus());
 }
Beispiel #2
0
 /**
  * @param GithubRepo $githubRepo
  * @param            $sha
  *
  * @return GithubCommit
  */
 private function createCommitObjectFromSha(GithubRepo $githubRepo, $sha)
 {
     $commit = new GithubCommit();
     $commit->setGithubRepo($githubRepo);
     $commit->setSha($sha);
     return $commit;
 }
 /**
  * @param GithubRepo $githubRepo
  * @param Commit     $commitValueObject
  *
  * @return GithubCommit
  */
 public function createFromValueObject(GithubRepo $githubRepo, Commit $commitValueObject)
 {
     $githubCommit = new GithubCommit();
     $githubCommit->setGithubRepo($githubRepo);
     $this->mapper->map($commitValueObject, $githubCommit);
     return $githubCommit;
 }
 /**
  * @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_sets_internal_state_to_success_if_all_statuses_passed(GithubCommit $githubCommit, GithubCommitStatus $commitStatus1, GithubCommitStatus $commitStatus2, GithubCommitStatus $commitStatus3, GithubCommitStatus $commitStatus4)
 {
     $commitStatusCollection = [$commitStatus1, $commitStatus2, $commitStatus3, $commitStatus4];
     $commitStatus1->getState()->willReturn(GithubCommitStatusState::PASSED);
     $commitStatus2->getState()->willReturn(GithubCommitStatusState::PASSED);
     $commitStatus3->getState()->willReturn(GithubCommitStatusState::PASSED);
     $commitStatus4->getState()->willReturn(GithubCommitStatusState::PASSED);
     $githubCommit->getCommitStatuses()->willReturn($commitStatusCollection);
     $githubCommit->setInternalStatus(InternalStatus::SUCCESS)->shouldBeCalled();
     $this->calculate($githubCommit)->shouldReturn($githubCommit);
 }
 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 GithubCommit $githubCommit
  * @param              $expectedStates
  *
  * @return bool
  */
 private function anyEqualTo(GithubCommit $githubCommit, $expectedStates)
 {
     foreach ($githubCommit->getCommitStatuses() as $status) {
         if (in_array($status->getState(), $expectedStates)) {
             return true;
         }
     }
     return false;
 }