| 12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- namespace App\Tests\Service\Cotisation;
- use App\Entity\Organization\Organization;
- use App\Repository\Organization\OrganizationRepository;
- use App\Service\Cotisation\CotisationCreator;
- use App\Service\Cotisation\Utils;
- use PHPUnit\Framework\TestCase;
- class CotisationCreatorTest extends TestCase
- {
- private OrganizationRepository $organizationRepository;
- private Utils $cotisationUtils;
- private CotisationCreator $cotisationCreator;
- public function setUp():void
- {
- $this->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());
- }
- }
|