Skip to content

Commit 4323967

Browse files
committed
Restore assertions for unit tests
1 parent c1cf633 commit 4323967

File tree

9 files changed

+37
-0
lines changed

9 files changed

+37
-0
lines changed

tests/Api/CallbackTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ public function test_can_handle_callback(): void
162162
{
163163
$call = new Callback($this->data);
164164
$response = $call->call();
165+
$this->assertInstanceOf(CallbackResponse::class, $response);
165166
$this->assertSame('d28df6b4-122d-49e2-add0-19c8271260b0', $response->paymentId);
166167
$this->assertSame('000000022', $response->shopOrderId);
167168
$this->assertSame('incomplete', $response->status);

tests/Api/CaptureReservationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function test_capture_reservation_transactions_data(): void
5454
$response = $api->call();
5555
$this->assertInstanceOf(CaptureReservationResponse::class, $response);
5656
$transaction = $response->Transactions[0];
57+
$this->assertInstanceOf(Transaction::class, $transaction);
5758
$this->assertSame('1', $transaction->TransactionId);
5859
$this->assertSame('978', $transaction->MerchantCurrency);
5960
$this->assertSame(13.37, $transaction->FraudRiskScore);

tests/Api/FundingListTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,16 @@ public function test_funding_object(): void
7777
$response = $api->call();
7878
$this->assertInstanceOf(FundingsResponse::class, $response);
7979
$funding = $response->Fundings[0];
80+
$this->assertInstanceOf(Funding::class, $funding);
8081

8182
$this->assertSame('CreatedByTest', $funding->Filename);
8283
$this->assertSame('1234567890123456', $funding->ContractIdentifier);
8384
$this->assertCount(2, $funding->Shops);
8485
$this->assertSame('TestAcquirer', $funding->Acquirer);
86+
$this->assertInstanceOf(\DateTime::class, $funding->FundingDate);
8587
$this->assertSame('26-09-2010', $funding->FundingDate->format('d-m-Y'));
8688
$this->assertSame('50.00 EUR', $funding->Amount);
89+
$this->assertInstanceOf(\DateTime::class, $funding->CreatedDate);
8790
$this->assertSame('27-09-2010', $funding->CreatedDate->format('d-m-Y'));
8891
$this->assertSame('http://localhost/merchant.php/API/fundingDownload?id=1', $funding->DownloadLink);
8992
}

tests/Api/HeaderTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function test_get_header_error_data(): void
3434
$api = $this->getapi();
3535
$api->call();
3636
} catch (ResponseHeaderException $e) {
37+
$this->assertInstanceOf(Header::class, $e->getHeader());
3738
$this->assertSame('200', $e->getHeader()->ErrorCode);
3839
$this->assertSame('This request has error', $e->getHeader()->ErrorMessage);
3940
}

tests/Api/InvoiceTextTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,14 @@ public function test_object(): void
5858
$this->assertStringStartsWith('Fordringen er overdraget', $response->MandatoryInvoiceText);
5959
$this->assertSame('7373', $response->InvoiceNumber);
6060
$this->assertSame('832', $response->CustomerNumber);
61+
$this->assertInstanceOf(\DateTime::class, $response->InvoiceDate);
6162
$this->assertSame('10-03-2011', $response->InvoiceDate->format('d-m-Y'));
63+
$this->assertInstanceOf(\DateTime::class, $response->DueDate);
6264
$this->assertSame('24-03-2011', $response->DueDate->format('d-m-Y'));
6365
$this->assertCount(1, $response->TextInfos);
6466
$this->assertSame('Password', $response->TextInfos[0]->Name);
6567
$this->assertSame('xxxxxx', $response->TextInfos[0]->Value);
68+
$this->assertInstanceOf(Address::class, $response->Address);
6669
$this->assertSame('John', $response->Address->Firstname);
6770
$this->assertSame('John', $response->Address->Lastname);
6871
$this->assertSame('Anywhere Street 12', $response->Address->Address);

tests/Api/PaymentRequestTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public function test_options_url(): void
117117
$this->assertSame('kg', $line['unitCode']);
118118

119119
// Config
120+
$this->assertIsArray($parts['config']);
120121
/** @var array<string> $config */
121122
$config = $parts['config'];
122123
$this->assertSame(sprintf('%s/%s', self::CONFIG_URL, 'form'), $config['callback_form']);

tests/Api/PaymentsTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public function test_payments_routing(): void
7373
->setPaymentId('mypaymentid');
7474
$api->call();
7575

76+
$this->assertInstanceOf(Request::class, $api->getRawRequest());
7677
$this->assertInstanceOf(Response::class, $api->getRawResponse());
7778

7879
$this->assertSame($this->getExceptedUri('payments/'), $api->getRawRequest()->getUri()->getPath());
@@ -119,6 +120,7 @@ public function test_multiple_payment_transaction_count(): void
119120
public function test_multiple_payment_transaction_data(): void
120121
{
121122
$data = $this->getMultiplePaymentTransaction()[0];
123+
$this->assertInstanceOf(Transaction::class, $data);
122124

123125
$this->assertSame('1', $data->TransactionId);
124126
$this->assertSame('ccc1479c-37f9-4962-8d2c-662d75117e9d', $data->PaymentId);
@@ -142,16 +144,24 @@ public function test_multiple_payment_transaction_data(): void
142144
$this->assertSame(1.00, $data->CapturedAmount);
143145
$this->assertSame(0.0, $data->RefundedAmount);
144146
$this->assertSame(0.0, $data->RecurringDefaultAmount);
147+
$this->assertInstanceOf(\DateTime::class, $data->CreatedDate);
148+
$this->assertInstanceOf(\DateTime::class, $data->UpdatedDate);
145149
$this->assertSame('28-09-2010', $data->CreatedDate->format('d-m-Y'));
146150
$this->assertSame('28-09-2010', $data->UpdatedDate->format('d-m-Y'));
147151
$this->assertSame('CreditCard', $data->PaymentNature);
148152
$this->assertSame('eCommerce', $data->PaymentSource);
149153
$this->assertSame(13.37, $data->FraudRiskScore);
150154
$this->assertSame('Fraud detection explanation', $data->FraudExplanation);
151155

156+
// Payment nature service
157+
$this->assertInstanceOf(PaymentNatureService::class, $data->PaymentNatureService);
158+
152159
// Payment Infos
153160
$this->assertCount(3, $data->PaymentInfos);
154161

162+
// Customer info
163+
$this->assertInstanceOf(CustomerInfo::class, $data->CustomerInfo);
164+
155165
// ReconciliationIdentifiers
156166
$this->assertCount(1, $data->ReconciliationIdentifiers);
157167
}
@@ -162,6 +172,7 @@ public function test_multiple_payment_transaction_data(): void
162172
public function test_multiple_payment_paymentnatureservice_data(): void
163173
{
164174
$data = $this->getMultiplePaymentTransaction()[0]->PaymentNatureService;
175+
$this->assertInstanceOf(PaymentNatureService::class, $data);
165176

166177
$this->assertSame('TestAcquirer', $data->name);
167178
$this->assertTrue($data->SupportsRefunds);
@@ -223,26 +234,36 @@ public function test_multiple_payment_customerinfo_data(): void
223234
$this->assertSame('support', $data->Username);
224235
$this->assertSame('+45 7020 0056', $data->CustomerPhone);
225236
$this->assertSame('12345678', $data->OrganisationNumber);
237+
$this->assertInstanceOf(Country::class, $data->CountryOfOrigin);
226238

227239
$country = $data->CountryOfOrigin;
240+
$this->assertInstanceOf(Country::class, $country);
228241
$this->assertSame('DK', $country->Country);
229242
$this->assertSame('BillingAddress', $country->Source);
230243

244+
$this->assertInstanceOf(Address::class, $data->BillingAddress);
245+
231246
$address = $data->BillingAddress;
247+
$this->assertInstanceOf(Address::class, $address);
232248
$this->assertSame('Palle', $address->Firstname);
233249
$this->assertSame('Simonsen', $address->Lastname);
234250
$this->assertSame('Rosenkæret 13', $address->Address);
235251
$this->assertSame('Søborg', $address->City);
236252
$this->assertSame('2860', $address->PostalCode);
237253
$this->assertSame('DK', $address->Country);
238254

255+
$this->assertInstanceOf(Address::class, $data->ShippingAddress);
256+
239257
$address = $data->ShippingAddress;
258+
$this->assertInstanceOf(Address::class, $address);
240259
$this->assertNull($address->Firstname);
241260
$this->assertNull($address->Lastname);
242261
$this->assertNull($address->Address);
243262
$this->assertNull($address->City);
244263
$this->assertNull($address->PostalCode);
245264
$this->assertNull($address->Country);
265+
266+
$this->assertInstanceOf(Address::class, $data->RegisteredAddress);
246267
}
247268

248269
/**
@@ -251,10 +272,12 @@ public function test_multiple_payment_customerinfo_data(): void
251272
public function test_multiple_payment_reconciliationidentifiers_data(): void
252273
{
253274
$data = $this->getMultiplePaymentTransaction()[0]->ReconciliationIdentifiers[0];
275+
$this->assertInstanceOf(ReconciliationIdentifier::class, $data);
254276

255277
$this->assertSame('f4e2533e-c578-4383-b075-bc8a6866784a', $data->Id);
256278
$this->assertSame(1.00, $data->Amount);
257279
$this->assertSame('captured', $data->Type);
280+
$this->assertInstanceOf(\DateTime::class, $data->Date);
258281
$this->assertSame('28-09-2010', $data->Date->format('d-m-Y'));
259282
$this->assertSame('978', $data->currency);
260283
}

tests/Api/RefundCapturedReservationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public function test_capture_refund_transactions_data(): void
5757
$response = $api->call();
5858
$this->assertInstanceOf(RefundResponse::class, $response);
5959
$transaction = $response->Transactions[0];
60+
$this->assertInstanceOf(Transaction::class, $transaction);
6061
$this->assertSame('1', $transaction->TransactionId);
6162
$this->assertSame('978', $transaction->MerchantCurrency);
6263
$this->assertSame(13.37, $transaction->FraudRiskScore);

tests/Api/TerminalsTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function test_header(): void
3333
$api = $this->getTerminals();
3434
$response = $api->call();
3535
$this->assertInstanceOf(TerminalsResponse::class, $response);
36+
$this->assertInstanceOf(\DateTime::class, $response->Header->Date);
3637
$this->assertSame('07-01-2016', $response->Header->Date->format('d-m-Y'));
3738
$this->assertSame('API/getTerminals', $response->Header->Path);
3839
$this->assertSame('0', $response->Header->ErrorCode);
@@ -60,6 +61,8 @@ public function test_response_terminal(): void
6061
$this->assertCount(2, $response->Terminals);
6162

6263
$terminal = $response->Terminals[0];
64+
$this->assertInstanceOf(Terminal::class, $terminal);
65+
$this->assertSame('AltaPay Multi-Nature Terminal', $terminal->Title);
6366
$this->assertSame('DK', $terminal->Country);
6467
$this->assertCount(4, $terminal->Natures);
6568
$this->assertCount(4, $terminal->Methods);

0 commit comments

Comments
 (0)