|
|
@@ -1507,6 +1507,25 @@ class OrganizationFactoryTest extends TestCase
|
|
|
$organizationMemberCreationRequest->method('getEmail')->willReturn('email@domain.com');
|
|
|
$organizationMemberCreationRequest->method('getMobile')->willReturn('+33607080910');
|
|
|
|
|
|
+ $this->phoneNumberUtil
|
|
|
+ ->expects(self::exactly(2))
|
|
|
+ ->method('isPossibleNumber')
|
|
|
+ ->willReturnMap([
|
|
|
+ ['+33102030405', null, true],
|
|
|
+ ['+33607080910', null, true],
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $phoneNumber = $this->getMockBuilder(PhoneNumber::class)->getMock();
|
|
|
+ $mobilePhoneNumber = $this->getMockBuilder(PhoneNumber::class)->getMock();
|
|
|
+
|
|
|
+ $this->phoneNumberUtil
|
|
|
+ ->expects(self::exactly(2))
|
|
|
+ ->method('parse')
|
|
|
+ ->willReturnMap([
|
|
|
+ ['+33102030405', null, null, false, $phoneNumber],
|
|
|
+ ['+33607080910', null, null, false, $mobilePhoneNumber],
|
|
|
+ ]);
|
|
|
+
|
|
|
$contactPoint = $organizationFactory->makePersonContactPoint($organizationMemberCreationRequest);
|
|
|
|
|
|
$this->assertEquals(
|
|
|
@@ -1515,29 +1534,75 @@ class OrganizationFactoryTest extends TestCase
|
|
|
);
|
|
|
|
|
|
$this->assertEquals(
|
|
|
- '33',
|
|
|
- $contactPoint->getTelphone()->getCountryCode()
|
|
|
- );
|
|
|
- $this->assertEquals(
|
|
|
- '102030405',
|
|
|
- $contactPoint->getTelphone()->getNationalNumber()
|
|
|
+ 'email@domain.com',
|
|
|
+ $contactPoint->getEmail()
|
|
|
);
|
|
|
|
|
|
$this->assertEquals(
|
|
|
- '33',
|
|
|
- $contactPoint->getMobilPhone()->getCountryCode()
|
|
|
- );
|
|
|
- $this->assertEquals(
|
|
|
- '607080910',
|
|
|
- $contactPoint->getMobilPhone()->getNationalNumber()
|
|
|
+ $phoneNumber,
|
|
|
+ $contactPoint->getTelphone()
|
|
|
);
|
|
|
|
|
|
$this->assertEquals(
|
|
|
- 'email@domain.com',
|
|
|
- $contactPoint->getEmail()
|
|
|
+ $mobilePhoneNumber,
|
|
|
+ $contactPoint->getMobilPhone()
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ public function testMakeAccessContactPointInvalidPhone(): void
|
|
|
+ {
|
|
|
+ $organizationFactory = $this->getOrganizationFactoryMockFor('makePersonContactPoint');
|
|
|
+
|
|
|
+ $organizationMemberCreationRequest = $this->getMockBuilder(OrganizationMemberCreationRequest::class)->getMock();
|
|
|
+
|
|
|
+ $organizationMemberCreationRequest->method('getPhone')->willReturn('invalid');
|
|
|
+ $organizationMemberCreationRequest->method('getEmail')->willReturn('email@domain.com');
|
|
|
+ $organizationMemberCreationRequest->method('getMobile')->willReturn('+33607080910');
|
|
|
+
|
|
|
+ $this->phoneNumberUtil
|
|
|
+ ->expects(self::once())
|
|
|
+ ->method('isPossibleNumber')
|
|
|
+ ->with('invalid')
|
|
|
+ ->willReturn(false);
|
|
|
+
|
|
|
+ $this->phoneNumberUtil
|
|
|
+ ->expects(self::never())
|
|
|
+ ->method('parse');
|
|
|
+
|
|
|
+ $this->expectException(\RuntimeException::class);
|
|
|
+ $this->expectExceptionMessage('Phone number is invalid or missing');
|
|
|
+
|
|
|
+ $organizationFactory->makePersonContactPoint($organizationMemberCreationRequest);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testMakeAccessContactPointInvalidMobilePhone(): void
|
|
|
+ {
|
|
|
+ $organizationFactory = $this->getOrganizationFactoryMockFor('makePersonContactPoint');
|
|
|
+
|
|
|
+ $organizationMemberCreationRequest = $this->getMockBuilder(OrganizationMemberCreationRequest::class)->getMock();
|
|
|
+
|
|
|
+ $organizationMemberCreationRequest->method('getPhone')->willReturn('+33102030405');
|
|
|
+ $organizationMemberCreationRequest->method('getEmail')->willReturn('email@domain.com');
|
|
|
+ $organizationMemberCreationRequest->method('getMobile')->willReturn('invalid');
|
|
|
+
|
|
|
+ $this->phoneNumberUtil
|
|
|
+ ->expects(self::exactly(2))
|
|
|
+ ->method('isPossibleNumber')
|
|
|
+ ->willReturnMap([
|
|
|
+ ['+33102030405', null, true],
|
|
|
+ ['invalid', null, false],
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $this->phoneNumberUtil
|
|
|
+ ->expects(self::never())
|
|
|
+ ->method('parse');
|
|
|
+
|
|
|
+ $this->expectException(\RuntimeException::class);
|
|
|
+ $this->expectExceptionMessage('Mobile phone number is invalid');
|
|
|
+
|
|
|
+ $organizationFactory->makePersonContactPoint($organizationMemberCreationRequest);
|
|
|
+ }
|
|
|
+
|
|
|
public function testMakePersonContactPointNoMobile(): void
|
|
|
{
|
|
|
$organizationFactory = $this->getOrganizationFactoryMockFor('makePersonContactPoint');
|
|
|
@@ -1547,6 +1612,12 @@ class OrganizationFactoryTest extends TestCase
|
|
|
$organizationMemberCreationRequest->method('getPhone')->willReturn('+33102030405');
|
|
|
$organizationMemberCreationRequest->method('getMobile')->willReturn(null);
|
|
|
|
|
|
+ $this->phoneNumberUtil
|
|
|
+ ->expects(self::once())
|
|
|
+ ->method('isPossibleNumber')
|
|
|
+ ->with('+33102030405')
|
|
|
+ ->willReturn(true);
|
|
|
+
|
|
|
$contactPoint = $organizationFactory->makePersonContactPoint($organizationMemberCreationRequest);
|
|
|
|
|
|
$this->assertEquals(
|