MockResponse::make([ 'access_token' => 'test-access-token', 'refresh_token' => 'test-refresh-token', 'expires_in' => 3600, 'token_type' => 'Bearer', ], 200), ]); $config = new AlfaConfig( baseUrl: 'https://test.com', certificatePath: __DIR__ . '/../../test_key.pem', // Use any existing file privateKeyPath: __DIR__ . '/../../test_key.pem' ); $connector = new AlfaBankConnector($config); $connector->withMockClient($mockClient); $request = new GetTokenRequest('client-id', 'client-secret', null, null, 'client_credentials'); $response = $connector->send($request); expect($response->status())->toBe(200) ->and($response->dto()->access_token)->toBe('test-access-token'); }); test('can login and set token', function () { $mockClient = new \Saloon\Http\Faking\MockClient([ GetTokenRequest::class => MockResponse::make([ 'access_token' => 'test-access-token', 'refresh_token' => 'test-refresh-token', 'expires_in' => 3600, 'token_type' => 'Bearer', ], 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); $connector->login('client-id', 'client-secret'); expect($connector->getAuthenticator())->not->toBeNull(); });