|
|
@@ -1398,6 +1398,11 @@ class OrganizationFactoryTest extends TestCase
|
|
|
$organizationMemberCreationRequest->method('getGivenName')->willReturn('bOBBy');
|
|
|
$organizationMemberCreationRequest->method('getGender')->willReturn(GenderEnum::MISTER);
|
|
|
|
|
|
+ $this->personRepository
|
|
|
+ ->method('findOneBy')
|
|
|
+ ->with(['username' => 'bob'], null)
|
|
|
+ ->willReturn(null);
|
|
|
+
|
|
|
$personAddressPostal = $this->getMockBuilder(PersonAddressPostal::class)->getMock();
|
|
|
$organizationFactory
|
|
|
->expects(self::once())
|
|
|
@@ -1440,6 +1445,37 @@ class OrganizationFactoryTest extends TestCase
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ public function testMakeAccessNewPersonUsernameAlreadyInUse(): void
|
|
|
+ {
|
|
|
+ $organizationFactory = $this->getOrganizationFactoryMockFor('makeAccess');
|
|
|
+
|
|
|
+ $organizationMemberCreationRequest = $this->getMockBuilder(OrganizationMemberCreationRequest::class)->getMock();
|
|
|
+
|
|
|
+ $organizationMemberCreationRequest->method('getUsername')->willReturn('bob');
|
|
|
+ $organizationMemberCreationRequest->method('getName')->willReturn('Bob');
|
|
|
+ $organizationMemberCreationRequest->method('getGivenName')->willReturn('bOBBy');
|
|
|
+ $organizationMemberCreationRequest->method('getGender')->willReturn(GenderEnum::MISTER);
|
|
|
+
|
|
|
+ $person = $this->getMockBuilder(Person::class)->getMock();
|
|
|
+ $this->personRepository
|
|
|
+ ->method('findOneBy')
|
|
|
+ ->with(['username' => 'bob'], null)
|
|
|
+ ->willReturn($person);
|
|
|
+
|
|
|
+ $organizationFactory
|
|
|
+ ->expects(self::never())
|
|
|
+ ->method('makePersonPostalAddress');
|
|
|
+
|
|
|
+ $organizationFactory
|
|
|
+ ->expects(self::never())
|
|
|
+ ->method('makePersonContactPoint');
|
|
|
+
|
|
|
+ $this->expectException(\RuntimeException::class);
|
|
|
+ $this->expectExceptionMessage('Username already in use : bob');
|
|
|
+
|
|
|
+ $organizationFactory->makeAccess($organizationMemberCreationRequest);
|
|
|
+ }
|
|
|
+
|
|
|
public function testMakeAccessExistingPerson(): void
|
|
|
{
|
|
|
$organizationFactory = $this->getOrganizationFactoryMockFor('makeAccess');
|
|
|
@@ -1555,6 +1591,7 @@ class OrganizationFactoryTest extends TestCase
|
|
|
|
|
|
$organizationMemberCreationRequest = $this->getMockBuilder(OrganizationMemberCreationRequest::class)->getMock();
|
|
|
|
|
|
+ $organizationMemberCreationRequest->method('getUsername')->willReturn('bob');
|
|
|
$organizationMemberCreationRequest->method('getPhone')->willReturn('invalid');
|
|
|
$organizationMemberCreationRequest->method('getEmail')->willReturn('email@domain.com');
|
|
|
$organizationMemberCreationRequest->method('getMobile')->willReturn('+33607080910');
|
|
|
@@ -1570,7 +1607,7 @@ class OrganizationFactoryTest extends TestCase
|
|
|
->method('parse');
|
|
|
|
|
|
$this->expectException(\RuntimeException::class);
|
|
|
- $this->expectExceptionMessage('Phone number is invalid or missing');
|
|
|
+ $this->expectExceptionMessage('Phone number is invalid or missing (person: bob)');
|
|
|
|
|
|
$organizationFactory->makePersonContactPoint($organizationMemberCreationRequest);
|
|
|
}
|
|
|
@@ -1581,6 +1618,7 @@ class OrganizationFactoryTest extends TestCase
|
|
|
|
|
|
$organizationMemberCreationRequest = $this->getMockBuilder(OrganizationMemberCreationRequest::class)->getMock();
|
|
|
|
|
|
+ $organizationMemberCreationRequest->method('getUsername')->willReturn('bob');
|
|
|
$organizationMemberCreationRequest->method('getPhone')->willReturn('+33102030405');
|
|
|
$organizationMemberCreationRequest->method('getEmail')->willReturn('email@domain.com');
|
|
|
$organizationMemberCreationRequest->method('getMobile')->willReturn('invalid');
|
|
|
@@ -1598,7 +1636,7 @@ class OrganizationFactoryTest extends TestCase
|
|
|
->method('parse');
|
|
|
|
|
|
$this->expectException(\RuntimeException::class);
|
|
|
- $this->expectExceptionMessage('Mobile phone number is invalid');
|
|
|
+ $this->expectExceptionMessage('Mobile phone number is invalid (person: bob)');
|
|
|
|
|
|
$organizationFactory->makePersonContactPoint($organizationMemberCreationRequest);
|
|
|
}
|