Skip to content

Commit

Permalink
Release/4.3.1 (#372)
Browse files Browse the repository at this point in the history
* Sdk 2481 Library Updates (Fix for psr/http-message version error on php 8)(#369)
  • Loading branch information
mehmet-yoti authored Sep 12, 2024
1 parent df0a9ee commit 9f9b977
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 32 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ Add the Yoti SDK dependency:

```json
"require": {
"yoti/yoti-php-sdk" : "^4.3.0"
"yoti/yoti-php-sdk" : "^4.3.1"
}
```

Or run this Composer command
```console
$ composer require yoti/yoti-php-sdk "^4.3.0"
$ composer require yoti/yoti-php-sdk "^4.3.1"
```

## Setup
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "yoti/yoti-php-sdk",
"description": "Yoti SDK for quickly integrating your PHP backend with Yoti",
"version": "4.3.0",
"version": "4.3.1",
"keywords": [
"yoti",
"sdk"
Expand All @@ -15,7 +15,7 @@
"phpseclib/phpseclib": "^3.0",
"guzzlehttp/guzzle": "^7.0",
"psr/http-client": "^1.0",
"psr/http-message": "^1.0",
"psr/http-message": "^2.0",
"guzzlehttp/psr7": "^2.4",
"ext-openssl": "*"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/digitalidentity/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file is a template for defining the environment variables
0# This file is a template for defining the environment variables
# Set the application config values here

YOTI_SDK_ID=xxxxxxxxxxxxxxxxxxxxx
Expand Down
2 changes: 1 addition & 1 deletion src/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Constants
public const SDK_IDENTIFIER = 'PHP';

/** Default SDK version */
public const SDK_VERSION = '4.3.0';
public const SDK_VERSION = '4.3.1';

/** Base url for connect page (user will be redirected to this page eg. baseurl/app-id) */
public const CONNECT_BASE_URL = 'https://www.yoti.com/connect';
Expand Down
82 changes: 69 additions & 13 deletions tests/DocScan/DocScanClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
use Yoti\DocScan\DocScanClient;
use Yoti\DocScan\Session\Create\CreateSessionResult;
use Yoti\DocScan\Session\Create\FaceCapture\CreateFaceCaptureResourcePayload;
Expand Down Expand Up @@ -92,8 +93,12 @@ public function testEmptyApiUrlEnvironmentVariable()
*/
private function assertApiUrlStartsWith($expectedUrl, $clientApiUrl = null)
{
$stream = $this->createMock(\Psr\Http\Message\StreamInterface::class);
$stream->method('getContents')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_CREATION_RESPONSE));
$stream->method('__toString')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_CREATION_RESPONSE));

$response = $this->createMock(ResponseInterface::class);
$response->method('getBody')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_CREATION_RESPONSE));
$response->method('getBody')->willReturn($stream);
$response->method('getStatusCode')->willReturn(200);

$httpClient = $this->createMock(ClientInterface::class);
Expand Down Expand Up @@ -126,8 +131,13 @@ private function assertApiUrlStartsWith($expectedUrl, $clientApiUrl = null)
*/
public function testCreateSession()
{
$stream = $this->createMock(\Psr\Http\Message\StreamInterface::class);
$stream->method('getContents')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_CREATION_RESPONSE));
$stream->method('__toString')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_CREATION_RESPONSE));

$response = $this->createMock(ResponseInterface::class);
$response->method('getBody')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_CREATION_RESPONSE));
$response->method('getBody')->willReturn($stream);

$response->method('getStatusCode')->willReturn(200);

$httpClient = $this->createMock(ClientInterface::class);
Expand Down Expand Up @@ -155,8 +165,12 @@ public function testCreateSession()
*/
public function testGetSession()
{
$stream = $this->createMock(\Psr\Http\Message\StreamInterface::class);
$stream->method('getContents')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_RESPONSE));
$stream->method('__toString')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_RESPONSE));

$response = $this->createMock(ResponseInterface::class);
$response->method('getBody')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_RESPONSE));
$response->method('getBody')->willReturn($stream);
$response->method('getStatusCode')->willReturn(200);

$httpClient = $this->createMock(ClientInterface::class);
Expand Down Expand Up @@ -203,8 +217,13 @@ public function testDeleteSessionDoesNotThrowException()
*/
public function testGetMedia()
{
$stream = $this->createMock(\Psr\Http\Message\StreamInterface::class);
$stream->method('getContents')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_RESPONSE));
$stream->method('__toString')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_RESPONSE));

$response = $this->createMock(ResponseInterface::class);
$response->method('getBody')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_RESPONSE));
$response->method('getBody')->willReturn($stream);

$response->method('getStatusCode')->willReturn(200);
$response->method('getHeader')->willReturn([ 'image/png' ]);

Expand Down Expand Up @@ -276,8 +295,12 @@ public function testDeleteMediaDoesNotThrowException()
*/
public function testGetSupportedDocuments()
{
$stream = $this->createMock(StreamInterface::class);
$stream->method('getContents')->willReturn(json_encode((object)[]));
$stream->method('__toString')->willReturn(json_encode((object)[]));

$response = $this->createMock(ResponseInterface::class);
$response->method('getBody')->willReturn(json_encode((object)[]));
$response->method('getBody')->willReturn($stream);
$response->method('getStatusCode')->willReturn(200);

$httpClient = $this->createMock(ClientInterface::class);
Expand All @@ -301,8 +324,12 @@ public function testGetSupportedDocuments()
*/
public function testCreateFaceCaptureResource()
{
$stream = $this->createMock(StreamInterface::class);
$stream->method('getContents')->willReturn(json_encode((object)[]));
$stream->method('__toString')->willReturn(json_encode((object)[]));

$response = $this->createMock(ResponseInterface::class);
$response->method('getBody')->willReturn(json_encode((object)[]));
$response->method('getBody')->willReturn($stream);
$response->method('getStatusCode')->willReturn(201);

$createFaceCaptureResourcePayloadMock = $this->createMock(CreateFaceCaptureResourcePayload::class);
Expand Down Expand Up @@ -331,9 +358,14 @@ public function testCreateFaceCaptureResource()
*/
public function testUploadFaceCaptureImage()
{

$stream = $this->createMock(StreamInterface::class);
$stream->method('getContents')->willReturn(json_encode((object)[]));
$stream->method('__toString')->willReturn(json_encode((object)[]));

$response = $this->createMock(ResponseInterface::class);
$response->method('getBody')->willReturn($stream);
$uploadFaceCaptureImagePayloadMock = $this->createMock(UploadFaceCaptureImagePayload::class);
$response->method('getBody')->willReturn(json_encode((object)[]));
$response->method('getStatusCode')->willReturn(200);

$httpClient = $this->createMock(ClientInterface::class);
Expand All @@ -358,8 +390,12 @@ public function testUploadFaceCaptureImage()
*/
public function testGetSessionConfiguration()
{
$stream = $this->createMock(StreamInterface::class);
$stream->method('getContents')->willReturn(json_encode((object)[]));
$stream->method('__toString')->willReturn(json_encode((object)[]));

$response = $this->createMock(ResponseInterface::class);
$response->method('getBody')->willReturn(json_encode((object)[]));
$response->method('getBody')->willReturn($stream);
$response->method('getStatusCode')->willReturn(200);

$httpClient = $this->createMock(ClientInterface::class);
Expand All @@ -383,9 +419,13 @@ public function testGetSessionConfiguration()
*/
public function testPutIbvInstructions()
{
$stream = $this->createMock(StreamInterface::class);
$stream->method('getContents')->willReturn(json_encode((object)[]));
$stream->method('__toString')->willReturn(json_encode((object)[]));

$response = $this->createMock(ResponseInterface::class);
$response->method('getBody')->willReturn($stream);
$instructionsMock = $this->createMock(Instructions::class);
$response->method('getBody')->willReturn(json_encode((object)[]));
$response->method('getStatusCode')->willReturn(200);

$httpClient = $this->createMock(ClientInterface::class);
Expand All @@ -409,8 +449,12 @@ public function testPutIbvInstructions()
*/
public function testGetIbvInstructions()
{
$stream = $this->createMock(StreamInterface::class);
$stream->method('getContents')->willReturn(json_encode((object)[]));
$stream->method('__toString')->willReturn(json_encode((object)[]));

$response = $this->createMock(ResponseInterface::class);
$response->method('getBody')->willReturn(json_encode((object)[]));
$response->method('getBody')->willReturn($stream);
$response->method('getStatusCode')->willReturn(200);

$httpClient = $this->createMock(ClientInterface::class);
Expand All @@ -433,8 +477,12 @@ public function testGetIbvInstructions()
*/
public function testGetIbvInstructionsPdf()
{
$stream = $this->createMock(StreamInterface::class);
$stream->method('getContents')->willReturn(json_encode((object)[]));
$stream->method('__toString')->willReturn(json_encode((object)[]));

$response = $this->createMock(ResponseInterface::class);
$response->method('getBody')->willReturn(json_encode((object)[]));
$response->method('getBody')->willReturn($stream);
$response->method('getStatusCode')->willReturn(200);

$httpClient = $this->createMock(ClientInterface::class);
Expand All @@ -457,8 +505,12 @@ public function testGetIbvInstructionsPdf()
*/
public function testFetchInstructionsContactProfile()
{
$stream = $this->createMock(StreamInterface::class);
$stream->method('getContents')->willReturn(json_encode((object)[]));
$stream->method('__toString')->willReturn(json_encode((object)[]));

$response = $this->createMock(ResponseInterface::class);
$response->method('getBody')->willReturn(json_encode((object)[]));
$response->method('getBody')->willReturn($stream);
$response->method('getStatusCode')->willReturn(200);

$httpClient = $this->createMock(ClientInterface::class);
Expand All @@ -481,8 +533,12 @@ public function testFetchInstructionsContactProfile()
*/
public function testTriggerIbvEmailNotification()
{
$stream = $this->createMock(StreamInterface::class);
$stream->method('getContents')->willReturn(json_encode((object)[]));
$stream->method('__toString')->willReturn(json_encode((object)[]));

$response = $this->createMock(ResponseInterface::class);
$response->method('getBody')->willReturn(json_encode((object)[]));
$response->method('getBody')->willReturn($stream);
$response->method('getStatusCode')->willReturn(200);

$httpClient = $this->createMock(ClientInterface::class);
Expand Down
32 changes: 19 additions & 13 deletions tests/YotiClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use GuzzleHttp\Psr7;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
use Psr\Log\LoggerInterface;
use Yoti\Aml\Address as AmlAddress;
use Yoti\Aml\Country as AmlCountry;
Expand Down Expand Up @@ -122,8 +123,12 @@ private function assertApiUrlStartsWith($expectedUrl, $clientApiUrl = null)
*/
public function testGetActivityDetails()
{
$stream = $this->createMock(StreamInterface::class);
$stream->method('getContents')->willReturn(file_get_contents(TestData::RECEIPT_JSON));
$stream->method('__toString')->willReturn(file_get_contents(TestData::RECEIPT_JSON));

$response = $this->createMock(ResponseInterface::class);
$response->method('getBody')->willReturn(file_get_contents(TestData::RECEIPT_JSON));
$response->method('getBody')->willReturn($stream);
$response->method('getStatusCode')->willReturn(200);

$httpClient = $this->createMock(ClientInterface::class);
Expand Down Expand Up @@ -220,20 +225,21 @@ public function testGetLoginUrl()
*/
public function testCustomLogger()
{
$response = $this->createMock(ResponseInterface::class);
$jsonstr = json_encode([
'receipt' => [
'timestamp' => 'some invalid timestamp',
'wrapped_receipt_key' => 'some receipt key',
'sharing_outcome' => 'SUCCESS',
]
]);

$stream = $this->createMock(StreamInterface::class);
$stream->method('getContents')->willReturn($jsonstr);
$stream->method('__toString')->willReturn($jsonstr);

$response = $this->createMock(ResponseInterface::class);
$response->method('getBody')->willReturn($stream);
$response->method('getStatusCode')->willReturn(200);
$response
->method('getBody')
->willReturn(
json_encode([
'receipt' => [
'timestamp' => 'some invalid timestamp',
'wrapped_receipt_key' => 'some receipt key',
'sharing_outcome' => 'SUCCESS',
]
])
);

$httpClient = $this->createMock(ClientInterface::class);
$httpClient->expects($this->exactly(1))
Expand Down

0 comments on commit 9f9b977

Please sign in to comment.