forked from apoloz/alfa-bank-sdk
42 lines
1.3 KiB
PHP
42 lines
1.3 KiB
PHP
<?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');
|
|
});
|