public function it_will_return_new_entity_if_no_entity_found($repository, $factory, $em, GithubRepo $githubRepo, Branch $branchValueObject, GithubBranch $githubBranchEntity) { $branchValueObject->getName()->willReturn('master'); $repository->findOneByName($githubRepo, 'master')->willReturn(null); $factory->createFromValueObject($githubRepo, $branchValueObject)->willReturn($githubBranchEntity); $em->persist($githubBranchEntity)->shouldBeCalled(); $em->flush()->shouldBeCalled(); $this->getOrCreate($githubRepo, $branchValueObject)->shouldReturn($githubBranchEntity); }
/** * @param GithubRepo $githubRepo * @param Branch $branchValueObject * * @return mixed */ public function get(GithubRepo $githubRepo, Branch $branchValueObject) { return $this->repository->findOneByName($githubRepo, $branchValueObject->getName()); }