organizationRepository = $this->getMockBuilder(OrganizationRepository::class)->disableOriginalConstructor()->getMock(); $this->cotisationUtils = $this->getMockBuilder(Utils::class)->disableOriginalConstructor()->getMock(); } /** * @see CotisationCreator::getCotisation() */ public function testGetCotisation(): void { $cotisationCreator = $this->getMockBuilder(CotisationCreator::class) ->setConstructorArgs([$this->organizationRepository, $this->cotisationUtils]) ->setMethodsExcept(['getCotisation']) ->getMock(); $this->cotisationUtils->expects(self::once())->method('getCurrentCotisationYear')->willReturn(2000); $organization = $this->getMockBuilder(Organization::class)->disableOriginalConstructor()->getMock(); $this->organizationRepository->expects(self::once())->method('find')->willReturn($organization); $this->cotisationUtils->expects(self::once())->method('getAlertState')->with($organization, 2000)->willReturn(AlertStateEnum::ADVERTISINGINSURANCE); $cotisation = $cotisationCreator->getCotisation(1); $this->assertEquals(1, $cotisation->getOrganizationId()); $this->assertEquals(2000, $cotisation->getCotisationYear()); $this->assertEquals(AlertStateEnum::ADVERTISINGINSURANCE, $cotisation->getAlertState()); } }