|
|
@@ -5,6 +5,7 @@ use App\Entity\Billing\BillingSetting;
|
|
|
use App\Entity\Organization\Organization;
|
|
|
use App\Entity\Organization\Parameters;
|
|
|
use App\Enum\Organization\LegalEnum;
|
|
|
+use App\Service\OnChange\OnChangeContext;
|
|
|
use App\Service\OnChange\Organization\OnOrganizationChange;
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
@@ -19,6 +20,54 @@ class OnOrganizationChangeTest extends TestCase
|
|
|
$this->onOrganizationChange = new OnOrganizationChange();
|
|
|
}
|
|
|
|
|
|
+ public function testBeforeChangeNoChange(): void
|
|
|
+ {
|
|
|
+ $onOrganizationChange = $this
|
|
|
+ ->getMockBuilder(OnOrganizationChange::class)
|
|
|
+ ->onlyMethods(['onLegalStatusChange'])
|
|
|
+ ->disableOriginalConstructor()
|
|
|
+ ->getMock();
|
|
|
+ $onOrganizationChange
|
|
|
+ ->expects(self::never())
|
|
|
+ ->method('onLegalStatusChange')
|
|
|
+ ->willReturnSelf();
|
|
|
+
|
|
|
+ $previousOrganization = $this->getMockBuilder(Organization::class)->disableOriginalConstructor()->getMock();
|
|
|
+ $previousOrganization->expects(self::once())->method('getLegalStatus')->willReturn('ASSOCIATION_LAW_1901');
|
|
|
+
|
|
|
+ $context = $this->getMockBuilder(OnChangeContext::class)->disableOriginalConstructor()->getMock();
|
|
|
+ $context->method('previousData')->willReturn($previousOrganization);
|
|
|
+
|
|
|
+ $organization = $this->getMockBuilder(Organization::class)->disableOriginalConstructor()->getMock();
|
|
|
+ $organization->expects(self::once())->method('getLegalStatus')->willReturn('ASSOCIATION_LAW_1901');
|
|
|
+
|
|
|
+ $onOrganizationChange->beforeChange($organization, $context);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testBeforeChangeLegalStatusChanged(): void
|
|
|
+ {
|
|
|
+ $onOrganizationChange = $this
|
|
|
+ ->getMockBuilder(OnOrganizationChange::class)
|
|
|
+ ->onlyMethods(['onLegalStatusChange'])
|
|
|
+ ->disableOriginalConstructor()
|
|
|
+ ->getMock();
|
|
|
+ $onOrganizationChange
|
|
|
+ ->expects(self::once())
|
|
|
+ ->method('onLegalStatusChange')
|
|
|
+ ->willReturnSelf();
|
|
|
+
|
|
|
+ $previousOrganization = $this->getMockBuilder(Organization::class)->disableOriginalConstructor()->getMock();
|
|
|
+ $previousOrganization->expects(self::once())->method('getLegalStatus')->willReturn('ASSOCIATION_LAW_1901');
|
|
|
+
|
|
|
+ $context = $this->getMockBuilder(OnChangeContext::class)->disableOriginalConstructor()->getMock();
|
|
|
+ $context->method('previousData')->willReturn($previousOrganization);
|
|
|
+
|
|
|
+ $organization = $this->getMockBuilder(Organization::class)->disableOriginalConstructor()->getMock();
|
|
|
+ $organization->expects(self::once())->method('getLegalStatus')->willReturn('LOCAL_AUTHORITY');
|
|
|
+
|
|
|
+ $onOrganizationChange->beforeChange($organization, $context);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @see OnOrganizationChange::onLegalStatusChange()
|
|
|
*/
|
|
|
@@ -36,4 +85,4 @@ class OnOrganizationChangeTest extends TestCase
|
|
|
$this->assertFalse($this->organization->getParameters()->getShowAdherentList());
|
|
|
$this->assertTrue($this->organization->getBillingSetting()->getApplyVat());
|
|
|
}
|
|
|
-}
|
|
|
+}
|