contactPointRepositoryMock = $this->getMockBuilder(ContactPointRepository::class)->disableOriginalConstructor()->getMock(); $this->contactPointUtils = new ContactPointUtils($this->contactPointRepositoryMock); } /** * @see Utils::getPersonContactPointPrincipal() */ public function testGetPersonContactPointPrincipal(){ $person = new Person(); $access = new Access(); $access->setPerson($person); $this->contactPointRepositoryMock ->method('getByTypeAndPerson') ->with(ContactPointTypeEnum::PRINCIPAL()->getValue(), $access->getPerson()) ->willReturn([new ContactPoint()]); $this->assertInstanceOf(ContactPoint::class, $this->contactPointUtils->getPersonContactPointPrincipal($access)); } /** * @see Utils::getPersonContactPointPrincipal() */ public function testGetPersonContactPointPrincipalNotExist(){ $person = new Person(); $access = new Access(); $access->setPerson($person); $this->contactPointRepositoryMock ->method('getByTypeAndPerson') ->with(ContactPointTypeEnum::PRINCIPAL()->getValue(), $access->getPerson()) ->willReturn([]); $this->assertNull($this->contactPointUtils->getPersonContactPointPrincipal($access)); } }