forked from apoloz/alfa-bank-sdk
43 lines
1.6 KiB
PHP
43 lines
1.6 KiB
PHP
<?php
|
|
|
|
use Apoloz\AlfaBank\Core\AlfaBankConnector;
|
|
use Apoloz\AlfaBank\Core\AlfaConfig;
|
|
use Apoloz\AlfaBank\Requests\Statement\GetTransactionsRequest;
|
|
use Saloon\Http\Faking\MockResponse;
|
|
|
|
test('can get transactions statement', function () {
|
|
$mockClient = new \Saloon\Http\Faking\MockClient([
|
|
GetTransactionsRequest::class => MockResponse::make([
|
|
'pagination' => [
|
|
'totalCount' => 1,
|
|
'limit' => 10,
|
|
'offset' => 0
|
|
],
|
|
'transactions' => [
|
|
[
|
|
'uuid' => 'uuid-123',
|
|
'transactionId' => 'tx-123',
|
|
'operationDate' => '2023-01-01',
|
|
'number' => '1',
|
|
'direction' => 'CREDIT',
|
|
'amount' => ['amount' => 100.00, 'currencyName' => 'RUB'],
|
|
'amountRub' => ['amount' => 100.00, 'currencyName' => 'RUB'],
|
|
'paymentPurpose' => 'Test',
|
|
'correspondingAccount' => '408...'
|
|
]
|
|
]
|
|
], 200, ['Content-Type' => 'application/json']),
|
|
]);
|
|
|
|
$config = createTestConfig();
|
|
$connector = new AlfaBankConnector($config);
|
|
$connector->withMockClient($mockClient);
|
|
|
|
$request = new GetTransactionsRequest('408...', '2023-01-01', '2023-01-02');
|
|
$response = $connector->send($request);
|
|
|
|
expect($response->status())->toBe(200)
|
|
->and($response->dto()->transactions[0]->transactionId)->toBe('tx-123')
|
|
->and($response->dto()->transactions[0]->amount->amount)->toBe(100.00);
|
|
});
|