forked from apoloz/alfa-bank-sdk
41 lines
1.3 KiB
PHP
41 lines
1.3 KiB
PHP
<?php
|
|
|
|
use Apoloz\AlfaBank\Core\AlfaBankConnector;
|
|
use Apoloz\AlfaBank\Core\AlfaConfig;
|
|
use Apoloz\AlfaBank\Data\NominalAccounts\Deals\Steps\StepActionRequestData;
|
|
use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\DigestSignatureData;
|
|
use Apoloz\AlfaBank\Requests\NominalAccounts\Deals\Steps\ManageStepRequest;
|
|
use Saloon\Http\Faking\MockResponse;
|
|
use Spatie\LaravelData\DataCollection;
|
|
|
|
test('can manage deal step', function (): void {
|
|
$mockClient = new \Saloon\Http\Faking\MockClient([
|
|
ManageStepRequest::class => MockResponse::make([
|
|
'dealId' => 'deal-123',
|
|
'stepId' => 'step-456',
|
|
'stepNumber' => 1,
|
|
], 200),
|
|
]);
|
|
|
|
$config = new AlfaConfig(
|
|
baseUrl: 'https://test.com',
|
|
certificatePath: __DIR__ . '/../../test_key.pem',
|
|
privateKeyPath: __DIR__ . '/../../test_key.pem'
|
|
);
|
|
$connector = new AlfaBankConnector($config);
|
|
$connector->withMockClient($mockClient);
|
|
|
|
$payload = new StepActionRequestData(
|
|
dealId: 'deal-123',
|
|
action: 'CREATE',
|
|
digestSignatures: new DataCollection(DigestSignatureData::class, [
|
|
new DigestSignatureData('sig', 'rsa'),
|
|
])
|
|
);
|
|
|
|
$response = $connector->send(new ManageStepRequest($payload));
|
|
|
|
expect($response->status())->toBe(200)
|
|
->and($response->dto()->stepId)->toBe('step-456');
|
|
});
|