CotisationCreatorTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace App\Tests\Service\Cotisation;
  3. use App\Entity\Organization\Organization;
  4. use App\Repository\Organization\OrganizationRepository;
  5. use App\Service\Cotisation\CotisationCreator;
  6. use App\Service\Cotisation\Utils;
  7. use PHPUnit\Framework\TestCase;
  8. class CotisationCreatorTest extends TestCase
  9. {
  10. private OrganizationRepository $organizationRepository;
  11. private Utils $cotisationUtils;
  12. private CotisationCreator $cotisationCreator;
  13. public function setUp():void
  14. {
  15. $this->organizationRepository = $this->getMockBuilder(OrganizationRepository::class)->disableOriginalConstructor()->getMock();
  16. $this->cotisationUtils = $this->getMockBuilder(Utils::class)->disableOriginalConstructor()->getMock();
  17. $this->cotisationCreator = new CotisationCreator(
  18. $this->organizationRepository,
  19. $this->cotisationUtils
  20. );
  21. }
  22. public function testGetCotisation() {
  23. $this->cotisationUtils->expects(self::once())->method('getCurrentCotisationYear')->willReturn(2000);
  24. $organization = $this->getMockBuilder(Organization::class)->disableOriginalConstructor()->getMock();
  25. $this->organizationRepository->expects(self::once())->method('find')->willReturn($organization);
  26. $this->cotisationUtils->expects(self::once())->method('getAlertState')->with($organization, 2000);
  27. $cotisation = $this->cotisationCreator->getCotisation(1);
  28. $this->assertEquals(1, $cotisation->getOrganizationId());
  29. }
  30. }