forked from apoloz/alfa-bank-sdk
refactor(core): enhance SDK structure and documentation
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
30
tests/Feature/Sbp/ConfigTest.php
Normal file
30
tests/Feature/Sbp/ConfigTest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Apoloz\AlfaBank\Sbp\SbpConnector;
|
||||
use Apoloz\AlfaBank\Sbp\Requests\GetQrCodeRequest;
|
||||
use Apoloz\AlfaBank\Sbp\Data\QrCodeRequestData;
|
||||
use Apoloz\AlfaBank\Core\AlfaConfig;
|
||||
use Saloon\Http\Faking\MockResponse;
|
||||
|
||||
test('sbp connector uses injected config', function () {
|
||||
$mockClient = new \Saloon\Http\Faking\MockClient([
|
||||
GetQrCodeRequest::class => MockResponse::make(['payload' => 'https://test.qr'], 200),
|
||||
]);
|
||||
|
||||
$config = new AlfaConfig(
|
||||
baseUrl: 'https://test.alfa',
|
||||
certificatePath: __DIR__ . '/../../test_key.pem', // valid path
|
||||
privateKeyPath: __DIR__ . '/../../test_key.pem', // valid path
|
||||
);
|
||||
|
||||
$connector = new SbpConnector($config, 'alias');
|
||||
$connector->withMockClient($mockClient);
|
||||
|
||||
expect($connector->resolveBaseUrl())->toBe('https://test.alfa');
|
||||
|
||||
$response = $connector->send(new GetQrCodeRequest(
|
||||
new QrCodeRequestData('term', '01', '100', 'purpose')
|
||||
));
|
||||
|
||||
expect($response->status())->toBe(200);
|
||||
});
|
||||
Reference in New Issue
Block a user