|
|
@@ -21,6 +21,7 @@ use App\Entity\Person\Person;
|
|
|
use App\Entity\Person\PersonAddressPostal;
|
|
|
use App\Enum\Core\ContactPointTypeEnum;
|
|
|
use App\Enum\Education\CycleEnum;
|
|
|
+use App\Enum\Network\NetworkEnum;
|
|
|
use App\Enum\Organization\AddressPostalOrganizationTypeEnum;
|
|
|
use App\Enum\Organization\LegalEnum;
|
|
|
use App\Enum\Organization\PrincipalTypeEnum;
|
|
|
@@ -835,7 +836,63 @@ class OrganizationFactoryTest extends TestCase
|
|
|
$organizationFactory->makeNetworkOrganization($organizationCreationRequest);
|
|
|
}
|
|
|
|
|
|
- public function testMakeAdminAccess()
|
|
|
+ public function testMakeNetworkOrganizationIsCMFInvalidIdentifier(): void {
|
|
|
+ $organizationFactory = $this->getOrganizationFactoryMockFor('makeNetworkOrganization');
|
|
|
+
|
|
|
+ $organizationCreationRequest = $this->getMockBuilder(OrganizationCreationRequest::class)->getMock();
|
|
|
+ $organizationCreationRequest->method('getParentId')->willReturn(123);
|
|
|
+ $organizationCreationRequest->method('getIdentifier')->willReturn('invalid');
|
|
|
+
|
|
|
+ $parent = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
+ $this->organizationRepository->method('find')->with(123)->willReturn($parent);
|
|
|
+
|
|
|
+ $network = $this->getMockBuilder(Network::class)->getMock();
|
|
|
+ $network->method('getId')->willReturn(NetworkEnum::CMF->value);
|
|
|
+
|
|
|
+ $networkOrganization = $this->getMockBuilder(NetworkOrganization::class)->getMock();
|
|
|
+ $networkOrganization->method('getNetwork')->willReturn($network);
|
|
|
+
|
|
|
+ $this->organizationUtils
|
|
|
+ ->method('getActiveNetworkOrganization')
|
|
|
+ ->with($parent)
|
|
|
+ ->willReturn($networkOrganization);
|
|
|
+
|
|
|
+ $this->expectException(\RuntimeException::class);
|
|
|
+ $this->expectExceptionMessage("CMF identifier is missing or invalid.");
|
|
|
+
|
|
|
+ $organizationFactory->makeNetworkOrganization($organizationCreationRequest);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testMakeNetworkOrganizationIsNotCMFInvalidIdentifier(): void {
|
|
|
+ $organizationFactory = $this->getOrganizationFactoryMockFor('makeNetworkOrganization');
|
|
|
+
|
|
|
+ $organizationCreationRequest = $this->getMockBuilder(OrganizationCreationRequest::class)->getMock();
|
|
|
+ $organizationCreationRequest->method('getParentId')->willReturn(123);
|
|
|
+ $organizationCreationRequest->method('getIdentifier')->willReturn('invalid');
|
|
|
+
|
|
|
+ $parent = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
+ $this->organizationRepository->method('find')->with(123)->willReturn($parent);
|
|
|
+
|
|
|
+ $network = $this->getMockBuilder(Network::class)->getMock();
|
|
|
+ $network->method('getId')->willReturn(NetworkEnum::OUTOFNET->value);
|
|
|
+
|
|
|
+ $networkOrganization = $this->getMockBuilder(NetworkOrganization::class)->getMock();
|
|
|
+ $networkOrganization->method('getNetwork')->willReturn($network);
|
|
|
+
|
|
|
+ $this->organizationUtils
|
|
|
+ ->method('getActiveNetworkOrganization')
|
|
|
+ ->with($parent)
|
|
|
+ ->willReturn($networkOrganization);
|
|
|
+
|
|
|
+ $result = $organizationFactory->makeNetworkOrganization($organizationCreationRequest);
|
|
|
+
|
|
|
+ $this->assertEquals(
|
|
|
+ $network,
|
|
|
+ $result->getNetwork()
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testMakeAdminAccess(): void
|
|
|
{
|
|
|
$organizationFactory = $this->getOrganizationFactoryMockFor('makeAdminAccess');
|
|
|
|