diff --git a/README.md b/README.md index 868c2de4..8bbd648b 100755 --- a/README.md +++ b/README.md @@ -300,7 +300,8 @@ $ ./vendor/bin/phpunit tests ## API Coverage * Activity Details - * [X] RememberMe ID `getRememberMeId()` + * [X] Remember Me ID `getRememberMeId()` + * [X] Parent Remember Me ID `getParentRememberMeId()` * [X] Receipt ID `getReceiptId()` * [X] Timestamp `getTimestamp()` // DateTime Object * [X] Application Profile `getApplicationProfile()` diff --git a/composer.json b/composer.json index 4eb5e340..7d2bc2db 100755 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "yoti/yoti-php-sdk", "description": "Yoti SDK for quickly integrating your PHP backend with Yoti", - "version": "1.2.1", + "version": "2.0.0", "keywords": [ "yoti", "sdk" diff --git a/examples/.env.dev b/examples/.env.dev new file mode 100644 index 00000000..79a10f5f --- /dev/null +++ b/examples/.env.dev @@ -0,0 +1,13 @@ +# This file is a template for defining the environment variables +# Set the application config values here + +YOTI_APP_ID=xxxxxxxxxxxxxxxxxx +YOTI_SCENARIO_ID=xxxxxxxxxxxxxxxx +YOTI_SDK_ID=xxxxxxxxxxxxxxxxxxxxx +# Below is the private key (in .pem format) associated with the Yoti Application you created on Dashboard +YOTI_KEY_FILE_PATH=/path_to_pem_dir/php-sdk-access-security.pem + +# Change the API URLs (optional) +YOTI_CONNECT_API=xxxxxxxxxxxxxxxx +YOTI_QR_URL=xxxxxxxxxxxxxxxx +YOTI_CONNECT_URL=xxxxxxxxxxxxxxxx \ No newline at end of file diff --git a/examples/composer.lock b/examples/composer.lock index 25ba897e..183443eb 100644 --- a/examples/composer.lock +++ b/examples/composer.lock @@ -1,11 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "hash": "7a6c48264e6454ff581a7f0189792926", - "content-hash": "2a81e6ba4478b78c3d08f434b9ed3156", + "content-hash": "5da8436cec4125630cc7875a14bcad6c", "packages": [ { "name": "symfony/dotenv", @@ -62,20 +61,20 @@ "env", "environment" ], - "time": "2017-04-27 07:47:28" + "time": "2017-04-27T07:47:28+00:00" }, { "name": "yoti/yoti-php-sdk", - "version": "1.2.0", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/getyoti/yoti-php-sdk.git", - "reference": "59890106c25a19025e1e0914b56e2c38aa979fc5" + "reference": "b214dc5d69216265ba06c9820f85890bb334d61d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/getyoti/yoti-php-sdk/zipball/59890106c25a19025e1e0914b56e2c38aa979fc5", - "reference": "59890106c25a19025e1e0914b56e2c38aa979fc5", + "url": "https://api.github.com/repos/getyoti/yoti-php-sdk/zipball/b214dc5d69216265ba06c9820f85890bb334d61d", + "reference": "b214dc5d69216265ba06c9820f85890bb334d61d", "shasum": "" }, "require": { @@ -91,12 +90,13 @@ "src/phpseclib/bootstrap.php" ], "psr-4": { - "Attrpubapi_v1\\": "src/attrpubapi_v1", - "Compubapi_v1\\": "src/compubapi_v1", + "Attrpubapi\\": "src/Attrpubapi", + "Compubapi\\": "src/Compubapi", "Google\\Protobuf\\": "src/protobuflib/Google/Protobuf", "GPBMetadata\\": "src/protobuflib/GPBMetadata", "phpseclib\\": "src/phpseclib/", - "Yoti\\": "src/Yoti" + "Yoti\\": "src/Yoti", + "YotiSandbox\\": "sandbox/src" } }, "notification-url": "https://packagist.org/downloads/", @@ -131,7 +131,7 @@ "sdk", "yoti" ], - "time": "2018-06-25 09:59:44" + "time": "2019-01-22T16:04:34+00:00" } ], "packages-dev": [], diff --git a/examples/error.php b/examples/error.php index b787eae7..8ec922c3 100644 --- a/examples/error.php +++ b/examples/error.php @@ -6,6 +6,6 @@

Home

-

Could not login user for the following reason:

+

Could not login user for the following reason:

\ No newline at end of file diff --git a/examples/index.php b/examples/index.php index f78d0ce6..b9b9d4f9 100644 --- a/examples/index.php +++ b/examples/index.php @@ -71,7 +71,13 @@ \ No newline at end of file diff --git a/examples/profile.inc.php b/examples/profile.inc.php index 2d6cb68d..9af880e5 100644 --- a/examples/profile.inc.php +++ b/examples/profile.inc.php @@ -7,8 +7,14 @@ $token = isset($_GET['token']) ? $_GET['token'] : ''; $profileAttributes = []; +// Allow Connect API to be configured. +$connect_api = Yoti\YotiClient::DEFAULT_CONNECT_API; +if (!empty(getenv('YOTI_CONNECT_API'))) { + $connect_api = getenv('YOTI_CONNECT_API'); +} + try { - $yotiClient = new Yoti\YotiClient(getenv('YOTI_SDK_ID'), getenv('YOTI_KEY_FILE_PATH')); + $yotiClient = new Yoti\YotiClient(getenv('YOTI_SDK_ID'), getenv('YOTI_KEY_FILE_PATH'), $connect_api); $activityDetails = $yotiClient->getActivityDetails($token); $profile = $activityDetails->getProfile(); diff --git a/tests/ActivityDetailsTest.php b/tests/ActivityDetailsTest.php index 50e52277..399e1bb8 100644 --- a/tests/ActivityDetailsTest.php +++ b/tests/ActivityDetailsTest.php @@ -9,6 +9,9 @@ use Yoti\Entity\Image; use Yoti\Entity\ApplicationProfile; +/** + * @coversDefaultClass \Yoti\ActivityDetails + */ class ActivityDetailsTest extends TestCase { /** @@ -26,21 +29,30 @@ class ActivityDetailsTest extends TestCase */ public $applicationProfile; - public $rememberMeId = 'Hig2yAT79cWvseSuXcIuCLa5lNkAPy70rxetUaeHlTJGmiwc/g1MWdYWYrexWvPU'; + /** + * @var string Pem file contents. + */ + private $pem; + + /** + * @var array Receipt array. + */ + private $receiptArr; public function setUp() { - $pem = file_get_contents(PEM_FILE); - $receiptArr = json_decode(file_get_contents(RECEIPT_JSON), true); - $receipt = new Receipt($receiptArr['receipt']); - - $this->activityDetails = new ActivityDetails($receipt, $pem); + $this->pem = file_get_contents(PEM_FILE); + $this->receiptArr = json_decode(file_get_contents(RECEIPT_JSON), true)['receipt']; + $this->activityDetails = new ActivityDetails( + new Receipt($this->receiptArr), + $this->pem + ); $this->profile = $this->activityDetails->getProfile(); $this->applicationProfile = $this->activityDetails->getApplicationProfile(); } /** - * Test getting ActivityDetails Instance + * Test getting ActivityDetails Instance. */ public function testActivityDetailsInstance() { @@ -48,26 +60,60 @@ public function testActivityDetailsInstance() } /** - * Test getting RememberMeId + * @covers ::getRememberMeId */ public function testGetRememberMeId() { - $this->assertEquals($this->rememberMeId, $this->activityDetails->getRememberMeId()); + $rememberMeId = 'Hig2yAT79cWvseSuXcIuCLa5lNkAPy70rxetUaeHlTJGmiwc/g1MWdYWYrexWvPU'; + $this->assertEquals($rememberMeId, $this->activityDetails->getRememberMeId()); } + /** + * @covers ::getRememberMeId + */ + public function testGetRememberMeIdNotPresent() + { + // Remove Remember Me ID from test receipt. + unset($this->receiptArr['remember_me_id']); + $receipt = new Receipt($this->receiptArr); + + $activityDetails = new ActivityDetails($receipt, $this->pem); + $this->assertNull($activityDetails->getRememberMeId()); + } + + /** + * @covers ::getRememberMeId + */ + public function testGetRememberMeIdEmpty() + { + // Set Remember Me ID to empty string. + $this->receiptArr['remember_me_id'] = ''; + $receipt = new Receipt($this->receiptArr); + + $activityDetails = new ActivityDetails($receipt, $this->pem); + $this->assertEquals('', $activityDetails->getRememberMeId()); + } + + /** + * @covers ::getParentRememberMeId + */ public function testGetParentRememberMeIdExists() { - $this->assertTrue(method_exists($this->activityDetails, 'getParentRememberMeId')); + $parentRememberMeId = 'f5RjVQMyoKOvO/hkv43Ik+t6d6mGfP2tdrNijH4k4qafTG0FSNUgQIvd2Z3Nx1j8'; + $this->assertEquals($parentRememberMeId, $this->activityDetails->getParentRememberMeId()); } /** - * Test getting Given Names + * @covers ::getProfile */ public function testGetProfile() { $this->assertInstanceOf(Profile::class, $this->activityDetails->getProfile()); } + /** + * @covers ::getApplicationProfile + */ public function testGetApplicationProfile() { $this->assertInstanceOf( @@ -77,7 +123,7 @@ public function testGetApplicationProfile() } /** - * Test getting Family Name + * @covers \Yoti\Entity\Profile::getFamilyName */ public function testGetFamilyName() { @@ -85,7 +131,7 @@ public function testGetFamilyName() } /** - * Test getting Full Name + * @covers \Yoti\Entity\Profile::getFullName */ public function testGetFullName() { @@ -93,7 +139,7 @@ public function testGetFullName() } /** - * Test getting Date Of Birth + * @covers \Yoti\Entity\Profile::getDateOfBirth */ public function testGetDateOfBirth() { @@ -101,7 +147,8 @@ public function testGetDateOfBirth() } /** - * Test getting Phone Number + * @covers \Yoti\Entity\Profile::getPhoneNumber + * @covers \Yoti\Entity\Attribute::getValue */ public function testGetPhoneNumber() { @@ -109,7 +156,7 @@ public function testGetPhoneNumber() } /** - * Test getting Email Address + * @covers \Yoti\Entity\Profile::getEmailAddress */ public function testGetEmailAddress() { @@ -117,7 +164,8 @@ public function testGetEmailAddress() } /** - * Test getting Selfie + * @covers \Yoti\Entity\Profile::getSelfie + * @covers \Yoti\Entity\Attribute::getValue */ public function testGetSelfie() { @@ -125,15 +173,21 @@ public function testGetSelfie() $this->assertInstanceOf(Image::class, $this->profile->getSelfie()->getValue()); } + /** + * ::getTimestamp + */ public function testGetTimestamp() { $timestamp = $this->activityDetails->getTimestamp(); $this->assertEquals('19-07-2016 08:55:38', $timestamp->format('d-m-Y H:i:s')); } + /** + * ::getReceiptId + */ public function testGetReceipt() { $receiptId = '9HNJDX5bEIN5TqBm0OGzVIc1LaAmbzfx6eIrwNdwpHvKeQmgPujyogC+r7hJCVPl'; $this->assertEquals($receiptId, $this->activityDetails->getReceiptId()); } -} \ No newline at end of file +} diff --git a/tests/Entity/AnchorTest.php b/tests/Entity/AnchorTest.php index 7b80baef..91cd2583 100644 --- a/tests/Entity/AnchorTest.php +++ b/tests/Entity/AnchorTest.php @@ -8,13 +8,25 @@ use YotiTest\Util\Profile\TestAnchors; use Yoti\Util\Profile\AnchorListConverter; +/** + * @coversDefaultClass \Yoti\Entity\Anchor + */ class AnchorTest extends TestCase { + /** + * Check Anchor class exists. + */ public function testAnchorClassExists() { $this->assertTrue(class_exists(Anchor::class)); } + /** + * @covers ::getType + * @covers ::getValue + * @covers ::getSignedTimeStamp + * @covers ::getOriginServerCerts + */ public function testYotiAnchorEndpoints() { $dlAnchor = new \Attrpubapi\Anchor(); @@ -43,4 +55,4 @@ public function testYotiAnchorEndpoints() $sourceAnchor->getOriginServerCerts()[0] ); } -} \ No newline at end of file +} diff --git a/tests/Entity/ApplicationProfileTest.php b/tests/Entity/ApplicationProfileTest.php index bafca2ca..59d33a79 100644 --- a/tests/Entity/ApplicationProfileTest.php +++ b/tests/Entity/ApplicationProfileTest.php @@ -6,6 +6,9 @@ use YotiTest\TestCase; use Yoti\Entity\ApplicationProfile; +/** + * @coversDefaultClass \Yoti\Entity\ApplicationProfile + */ class ApplicationProfileTest extends TestCase { /** @@ -16,14 +19,17 @@ class ApplicationProfileTest extends TestCase public function setup() { $dummyData = [ - 'application_name' => new Attribute('application_name','Test PHP SDK',[]), + 'application_name' => new Attribute('application_name', 'Test PHP SDK', []), 'application_url' => new Attribute('application_url', 'https://localhost', []), 'application_receipt_bgcolor' => new Attribute('application_receipt_bgcolor', '#F5F5F5', []), - 'application_logo' => new Attribute('application_logo', new Image('dummyImageData','png'), []), + 'application_logo' => new Attribute('application_logo', new Image('dummyImageData', 'png'), []), ]; $this->dummyProfile = new ApplicationProfile($dummyData); } + /** + * @covers ::getApplicationName + */ public function testGetApplicationName() { $this->assertEquals( @@ -32,6 +38,9 @@ public function testGetApplicationName() ); } + /** + * @covers ::getApplicationUrl + */ public function testGetApplicationUrl() { $this->assertEquals( @@ -40,6 +49,9 @@ public function testGetApplicationUrl() ); } + /** + * @covers ::getApplicationReceiptBgColor + */ public function testGetApplicationReceiptBgColor() { $this->assertEquals( @@ -48,6 +60,10 @@ public function testGetApplicationReceiptBgColor() ); } + /** + * @covers ::getApplicationLogo + * @covers \Yoti\Entity\Image::getContent + */ public function testGetApplicationLogoImageData() { $this->assertEquals( @@ -56,6 +72,10 @@ public function testGetApplicationLogoImageData() ); } + /** + * @covers ::getApplicationLogo + * @covers \Yoti\Entity\Image::getMimeType + */ public function testGetApplicationLogoImageType() { $this->assertEquals( @@ -63,4 +83,4 @@ public function testGetApplicationLogoImageType() $this->dummyProfile->getApplicationLogo()->getValue()->getMimeType() ); } -} \ No newline at end of file +} diff --git a/tests/Entity/AttributeTest.php b/tests/Entity/AttributeTest.php index 5e04eeb0..555e27d0 100644 --- a/tests/Entity/AttributeTest.php +++ b/tests/Entity/AttributeTest.php @@ -9,12 +9,15 @@ use YotiTest\Util\Profile\TestAnchors; use Yoti\Util\Profile\AnchorListConverter; +/** + * @coversDefaultClass \Yoti\Entity\Attribute + */ class AttributeTest extends TestCase { const ATTR_VALUE = 'Test FullName'; /** - * @var Attribute + * @var \Yoti\Entity\Attribute */ public $dummyAttribute; @@ -33,16 +36,25 @@ public function setup() ); } + /** + * @covers ::getName + */ public function testAttributeName() { $this->assertEquals(Profile::ATTR_FULL_NAME, $this->dummyAttribute->getName()); } + /** + * @covers ::getValue + */ public function testAttributeValue() { $this->assertEquals(self::ATTR_VALUE, $this->dummyAttribute->getValue()); } + /** + * @covers ::getSources + */ public function testGetSources() { $sources = $this->dummyAttribute->getSources(); @@ -59,6 +71,9 @@ public function testGetSources() ); } + /** + * @covers ::getVerifiers + */ public function testVerifiers() { $verifiers = $this->dummyAttribute->getVerifiers(); @@ -72,6 +87,9 @@ public function testVerifiers() ); } + /** + * @covers ::getAnchors + */ public function testGetAnchors() { $anchors = $this->dummyAttribute->getAnchors(); @@ -84,10 +102,16 @@ public function testGetAnchors() $this->assertEquals('YOTI_ADMIN', $anchors[2]->getValue()); } + /** + * Convert anchor string to Protobuf Anchor + * + * @param string $anchorString + * @return \Attrpubapi\Anchor + */ public function convertToProtobufAnchor($anchorString) { $anchor = new \Attrpubapi\Anchor(); $anchor->mergeFromString(base64_decode($anchorString)); return $anchor; } -} \ No newline at end of file +} diff --git a/tests/Entity/DocumentDetailsTest.php b/tests/Entity/DocumentDetailsTest.php index bde9e734..4309ed51 100644 --- a/tests/Entity/DocumentDetailsTest.php +++ b/tests/Entity/DocumentDetailsTest.php @@ -4,6 +4,9 @@ use Yoti\Entity\DocumentDetails; use YotiTest\TestCase; +/** + * @coversDefaultClass \Yoti\Entity\DocumentDetails + */ class DocumentDetailsTest extends TestCase { /** @@ -17,6 +20,12 @@ public function setup() $this->dummyDocumentDetails = new DocumentDetails($dummyValue); } + /** + * @covers ::getType + * @covers ::getIssuingCountry + * @covers ::getDocumentNumber + * @covers ::getExpirationDate + */ public function testShouldParseOneOptionalAttribute() { $document = new DocumentDetails('PASSPORT GBR 01234567 2020-01-01'); @@ -26,6 +35,13 @@ public function testShouldParseOneOptionalAttribute() $this->assertEquals('2020-01-01', $document->getExpirationDate()->format('Y-m-d')); } + /** + * @covers ::getType + * @covers ::getIssuingCountry + * @covers ::getDocumentNumber + * @covers ::getExpirationDate + * @covers ::getIssuingAuthority + */ public function testShouldParseTwoOptionalAttributes() { $document = new DocumentDetails('DRIVING_LICENCE GBR 1234abc 2016-05-01 DVLA'); @@ -36,24 +52,40 @@ public function testShouldParseTwoOptionalAttributes() $this->assertEquals('DVLA', $document->getIssuingAuthority()); } + /** + * @covers ::__construct + */ public function testShouldThrowExceptionWhenValueIsEmpty() { $this->expectException('Yoti\Exception\AttributeException'); $document = new DocumentDetails(''); } + /** + * @covers ::__construct + */ public function testShouldThrowExceptionForInvalidCountry() { $this->expectException('Yoti\Exception\AttributeException'); $document = new DocumentDetails('PASSPORT 13 1234abc 2016-05-01'); } + /** + * @covers ::__construct + */ public function testShouldThrowExceptionForInvalidNumber() { $this->expectException('Yoti\Exception\AttributeException'); $document = new DocumentDetails("PASSPORT GBR $%^$%^£ 2016-05-01"); } + /** + * @covers ::getType + * @covers ::getIssuingCountry + * @covers ::getDocumentNumber + * @covers ::getExpirationDate + * @covers ::getIssuingAuthority + */ public function testWhenExpirationDateIsMissing() { $document = new DocumentDetails('PASS_CARD GBR 22719564893 - CITIZENCARD'); @@ -64,18 +96,31 @@ public function testWhenExpirationDateIsMissing() $this->assertEquals('CITIZENCARD', $document->getIssuingAuthority()); } + /** + * @covers ::__construct + */ public function testWhenTheValueIsLessThanThreeWords() { $this->expectException('Yoti\Exception\AttributeException'); $documentDetails = new DocumentDetails('PASS_CARD GBR'); } + /** + * @covers ::__construct + */ public function testShouldThrowExceptionForInvalidDate() { $this->expectException('Yoti\Exception\AttributeException'); $document = new DocumentDetails('PASSPORT GBR 1234abc X016-05-01'); } + /** + * @covers ::getType + * @covers ::getIssuingCountry + * @covers ::getDocumentNumber + * @covers ::getExpirationDate + * @covers ::getIssuingAuthority + */ public function testShouldIgnoreTheSixthOptionalAttribute() { $value = 'DRIVING_LICENCE GBR 1234abc 2016-05-01 DVLA someThirdAttribute'; @@ -87,4 +132,4 @@ public function testShouldIgnoreTheSixthOptionalAttribute() $this->assertEquals('2016-05-01', $document->getExpirationDate()->format('Y-m-d')); $this->assertEquals('DVLA', $document->getIssuingAuthority()); } -} \ No newline at end of file +} diff --git a/tests/Entity/ImageTest.php b/tests/Entity/ImageTest.php index 68081a6c..c3df7113 100644 --- a/tests/Entity/ImageTest.php +++ b/tests/Entity/ImageTest.php @@ -4,10 +4,13 @@ use Yoti\Entity\Image; use YotiTest\TestCase; +/** + * @coversDefaultClass \Yoti\Entity\Image + */ class ImageTest extends TestCase { /** - * @var Image + * @var \Yoti\Entity\Image */ public $dummyImage; @@ -16,25 +19,37 @@ public function setup() $this->dummyImage = new Image('dummyImageData', 'png'); } + /** + * @covers ::getMimeType + */ public function testGetMimeType() { $this->assertEquals('image/png', $this->dummyImage->getMimeType()); } + /** + * @covers ::getContent + */ public function testGetContent() { $this->assertEquals('dummyImageData', $this->dummyImage->getContent()); } + /** + * @covers ::getBase64Content + */ public function testGetBase64Content() { $expectedValue = 'data:image/png;base64,ZHVtbXlJbWFnZURhdGE='; $this->assertEquals($expectedValue, $this->dummyImage->getBase64Content()); } + /** + * @covers ::__construct + */ public function testShouldThrowExceptionForUnsupportedExtension() { $this->expectException("\Yoti\Exception\AttributeException"); $image = new Image('dummyImageData', 'bmp'); } -} \ No newline at end of file +} diff --git a/tests/Entity/ProfileTest.php b/tests/Entity/ProfileTest.php index 8575b3c6..cbc5d7ff 100644 --- a/tests/Entity/ProfileTest.php +++ b/tests/Entity/ProfileTest.php @@ -7,21 +7,29 @@ use Yoti\Entity\Attribute; use Yoti\Entity\AgeVerification; +/** + * @coversDefaultClass \Yoti\Entity\Profile + */ class ProfileTest extends TestCase { /** * @var \Yoti\Entity\Profile */ public $profile; + /** * @var \Yoti\YotiClient */ public $yotiClient; + /** * @var string */ public $expectedPhoneNumber; + /** + * @var Array Structured Postal Address + */ public $dummyStructuredPostalAddress; public function setup() @@ -55,18 +63,34 @@ public function setup() $this->profile = $activityDetails->getProfile(); } + /** + * @covers \Yoti\Entity\Attribute::getValue + * @covers ::getPhoneNumber + * @covers ::getProfileAttribute + */ public function testGetAttributeValue() { $phoneNumber = $this->profile->getPhoneNumber(); + $this->assertInstanceOf(Attribute::class, $phoneNumber); $this->assertEquals($this->expectedPhoneNumber, $phoneNumber->getValue()); } + /** + * @covers \Yoti\Entity\Attribute::getName + * @covers ::getPhoneNumber + * @covers ::getProfileAttribute + */ public function testGetAttributeName() { $phoneNumber = $this->profile->getPhoneNumber(); + $this->assertInstanceOf(Attribute::class, $phoneNumber); $this->assertEquals('phone_number', $phoneNumber->getName()); } + /** + * @covers ::getPostalAddress + * @covers ::getStructuredPostalAddress + */ public function testShouldReturnFormattedAddressAsPostalAddressWhenNull() { $structuredPostalAddress = new Attribute( @@ -95,18 +119,26 @@ public function testShouldReturnFormattedAddressAsPostalAddressWhenNull() /** * Should not return age_verifications in the array + * + * @covers ::getAttributes + * @dataProvider getDummyProfileDataWithAgeVerifications */ - public function testGetAttributes() + public function testGetAttributes($profileData) { - $profileData = $this->getDummyProfileDataWithAgeVerifications(); $profile = new Profile($profileData); $this->assertArrayNotHasKey(Profile::ATTR_AGE_VERIFICATIONS, $profile->getAttributes()); } - public function testFindAgeOverVerification() + /** + * @covers ::findAgeOverVerification + * @covers \Yoti\Entity\AgeVerification::getCheckType + * @covers \Yoti\Entity\AgeVerification::getAge + * @covers \Yoti\Entity\AgeVerification::getResult + * @dataProvider getDummyProfileDataWithAgeVerifications + */ + public function testFindAgeOverVerification($profileData) { - $profileData = $this->getDummyProfileDataWithAgeVerifications(); $profile = new Profile($profileData); $ageOver35 = $profile->findAgeOverVerification(35); @@ -116,9 +148,15 @@ public function testFindAgeOverVerification() $this->assertTrue($ageOver35->getResult()); } - public function testFindAgeUnderVerification() + /** + * @covers ::findAgeUnderVerification + * @covers \Yoti\Entity\AgeVerification::getCheckType + * @covers \Yoti\Entity\AgeVerification::getAge + * @covers \Yoti\Entity\AgeVerification::getResult + * @dataProvider getDummyProfileDataWithAgeVerifications + */ + public function testFindAgeUnderVerification($profileData) { - $profileData = $this->getDummyProfileDataWithAgeVerifications(); $profile = new Profile($profileData); $ageUnder18 = $profile->findAgeUnderVerification(18); @@ -128,6 +166,9 @@ public function testFindAgeUnderVerification() $this->assertFalse($ageUnder18->getResult()); } + /** + * Profile data provider with age verifications. + */ public function getDummyProfileDataWithAgeVerifications() { $profileData = [ @@ -164,6 +205,6 @@ public function getDummyProfileDataWithAgeVerifications() [] ), ]; - return $profileData; + return [[$profileData]]; } -} \ No newline at end of file +} diff --git a/tests/Entity/ReceiptTest.php b/tests/Entity/ReceiptTest.php index c491ddf0..98559177 100644 --- a/tests/Entity/ReceiptTest.php +++ b/tests/Entity/ReceiptTest.php @@ -7,10 +7,21 @@ use Yoti\Entity\ApplicationProfile; use Yoti\Util\Profile\AttributeListConverter; +/** + * @coversDefaultClass \Yoti\Entity\Receipt + */ class ReceiptTest extends TestCase { + /** + * @var string Pem file contents. + */ public $pem; + /** + * @var array Receipt array. + */ + private $receiptArr; + /** * @var Receipt */ @@ -19,32 +30,67 @@ class ReceiptTest extends TestCase public function setup() { $this->pem = file_get_contents(PEM_FILE); - $receiptArr = json_decode(file_get_contents(RECEIPT_JSON), true); - $this->receipt = new Receipt($receiptArr['receipt']); + $this->receiptArr = json_decode(file_get_contents(RECEIPT_JSON), true)['receipt']; + $this->receipt = new Receipt($this->receiptArr); } + /** + * @covers ::__construct + */ public function testShouldThrowExceptionForInvalidReceipt() { $this->expectException('\Yoti\Exception\ReceiptException'); $receipt = new Receipt([]); } + /** + * @covers ::getTimestamp + */ public function testGetTimestamp() { $this->assertEquals('2016-07-19T08:55:38Z', $this->receipt->getTimestamp()); } + /** + * @covers ::getRememberMeId + */ public function testGetRememberMeId() { $expectedRememberMeId = 'Hig2yAT79cWvseSuXcIuCLa5lNkAPy70rxetUaeHlTJGmiwc/g1MWdYWYrexWvPU'; $this->assertEquals($expectedRememberMeId, $this->receipt->getRememberMeId()); } + /** + * @covers ::getRememberMeId + */ + public function testGetRememberMeIdNotPresent() + { + unset($this->receiptArr['remember_me_id']); + $receipt = new Receipt($this->receiptArr); + $this->assertNull($receipt->getRememberMeId()); + } + + /** + * @covers ::getRememberMeId + */ + public function testGetRememberMeIdEmpty() + { + $this->receiptArr['remember_me_id'] = ''; + $receipt = new Receipt($this->receiptArr); + $this->assertEquals('', $receipt->getRememberMeId()); + } + + /** + * @covers ::getSharingOutcome + */ public function testGetSharingOutcome() { $this->assertEquals('SUCCESS', $this->receipt->getSharingOutcome()); } + /** + * @covers ::getReceiptId + */ public function testGetReceiptId() { $expectedReceiptId = '9HNJDX5bEIN5TqBm0OGzVIc1LaAmbzfx6eIrwNdwpHvKeQmgPujyogC+r7hJCVPl'; @@ -54,6 +100,9 @@ public function testGetReceiptId() ); } + /** + * @covers ::parseAttribute + */ public function testShouldParseOtherPartyProfileContent() { $protobufAttributesList = $this->receipt->parseAttribute( @@ -67,6 +116,9 @@ public function testShouldParseOtherPartyProfileContent() $this->assertEquals('+447474747474', $profile->getPhoneNumber()->getValue()); } + /** + * @covers ::parseAttribute + */ public function testShouldParseProfileContent() { $protobufAttributesList = $this->receipt->parseAttribute( @@ -83,4 +135,4 @@ public function testShouldParseProfileContent() $this->assertEquals('Node SDK Test', $applicationProfile->getApplicationName()->getValue()); $this->assertEquals('#ffffff', $applicationProfile->getApplicationReceiptBgColor()->getValue()); } -} \ No newline at end of file +} diff --git a/tests/Http/AmlResultTest.php b/tests/Http/AmlResultTest.php index 76ef5239..6c6e10ab 100644 --- a/tests/Http/AmlResultTest.php +++ b/tests/Http/AmlResultTest.php @@ -5,6 +5,9 @@ use Yoti\Http\AmlResult; use YotiTest\TestCase; +/** + * @coversDefaultClass \Yoti\Http\AmlResult + */ class AmlResultTest extends TestCase { /** @@ -14,22 +17,31 @@ class AmlResultTest extends TestCase public function setup() { - $resultArr = json_decode(file_get_contents(AML_CHECK_RESULT_JSON), TRUE); + $resultArr = json_decode(file_get_contents(AML_CHECK_RESULT_JSON), true); $this->amlResult = new AmlResult($resultArr); } + /** + * @covers ::isOnPepList + */ public function testIsOnPepeList() { $this->assertTrue($this->amlResult->isOnPepList()); } + /** + * @covers ::isOnFraudList + */ public function testIsOnFraudList() { $this->assertFalse($this->amlResult->isOnFraudList()); } + /** + * @covers ::isOnWatchList + */ public function testIsOnWatchList() { $this->assertFalse($this->amlResult->isOnWatchList()); } -} \ No newline at end of file +} diff --git a/tests/Http/CurlRequestHandlerTest.php b/tests/Http/CurlRequestHandlerTest.php index f4ffec68..3a31f183 100644 --- a/tests/Http/CurlRequestHandlerTest.php +++ b/tests/Http/CurlRequestHandlerTest.php @@ -12,30 +12,37 @@ use Yoti\Http\CurlRequestHandler; use Yoti\Http\AbstractRequestHandler; +/** + * @coversDefaultClass \Yoti\Http\CurlRequestHandler + */ class CurlRequestHandlerTest extends TestCase { + /** + * @var string Pem file contents + */ public $pem; + /** * @var CurlRequestHandler */ public $requestHandler; + /** - * @var Payload + * @var \Yoti\Http\Payload */ public $payload; + /** + * @var Yoti\Http\RequestSigner + */ public $requestSigner; - public $postMethod = CurlRequestHandler::METHOD_POST; - public function setup() { $endpoint = '/aml-check'; $amlAddress = new AmlAddress(new Country('GBR')); $amlProfile = new AmlProfile('Edward Richard George', 'Heath', $amlAddress); $this->payload = new Payload($amlProfile->getData()); - $this->postMethod = CurlRequestHandler::METHOD_POST; - $this->pem = file_get_contents(PEM_FILE); $this->requestSigner = new RequestSigner( @@ -52,16 +59,25 @@ public function setup() ); } + /** + * @covers ::getPem + */ public function testGetPem() { $this->assertEquals($this->pem, $this->requestHandler->getPem()); } + /** + * @covers ::getSdkId + */ public function testGetSdkId() { $this->assertEquals(SDK_ID, $this->requestHandler->getSdkId()); } + /** + * @covers ::sendRequest + */ public function testInvalidHttpMethod() { $this->expectException('\Yoti\Exception\RequestException'); @@ -72,11 +88,17 @@ public function testInvalidHttpMethod() ); } + /** + * @covers ::sendRequest + */ public function testClassIsInstanceOfAbstractRequestHandler() { $this->assertInstanceOf(AbstractRequestHandler::class, $this->requestHandler); } + /** + * @covers ::sendRequest + */ public function testSendRequest() { $expectedResult['response'] = file_get_contents(RECEIPT_JSON); @@ -96,4 +118,4 @@ public function testSendRequest() ); $this->assertEquals(json_encode($expectedResult), json_encode($result)); } -} \ No newline at end of file +} diff --git a/tests/Http/PayloadTest.php b/tests/Http/PayloadTest.php index 1dd16715..7a57aae3 100644 --- a/tests/Http/PayloadTest.php +++ b/tests/Http/PayloadTest.php @@ -8,6 +8,9 @@ use Yoti\Http\Payload; use YotiTest\TestCase; +/** + * @coversDefaultClass \Yoti\Http\Payload + */ class PayloadTest extends TestCase { /** @@ -32,12 +35,16 @@ public function setup() $this->payload = new Payload($amlProfile->getData()); // Expected test data - $this->payloadJSON = '{"given_names":"Edward Richard George","family_name":"Heath","ssn":null,"address":{"post_code":null,"country":"GBR"}}'; - $this->base64Payload = 'eyJnaXZlbl9uYW1lcyI6IkVkd2FyZCBSaWNoYXJkIEdlb3JnZSIsImZhbWlseV9uYW1lIjoiSGVhdGgiLCJzc24iOm51bGwsImFkZHJlc3MiOnsicG9zdF9jb2RlIjpudWxsLCJjb3VudHJ5IjoiR0JSIn19'; + $this->payloadJSON = '{"given_names":"Edward Richard George","family_name":"Heath",' . + '"ssn":null,"address":{"post_code":null,"country":"GBR"}}'; + $this->base64Payload = 'eyJnaXZlbl9uYW1lcyI6IkVkd2FyZCBSaWNoYXJkIEdlb3JnZSIsImZhbWls' . + 'eV9uYW1lIjoiSGVhdGgiLCJzc24iOm51bGwsImFkZHJlc3MiOnsicG9zdF9jb2RlIjpudWxsLCJjb3VudHJ5IjoiR0JSIn19'; } /** * Test getting Payload data as a JSON string. + * + * @covers ::getPayloadJSON */ public function testGetPayloadJSON() { @@ -46,21 +53,30 @@ public function testGetPayloadJSON() /** * Test getting Payload data as a Base64 string. + * + * @covers ::getBase64Payload */ public function testGetBase64Payload() { $this->assertEquals($this->base64Payload, $this->payload->getBase64Payload()); } + /** + * @covers ::getRawData + */ public function testGetRawData() { $this->assertEquals($this->payloadJSON, json_encode($this->payload->getRawData())); } + /** + * @covers ::__construct + * @covers ::getPayloadJSON + */ public function testPassingAStringAsPayloadData() { $payloadData = 'payloadDataAsAString'; $payload = new Payload($payloadData); $this->assertEquals(json_encode($payloadData), $payload->getPayloadJSON()); } -} \ No newline at end of file +} diff --git a/tests/Http/RequestSignerTest.php b/tests/Http/RequestSignerTest.php index a4d31de5..99261506 100644 --- a/tests/Http/RequestSignerTest.php +++ b/tests/Http/RequestSignerTest.php @@ -11,17 +11,20 @@ use Yoti\Entity\AmlProfile; use Yoti\Http\RequestSigner; +/** + * @coversDefaultClass \Yoti\Http\RequestSigner + */ class RequestSignerTest extends TestCase { /** - * @var Payload + * @var \Yoti\Http\Payload */ public $payload; + /** - * @var CurlRequestHandler + * @var \Yoti\Http\CurlRequestHandler */ public $request; - public $messageToSign; public function setup() { @@ -30,14 +33,14 @@ public function setup() $this->request = new CurlRequestHandler( YotiClient::DEFAULT_CONNECT_API, - $pem , + $pem, SDK_ID, 'PHP' ); } /** - * Test verifying a signed message. + * @covers ::signRequest */ public function testShouldVerifySignedMessage() { @@ -58,6 +61,11 @@ public function testShouldVerifySignedMessage() $this->assertEquals(1, $verify); } + /** + * Dummy request payload + * + * @return \Yoti\Http\Payload + */ public function getDummyPayload() { $amlAddress = new AmlAddress(new Country('GBR')); @@ -65,13 +73,23 @@ public function getDummyPayload() return new Payload($amlProfile->getData()); } + /** + * Dummy private key + * + * @return string + */ public function getDummyPrivateKey() { return file_get_contents(AML_PRIVATE_KEY); } + /** + * Dummy public key + * + * @return string + */ public function getDummyPublicKey() { return file_get_contents(AML_PUBLIC_KEY); } -} \ No newline at end of file +} diff --git a/tests/TestCase.php b/tests/TestCase.php index eaa3f79a..455e8632 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -7,4 +7,4 @@ class TestCase extends PHPUnit_Framework_TestCase { -} \ No newline at end of file +} diff --git a/tests/Util/Age/AgeOverVerificationProcessorTest.php b/tests/Util/Age/AgeOverVerificationProcessorTest.php index 7c5941ee..46311a6f 100644 --- a/tests/Util/Age/AgeOverVerificationProcessorTest.php +++ b/tests/Util/Age/AgeOverVerificationProcessorTest.php @@ -6,8 +6,17 @@ use Yoti\Entity\AgeVerification; use Yoti\Util\Age\AgeOverVerificationProcessor; +/** + * @coversDefaultClass \Yoti\Util\Age\AgeOverVerificationProcessor + */ class AgeOverVerificationProcessorTest extends TestCase { + /** + * @covers ::process + * @covers \Yoti\Entity\AgeVerification::getResult + * @covers \Yoti\Entity\AgeVerification::getCheckType + * @covers \Yoti\Entity\AgeVerification::getAge + */ public function testProcessWithAgeOver() { $ageAttribute = new Attribute('age_over:18', 'true', []); @@ -19,6 +28,12 @@ public function testProcessWithAgeOver() $this->assertEquals(18, $ageVerificationObj->getAge()); } + /** + * @covers ::process + * @covers \Yoti\Entity\AgeVerification::getResult + * @covers \Yoti\Entity\AgeVerification::getCheckType + * @covers \Yoti\Entity\AgeVerification::getAge + */ public function testForAgeOver20ShouldReturnTrue() { $ageAttribute = new Attribute('age_over:20', 'true', []); @@ -30,10 +45,13 @@ public function testForAgeOver20ShouldReturnTrue() $this->assertEquals(20, $ageVerificationObj->getAge()); } + /** + * @covers ::process + */ public function testWhenThereIsNotAgeOverShouldReturnNull() { $ageAttribute = new Attribute('age_under:20', 'false', []); $ageOverVerificationProcessor = new AgeOverVerificationProcessor($ageAttribute); $this->assertNull($ageOverVerificationProcessor->process()); } -} \ No newline at end of file +} diff --git a/tests/Util/Age/AgeUnderVerificationProcessorTest.php b/tests/Util/Age/AgeUnderVerificationProcessorTest.php index bf6b14ad..16ac1f54 100644 --- a/tests/Util/Age/AgeUnderVerificationProcessorTest.php +++ b/tests/Util/Age/AgeUnderVerificationProcessorTest.php @@ -6,8 +6,17 @@ use Yoti\Entity\AgeVerification; use Yoti\Util\Age\AgeUnderVerificationProcessor; +/** + * @coversDefaultClass \Yoti\Util\Age\AgeUnderVerificationProcessor + */ class AgeUnderVerificationProcessorTest extends TestCase { + /** + * @covers ::process + * @covers \Yoti\Entity\AgeVerification::getResult + * @covers \Yoti\Entity\AgeVerification::getCheckType + * @covers \Yoti\Entity\AgeVerification::getAge + */ public function testProcessWithAgeUnder() { $ageAttribute = new Attribute('age_under:18', 'false', []); @@ -19,6 +28,12 @@ public function testProcessWithAgeUnder() $this->assertEquals(18, $ageVerificationObj->getAge()); } + /** + * @covers ::process + * @covers \Yoti\Entity\AgeVerification::getResult + * @covers \Yoti\Entity\AgeVerification::getCheckType + * @covers \Yoti\Entity\AgeVerification::getAge + */ public function testForAgeUnder20ShouldReturnTrue() { $ageAttribute = new Attribute('age_under:20', 'true', []); @@ -30,10 +45,13 @@ public function testForAgeUnder20ShouldReturnTrue() $this->assertEquals(20, $ageVerificationObj->getAge()); } + /** + * @covers ::process + */ public function testWhenThereIsNotAgeUnderShouldReturnNull() { $ageAttribute = new Attribute('age_over:20', 'false', []); $ageUnderVerificationProcessor = new AgeUnderVerificationProcessor($ageAttribute); $this->assertNull($ageUnderVerificationProcessor->process()); } -} \ No newline at end of file +} diff --git a/tests/Util/Age/AgeVerificationConverterTest.php b/tests/Util/Age/AgeVerificationConverterTest.php index 126bc409..b4c061b9 100644 --- a/tests/Util/Age/AgeVerificationConverterTest.php +++ b/tests/Util/Age/AgeVerificationConverterTest.php @@ -8,8 +8,14 @@ use Yoti\Entity\AgeVerification; use Yoti\Util\Age\AgeVerificationConverter; +/** + * @coversDefaultClass \Yoti\Util\Age\AgeVerificationConverter + */ class AgeVerificationConverterTest extends TestCase { + /** + * @covers ::getAgeVerificationsFromAttrsMap + */ public function testGetAgeVerificationsFromAttrsMap() { $ageAttribute = new Attribute('age_under:18', 'true', []); @@ -24,6 +30,9 @@ public function testGetAgeVerificationsFromAttrsMap() $this->assertInstanceOf(Attribute::class, $ageUnder18->getAttribute()); } + /** + * @covers ::getAgeVerificationsFromAttrsMap + */ public function testMultipleAgeDerivations() { $profileData = [ @@ -49,6 +58,9 @@ public function testMultipleAgeDerivations() $this->assertArrayNotHasKey('age_breaker:50', $ageVerifications); } + /** + * @covers ::getAgeVerificationsFromAttrsMap + */ public function testShouldReturnEmptyAgeVerifications() { $profileData = [ diff --git a/tests/Util/ConfigTest.php b/tests/Util/ConfigTest.php index 58eaa73d..9a389ac4 100644 --- a/tests/Util/ConfigTest.php +++ b/tests/Util/ConfigTest.php @@ -5,16 +5,25 @@ use YotiTest\TestCase; use Yoti\Util\Config; +/** + * @coversDefaultClass \Yoti\Util\Config + */ class ConfigTest extends TestCase { + /** + * @covers ::getInstance + */ public function testConfigInstance() { $this->assertInstanceOf(Config::class, Config::getInstance()); } + /** + * @covers ::get + */ public function testGetSDKVersion() { $sdkVersion = Config::getInstance()->get('version'); $this->assertNotNull($sdkVersion); } -} \ No newline at end of file +} diff --git a/tests/Util/Profile/AnchorListConverterTest.php b/tests/Util/Profile/AnchorListConverterTest.php index 30d36f10..5db179d9 100644 --- a/tests/Util/Profile/AnchorListConverterTest.php +++ b/tests/Util/Profile/AnchorListConverterTest.php @@ -7,14 +7,23 @@ use YotiTest\TestCase; use Yoti\Util\Profile\AnchorListConverter; +/** + * @coversDefaultClass \Yoti\Util\Profile\AnchorListConverter + */ class AnchorListConverterTest extends TestCase { + /** + * @covers ::convert + */ public function testConvertingSourceAnchor() { $anchorsData = $this->parseFromBase64String(TestAnchors::SOURCE_PP_ANCHOR); $this->assertEquals('PASSPORT', $anchorsData[Anchor::TYPE_SOURCE_OID][0]->getValue()); } + /** + * @covers ::convert + */ public function testConvertingVerifierAnchor() { $anchorsData = $this->parseFromBase64String(TestAnchors::VERIFIER_YOTI_ADMIN_ANCHOR); @@ -22,6 +31,9 @@ public function testConvertingVerifierAnchor() $this->assertEquals('YOTI_ADMIN', $anchorVerifiersObj->getValue()); } + /** + * @covers ::convert + */ public function testConvertingTwoSources() { $passportAnchor = new \Attrpubapi\Anchor(); @@ -56,4 +68,4 @@ public function parseFromBase64String($anchorString) return AnchorListConverter::convert($collection); } -} \ No newline at end of file +} diff --git a/tests/Util/Profile/AttributeConverterTest.php b/tests/Util/Profile/AttributeConverterTest.php index 0bfcabc1..46261bdf 100644 --- a/tests/Util/Profile/AttributeConverterTest.php +++ b/tests/Util/Profile/AttributeConverterTest.php @@ -8,8 +8,36 @@ use Yoti\ActivityDetails; use Yoti\Util\Profile\AttributeConverter; +/** + * @coversDefaultClass \Yoti\Util\Profile\AttributeConverter + */ class AttributeConverterTest extends TestCase { + /** + * Mocks \Attrpubapi\Attribute with provided name and value. + */ + private function getMockForProtobufAttribute($name, $value) + { + // Setup protobuf mock. + $protobufAttribute = $this->getMockBuilder(\Attrpubapi\Attribute::class) + ->disableOriginalConstructor() + ->getMock(); + $protobufAttribute + ->method('getAnchors') + ->willReturn($this->getMockBuilder(\Traversable::class)->getMock()); + $protobufAttribute + ->method('getName') + ->willReturn($name); + $protobufAttribute + ->method('getValue') + ->willReturn($value); + + return $protobufAttribute; + } + + /** + * @covers ::convertTimestampToDate + */ public function testDateTypeShouldReturnDateTime() { $dateTime = AttributeConverter::convertTimestampToDate('1980/12/01'); @@ -17,6 +45,9 @@ public function testDateTypeShouldReturnDateTime() $this->assertEquals('01-12-1980', $dateTime->format('d-m-Y')); } + /** + * @covers ::convertValueBasedOnContentType + */ public function testSelfieValueShouldReturnImageObject() { $pem = file_get_contents(PEM_FILE); @@ -27,4 +58,23 @@ public function testSelfieValueShouldReturnImageObject() $this->profile = $this->activityDetails->getProfile(); $this->assertInstanceOf(Image::class, $this->profile->getSelfie()->getValue()); } -} \ No newline at end of file + + /** + * @covers ::convertToYotiAttribute + */ + public function testConvertToYotiAttribute() + { + $attr = AttributeConverter::convertToYotiAttribute($this->getMockForProtobufAttribute('test_attr', 'my_value')); + $this->assertEquals('test_attr', $attr->getName()); + $this->assertEquals('my_value', $attr->getValue()); + } + + /** + * @covers ::convertToYotiAttribute + */ + public function testConvertToYotiAttributeNullValue() + { + $attr = AttributeConverter::convertToYotiAttribute($this->getMockForProtobufAttribute('test_attr', '')); + $this->assertNull($attr); + } +} diff --git a/tests/Util/Profile/TestAnchors.php b/tests/Util/Profile/TestAnchors.php index e456ca31..6d87ad03 100644 --- a/tests/Util/Profile/TestAnchors.php +++ b/tests/Util/Profile/TestAnchors.php @@ -123,4 +123,4 @@ class TestAnchors . "b185Qe6PWL4Jl+DvbzN2C0wsUFKRQyRwgBEIaQ8PyYstoCGhyG6joGfHdvA8tGS+Ol98" . "igUHdLW56nhnGLovTMIhz+RsUWrtszSjWSim2/4vJAE8QjXJ98ou4AVzKUOg9EUklWSU" . "5HX0xJQ0VOQ0U="; -} \ No newline at end of file +} diff --git a/tests/YotiClientTest.php b/tests/YotiClientTest.php index ed0dfab0..97071260 100755 --- a/tests/YotiClientTest.php +++ b/tests/YotiClientTest.php @@ -8,6 +8,9 @@ use Yoti\Entity\AmlProfile; use Yoti\Http\AmlResult; +/** + * @coversDefaultClass \Yoti\YotiClient + */ class YotiClientTest extends TestCase { /** @@ -15,10 +18,19 @@ class YotiClientTest extends TestCase */ public $yotiClient; + /** + * @var string Pem file contents + */ public $pem; + /** + * @var \Yoti\Entity\AmlProfile + */ public $amlProfile; + /** + * @var array Aml Result + */ public $amlResult = []; public function setUp() @@ -38,6 +50,8 @@ public function setUp() /** * Test the use of pem file + * + * @covers ::__construct */ public function testCanUsePemFile() { @@ -47,6 +61,8 @@ public function testCanUsePemFile() /** * Test passing invalid pem file path + * + * @covers ::__construct */ public function testInvalidPem() { @@ -55,7 +71,7 @@ public function testInvalidPem() } /** - * Test getting activity details + * @covers ::getActivityDetails */ public function testGetActivityDetails() { @@ -71,7 +87,7 @@ public function testGetActivityDetails() } /** - * Test performAmlCheck with a mock result + * @covers ::performAmlCheck */ public function testPerformAmlCheck() { @@ -85,6 +101,8 @@ public function testPerformAmlCheck() /** * Test invalid Token + * + * @covers ::getActivityDetails */ public function testInvalidConnectToken() { @@ -96,6 +114,8 @@ public function testInvalidConnectToken() /** * Test invalid http header value for X-Yoti-SDK + * + * @covers ::__construct */ public function testInvalidSdkIdentifier() { @@ -110,6 +130,8 @@ public function testInvalidSdkIdentifier() /** * Test X-Yoti-SDK http header value for Wordpress + * + * @covers ::__construct */ public function testCanUseWordPressAsSdkIdentifier() { @@ -125,6 +147,8 @@ public function testCanUseWordPressAsSdkIdentifier() /** * Test X-Yoti-SDK http header value for Drupal + * + * @covers ::__construct */ public function testCanUseDrupalAsSdkIdentifier() { @@ -140,6 +164,8 @@ public function testCanUseDrupalAsSdkIdentifier() /** * Test X-Yoti-SDK http header value for Joomla + * + * @covers ::__construct */ public function testCanUseJoomlaAsSdkIdentifier() { @@ -155,6 +181,8 @@ public function testCanUseJoomlaAsSdkIdentifier() /** * Test X-Yoti-SDK http header value for PHP + * + * @covers ::__construct */ public function testCanUsePHPAsSdkIdentifier() { @@ -168,4 +196,4 @@ public function testCanUsePHPAsSdkIdentifier() $this->assertInstanceOf(YotiClient::class, $yotiClientObj); } -} \ No newline at end of file +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php index e1d07fa4..c7184b55 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -3,13 +3,4 @@ * loads all required files including composer vendor autoload */ require_once __DIR__ . '/../vendor/autoload.php'; - -define('SDK_ID', '990a3996-5762-4e8a-aa64-cb406fdb0e68'); -define('RECEIPT_JSON', __DIR__ . '/sample-data/receipt.json'); -define('INVALID_YOTI_CONNECT_TOKEN', 'sdfsdfsdasdajsopifajsd='); -define('PEM_FILE', __DIR__ . '/sample-data/yw-access-security.pem'); -define('DUMMY_SELFIE_FILE', __DIR__ . '/sample-data/dummy-avatar.png'); -define('AML_PRIVATE_KEY', __DIR__ . '/sample-data/aml-check-private-key.pem'); -define('AML_PUBLIC_KEY', __DIR__ . '/sample-data/aml-check-public-key.pem'); -define('AML_CHECK_RESULT_JSON', __DIR__ . '/sample-data/aml-check-result.json'); -define('YOTI_CONNECT_TOKEN', file_get_contents(__DIR__ . '/sample-data/connect-token.txt')); \ No newline at end of file +require_once __DIR__ . '/config.php'; diff --git a/tests/config.php b/tests/config.php new file mode 100644 index 00000000..cd13004b --- /dev/null +++ b/tests/config.php @@ -0,0 +1,13 @@ +