public function it_will_return_new_entity_if_no_entity_found($repository, $factory, $em, GithubRepo $githubRepo, Commit $commitValueObject, GithubCommit $githubCommitEntity) { $commitValueObject->getSha()->willReturn('sha'); $repository->findOneBySha($githubRepo, 'sha')->willReturn(null); $factory->createFromValueObject($githubRepo, $commitValueObject)->willReturn($githubCommitEntity); $em->persist($githubCommitEntity)->shouldBeCalled(); $em->flush()->shouldBeCalled(); $this->getOrCreate($githubRepo, $commitValueObject)->shouldReturn($githubCommitEntity); }
/** * @param GithubRepo $githubRepo * @param Commit $commitValueObject * * @return mixed */ public function get(GithubRepo $githubRepo, Commit $commitValueObject) { return $this->repository->findOneBySha($githubRepo, $commitValueObject->getSha()); }