diff --git a/src/Gateway/GlobalAuthenticationGateway.php b/src/Gateway/GlobalAuthenticationGateway.php index 717f1bb..00e6a1a 100644 --- a/src/Gateway/GlobalAuthenticationGateway.php +++ b/src/Gateway/GlobalAuthenticationGateway.php @@ -8,7 +8,7 @@ class GlobalAuthenticationGateway extends ID3GlobalBaseGateway { - public function AuthenticateSP(string $profileID, string $profileVersion, string $customerReference, Identity $identity) + public function AuthenticateSP(string $profileID, int $profileVersion, ?string $customerReference, Identity $identity) { $request = new AuthenticateSPRequest(); $request->setCustomerReference($customerReference); diff --git a/src/Identity/PersonalDetails.php b/src/Identity/PersonalDetails.php index 6f4c053..55001d4 100644 --- a/src/Identity/PersonalDetails.php +++ b/src/Identity/PersonalDetails.php @@ -123,6 +123,10 @@ public function setGender(?string $gender): PersonalDetails */ public function setDateOfBirth(?DateTime $birthday): PersonalDetails { + if ($birthday == null) { + return $this; + } + $this->dateOfBirth = $birthday; $this->DOBDay = $birthday->format('d') ?? null; diff --git a/tests/Service/GlobalAuthenticationServiceTest.php b/tests/Service/GlobalAuthenticationServiceTest.php index 0a9e768..32fedf4 100644 --- a/tests/Service/GlobalAuthenticationServiceTest.php +++ b/tests/Service/GlobalAuthenticationServiceTest.php @@ -3,7 +3,7 @@ namespace ID3Global\Tests\Service; use DateTime; -use Exception; +use ID3Global\Exceptions\IdentityVerificationFailureException; use LogicException; use ID3Global\Identity\Identity; use ID3Global\Identity\PersonalDetails; @@ -25,9 +25,14 @@ public function setUp(): void } /** - * @throws Exception + * @dataProvider authenticateSp + * + * @param string|null $customerReference + * @param DateTime|null $birthday + * + * @throws IdentityVerificationFailureException */ - public function testSuccessfulResponse() + public function testSuccessfulResponse(?string $customerReference, ?DateTime $birthday) { // Arrange $personalDetails = new PersonalDetails(); @@ -36,7 +41,7 @@ public function testSuccessfulResponse() ->setMiddleName('White') ->setSurname('Huntsman') ->setGender('Female') - ->setDateOfBirth(DateTime::createFromFormat('Y-m-d', '1976-03-06')); + ->setDateOfBirth($birthday); $identity = new Identity(); $identity->setPersonalDetails($personalDetails); @@ -46,7 +51,7 @@ public function testSuccessfulResponse() // Act $bandText = $this->service ->setProfileId($profileId) - ->verifyIdentity($identity, 'customer reference'); + ->verifyIdentity($identity, $customerReference); // Assert $this->assertSame(GlobalAuthenticationGatewayFake::IDENTITY_BAND_PASS, $bandText); @@ -64,4 +69,13 @@ public function testNotSettingProfileIdThrows() $this->expectException(LogicException::class); $this->service->verifyIdentity($identity); } + + public function authenticateSp(): array + { + return [ + ['customer-reference', DateTime::createFromFormat('Y-m-d', '1976-03-06')], + [null, DateTime::createFromFormat('Y-m-d', '1976-03-06')], + ['customer-reference', null], + ]; + } }