forked from apoloz/alfa-bank-sdk
30 lines
1.0 KiB
PHP
30 lines
1.0 KiB
PHP
<?php
|
|
|
|
use Apoloz\AlfaBank\Core\AlfaBankConnector;
|
|
use Apoloz\AlfaBank\Data\SelfEmployed\AgreementPageRequestData;
|
|
use Apoloz\AlfaBank\Requests\SelfEmployed\CreateAgreementLinkRequest;
|
|
use Saloon\Http\Faking\MockResponse;
|
|
|
|
test('can create agreement link', function (): void {
|
|
$mockClient = new \Saloon\Http\Faking\MockClient([
|
|
CreateAgreementLinkRequest::class => MockResponse::make([
|
|
'agreementPageId' => 'uuid-page-123',
|
|
'agreementPageLink' => 'https://link.alfa/...',
|
|
], 200, ['Content-Type' => 'application/json']),
|
|
]);
|
|
|
|
$config = createTestConfig();
|
|
$connector = new AlfaBankConnector($config);
|
|
$connector->withMockClient($mockClient);
|
|
|
|
$payload = new AgreementPageRequestData(
|
|
phone: '79001234567',
|
|
returnUrl: 'https://my-site.com/return'
|
|
);
|
|
|
|
$response = $connector->send(new CreateAgreementLinkRequest($payload));
|
|
|
|
expect($response->status())->toBe(200)
|
|
->and($response->json('agreementPageLink'))->toBe('https://link.alfa/...');
|
|
});
|