Skip to content

Commit 0457e19

Browse files
committed
Fix test and code format
1 parent d25ee7d commit 0457e19

File tree

2 files changed

+28
-21
lines changed

2 files changed

+28
-21
lines changed

src/Adyen/Model/PaymentsApp/ObjectSerializer.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static function sanitizeForSerialization($data, $type = null, $format = n
8282
}
8383
}
8484
} else {
85-
foreach($data as $property => $value) {
85+
foreach ($data as $property => $value) {
8686
$values[$property] = self::sanitizeForSerialization($value);
8787
}
8888
}
@@ -118,7 +118,9 @@ public static function sanitizeFilename($filename)
118118
*/
119119
public static function sanitizeTimestamp($timestamp)
120120
{
121-
if (!is_string($timestamp)) return $timestamp;
121+
if (!is_string($timestamp)) {
122+
return $timestamp;
123+
}
122124

123125
return preg_replace('/(:\d{2}.\d{6})\d*/', '$1', $timestamp);
124126
}

tests/Unit/PaymentsAppTest.php

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
namespace Adyen\Tests\Unit;
2525

2626
use Adyen\Service\PaymentsApp\PaymentsAppApi;
27+
use Adyen\Model\PaymentsApp\BoardingTokenRequest;
2728
use Adyen\AdyenException;
2829

2930
class PaymentsAppTest extends TestCaseMock
@@ -37,13 +38,14 @@ public function testGeneratePaymentsAppBoardingTokenForMerchantSuccess($jsonFile
3738

3839
$paymentsAppApi = new PaymentsAppApi($client);
3940

40-
$requestParams = [
41-
'boardingRequestToken' => 'mockedRequestToken'
42-
];
41+
$json = '{[
42+
"boardingRequestToken": "mockedRequestToken"
43+
]}';
44+
$params = new BoardingTokenRequest(json_decode($json, true));
4345

4446
$response = $paymentsAppApi->generatePaymentsAppBoardingTokenForMerchant(
4547
"MerchantAccount123",
46-
$requestParams
48+
$params
4749
);
4850

4951
$this->assertNotNull($response);
@@ -59,20 +61,21 @@ public function testGeneratePaymentsAppBoardingTokenForMerchantError($jsonFile,
5961
$client = $this->createMockClient($jsonFile, $httpStatus);
6062
$paymentsAppApi = new PaymentsAppApi($client);
6163

62-
$requestParams = [
63-
'boardingRequestToken' => 'mockedRequestToken'
64-
];
64+
$json = '{[
65+
"boardingRequestToken": "mockedRequestToken"
66+
]}';
67+
$params = new BoardingTokenRequest(json_decode($json, true));
6568

6669
try {
6770
$paymentsAppApi->generatePaymentsAppBoardingTokenForMerchant(
6871
"MerchantAccount123",
69-
$requestParams
72+
$params
7073
);
7174
$this->fail(AdyenException::class . " expected");
7275
} catch (AdyenException $e) {
7376
$this->assertEquals(403, $e->getStatus()); // Assuming AdyenException has getStatus() or public status $status
7477
// Assumes the error message from boardingToken-error-403.json contains "PA001"
75-
$this->assertStringContainsString("PA001", $e->getMessage());
78+
$this->assertStringContainsString("PA001", $e->getAdyenErrorCode());
7679
}
7780
}
7881

@@ -84,14 +87,15 @@ public function testGeneratePaymentsAppBoardingTokenForStoreSuccess($jsonFile, $
8487
$client = $this->createMockClient($jsonFile, $httpStatus);
8588
$paymentsAppApi = new PaymentsAppApi($client);
8689

87-
$requestParams = [
88-
'boardingRequestToken' => 'mockedRequestToken'
89-
];
90+
$json = '{[
91+
"boardingRequestToken": "mockedRequestToken"
92+
]}';
93+
$params = new BoardingTokenRequest(json_decode($json, true));
9094

9195
$response = $paymentsAppApi->generatePaymentsAppBoardingTokenForStore(
9296
"MerchantAccount123",
9397
"StoreEU",
94-
$requestParams
98+
$params
9599
);
96100

97101
$this->assertNotNull($response);
@@ -107,20 +111,21 @@ public function testGeneratePaymentsAppBoardingTokenForStoreError($jsonFile, $ht
107111
$client = $this->createMockClient($jsonFile, $httpStatus);
108112
$paymentsAppApi = new PaymentsAppApi($client);
109113

110-
$requestParams = [
111-
'boardingRequestToken' => 'mockedRequestToken'
112-
];
114+
$json = '{[
115+
"boardingRequestToken": "mockedRequestToken"
116+
]}';
117+
$params = new BoardingTokenRequest(json_decode($json, true));
113118

114119
try {
115120
$paymentsAppApi->generatePaymentsAppBoardingTokenForStore(
116121
"MerchantAccount123",
117122
"StoreEU",
118-
$requestParams
123+
$params
119124
);
120125
$this->fail(AdyenException::class . " expected");
121126
} catch (AdyenException $e) {
122127
$this->assertEquals(403, $e->getStatus());
123-
$this->assertStringContainsString("PA001", $e->getMessage());
128+
$this->assertStringContainsString("Merchant not permitted for this action.", $e->getMessage());
124129
}
125130
}
126131

@@ -154,7 +159,7 @@ public function testListPaymentsAppForMerchantError($jsonFile, $httpStatus)
154159
} catch (AdyenException $e) {
155160
$this->assertEquals(500, $e->getStatus());
156161
// Assumes the error message from paymentsAppList-error-500.json contains "PA002"
157-
$this->assertStringContainsString("PA002", $e->getMessage());
162+
$this->assertStringContainsString("PA002", $e->getAdyenErrorCode());
158163
}
159164
}
160165

0 commit comments

Comments
 (0)