organizationRepository = $this->getMockBuilder(OrganizationRepository::class)->disableOriginalConstructor()->getMock(); $this->cotisationUtils = $this->getMockBuilder(Utils::class)->disableOriginalConstructor()->getMock(); $this->cotisationCreator = new CotisationCreator( $this->organizationRepository, $this->cotisationUtils ); } public function testGetCotisation() { $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); $cotisation = $this->cotisationCreator->getCotisation(1); $this->assertEquals(1, $cotisation->getOrganizationId()); } }