Skip to content

Commit bbdd977

Browse files
committed
increase code coverage
1 parent 6e41782 commit bbdd977

2 files changed

Lines changed: 11 additions & 16 deletions

File tree

src/DataTransferObjects/Checkout/CheckoutDto.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ public function __construct(
5656

5757
public static function fromArray(array $data): static
5858
{
59-
$metadata = isset($data['metadata'])
60-
? new MetaDataDto(...$data['metadata'])
61-
: null;
62-
6359
$totalAmount = null;
6460
if (isset($data['totalAmount'])) {
6561
$ta = $data['totalAmount'];
@@ -99,14 +95,6 @@ public static function fromArray(array $data): static
9995
);
10096
}
10197

102-
$redirectUrl = isset($data['redirectUrl'])
103-
? new RedirectUrlDto(...$data['redirectUrl'])
104-
: null;
105-
106-
$merchant = isset($data['merchant'])
107-
? new MerchantDto(...$data['merchant'])
108-
: null;
109-
11098
$paymentDetails = null;
11199
if (isset($data['paymentDetails'])) {
112100
$pd = $data['paymentDetails'];
@@ -165,11 +153,11 @@ public static function fromArray(array $data): static
165153
totalAmount: $totalAmount ?? new TotalAmountDto,
166154
buyer: $buyer,
167155
items: $data['items'] ?? [],
168-
redirectUrl: $redirectUrl,
156+
redirectUrl: new RedirectUrlDto(...($data['redirectUrl'] ?? [])),
169157
status: $data['status'] ?? null,
170158
paymentStatus: $data['paymentStatus'] ?? null,
171159
requestReferenceNumber: $data['requestReferenceNumber'] ?? null,
172-
metadata: $metadata,
160+
metadata: new MetaDataDto(...($data['metadata'] ?? [])),
173161
receiptNumber: $data['receiptNumber'] ?? null,
174162
createdAt: $data['createdAt'] ?? null,
175163
updatedAt: $data['updatedAt'] ?? null,
@@ -178,7 +166,7 @@ public static function fromArray(array $data): static
178166
refundedAmount: $data['refundedAmount'] ?? 0,
179167
canPayPal: $data['canPayPal'] ?? null,
180168
paymentScheme: $data['paymentScheme'] ?? null,
181-
merchant: $merchant,
169+
merchant: new MerchantDto(...($data['merchant'] ?? [])),
182170
paymentDetails: $paymentDetails,
183171
transactionReferenceNumber: $data['transactionReferenceNumber'] ?? null,
184172
);

tests/Requests/Checkout/GetCheckoutRequestTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,14 @@
164164
"failure": "https:\/\/staging-api2",
165165
"cancel": "https:\/\/staging-api3"
166166
},
167-
"transactionReferenceNumber": "xxx"
167+
"transactionReferenceNumber": "xxx","metadata":{
168+
"mci":"mci",
169+
"mco":"mco",
170+
"mpc":"mpc",
171+
"mst":"mst",
172+
"smi":"smi",
173+
"smn":"smn"
174+
}
168175
}';
169176

170177
MockClient::global([

0 commit comments

Comments
 (0)