forked from apoloz/alfa-bank-sdk
refactor: dto, requests, connector
This commit is contained in:
41
tests/Feature/SelfEmployed/IncomeTest.php
Normal file
41
tests/Feature/SelfEmployed/IncomeTest.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use Apoloz\AlfaBank\Core\AlfaBankConnector;
|
||||
use Apoloz\AlfaBank\Core\AlfaConfig;
|
||||
use Apoloz\AlfaBank\Services\OpenSslCmsSigner;
|
||||
use Apoloz\AlfaBank\Requests\SelfEmployed\RegisterIncomeRequest;
|
||||
use Apoloz\AlfaBank\Data\SelfEmployed\CreateIncomeRequestData;
|
||||
use Saloon\Http\Faking\MockResponse;
|
||||
use Saloon\Http\Faking\MockClient;
|
||||
|
||||
test('can register income', function () {
|
||||
$mockClient = new MockClient([
|
||||
RegisterIncomeRequest::class => MockResponse::make([
|
||||
'requestId' => 'req-1',
|
||||
'status' => 'CREATED'
|
||||
], 200),
|
||||
]);
|
||||
|
||||
$config = new AlfaConfig(
|
||||
baseUrl: 'https://test.com',
|
||||
certificatePath: __DIR__ . '/../../test_key.pem',
|
||||
privateKeyPath: __DIR__ . '/../../test_key.pem'
|
||||
);
|
||||
$signer = new OpenSslCmsSigner(__DIR__ . '/../../test_key.pem', __DIR__ . '/../../test_key.pem');
|
||||
|
||||
$connector = new AlfaBankConnector($config, $signer);
|
||||
$connector->withMockClient($mockClient);
|
||||
|
||||
$data = new CreateIncomeRequestData(
|
||||
vatin: '1234567890',
|
||||
name: 'Services',
|
||||
amount: '100.00',
|
||||
date: '2025-01-01'
|
||||
);
|
||||
|
||||
$response = $connector->send(new RegisterIncomeRequest($data));
|
||||
$dto = $response->dto();
|
||||
|
||||
expect($dto->requestId)->toBe('req-1')
|
||||
->and($dto->status)->toBe('CREATED');
|
||||
});
|
||||
Reference in New Issue
Block a user