Files
alfa-bank-sdk/tests/Feature/SelfEmployed/DictionaryTest.php

45 lines
1.8 KiB
PHP

<?php
use Apoloz\AlfaBank\Core\AlfaBankConnector;
use Apoloz\AlfaBank\Core\AlfaConfig;
use Apoloz\AlfaBank\Requests\SelfEmployed\GetActivitiesRequest;
use Saloon\Http\Faking\MockResponse;
test('can get activities dictionary', function () {
$mockClient = new \Saloon\Http\Faking\MockClient([
GetActivitiesRequest::class => MockResponse::make([
['id' => '1', 'name' => 'IT Services'],
['id' => '2', 'name' => 'Design'],
], 200, ['Content-Type' => 'application/json']),
]);
$config = createTestConfig();
$connector = new AlfaBankConnector($config);
$connector->withMockClient($mockClient);
$response = $connector->send(new GetActivitiesRequest());
expect($response->status())->toBe(200)
->and($response->dto()->count())->toBe(2)
->and($response->dto()->first()->name)->toBe('IT Services');
});
test('can get regions dictionary', function () {
$mockClient = new \Saloon\Http\Faking\MockClient([
\Apoloz\AlfaBank\Requests\SelfEmployed\GetRegionsRequest::class => \Saloon\Http\Faking\MockResponse::make([
'regions' => [['code' => '77', 'name' => 'Москва']]
], 200),
]);
$config = new \Apoloz\AlfaBank\Core\AlfaConfig('https://test.com', __DIR__ . '/../../test_cert.pem', __DIR__ . '/../../test_key.pem');
$signer = new \Apoloz\AlfaBank\Services\OpenSslCmsSigner(__DIR__ . '/../../test_cert.pem', __DIR__ . '/../../test_key.pem');
$connector = new \Apoloz\AlfaBank\Core\AlfaBankConnector($config, $signer);
$connector->withMockClient($mockClient);
$response = $connector->send(new \Apoloz\AlfaBank\Requests\SelfEmployed\GetRegionsRequest());
expect($response->status())->toBe(200)
->and($response->json('regions.0.name'))->toBe('Москва');
});