From 135510b46523d64e3c60776cca27820e7106c8a3 Mon Sep 17 00:00:00 2001 From: Elnur Hajiyev Date: Mon, 6 Sep 2021 15:39:09 +0400 Subject: [PATCH] Require `$ProfileID` to be not null rather than not empty So it is possible to send an empty string when using the fake gateway --- src/Service/GlobalAuthenticationService.php | 6 +++--- tests/Service/GlobalAuthenticationServiceTest.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Service/GlobalAuthenticationService.php b/src/Service/GlobalAuthenticationService.php index 7026ff2..83e26a7 100644 --- a/src/Service/GlobalAuthenticationService.php +++ b/src/Service/GlobalAuthenticationService.php @@ -18,11 +18,11 @@ class GlobalAuthenticationService extends ID3BaseService private GlobalAuthenticationGateway $gateway; /** - * @var string The Profile ID to be used when verifying identities via->verifyIdentity(). + * @var ?string The Profile ID to be used when verifying identities via->verifyIdentity(). * * @see self::setProfileId() */ - private string $profileId = ''; + private ?string $profileId = null; /** * @var int The version of the Profile ID to be used when verifying identities via->verifyIdentity(). @@ -99,7 +99,7 @@ public function verifyIdentity(Identity $identity, ?string $customerReference = $gateway = $this->getGateway(); - if (!$this->profileId) { + if ($this->profileId === null) { $error = 'An ID3global Profile ID must be set by calling setProfileId() before calling verifyIdentity().'; throw new LogicException($error); diff --git a/tests/Service/GlobalAuthenticationServiceTest.php b/tests/Service/GlobalAuthenticationServiceTest.php index 3fc6ee9..ef1b5ee 100644 --- a/tests/Service/GlobalAuthenticationServiceTest.php +++ b/tests/Service/GlobalAuthenticationServiceTest.php @@ -120,7 +120,7 @@ public function fakeResponses(): array { return [ ['profile-id', 1, 'customer-1', GlobalAuthenticationGatewayFake::IDENTITY_BAND_ALERT, 20000], - ['profile-id-2', 0, 'customer-2', GlobalAuthenticationGatewayFake::IDENTITY_BAND_REFER, 500], + ['', 0, '', GlobalAuthenticationGatewayFake::IDENTITY_BAND_REFER, 500], ]; } }