Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
elnurvl committed Sep 5, 2021
1 parent 78689c4 commit eb49d36
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Gateway/GlobalAuthenticationGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/Identity/PersonalDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
24 changes: 19 additions & 5 deletions tests/Service/GlobalAuthenticationServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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],
];
}
}

0 comments on commit eb49d36

Please sign in to comment.