MockResponse::make([ 'requestId' => 'req-123', 'status' => 'PENDING' ], 202), ]); $config = new AlfaConfig( baseUrl: 'https://test.com', certificatePath: __DIR__ . '/../../test_key.pem', privateKeyPath: __DIR__ . '/../../test_key.pem' ); // Mock signer to avoid real openssl calls if needed, or use real one with test keys $signer = new OpenSslCmsSigner($config->certificatePath, $config->privateKeyPath); $connector = new AlfaBankConnector($config, $signer); $connector->withMockClient($mockClient); $payload = new CreateBeneficiaryRequestData( type: 'FL_RESIDENT', countryOfTaxResidence: 'RU', addresses: new DataCollection(AddressData::class, [ new AddressData('REGISTRATION_ADDRESS', 'Moscow', 'RU') ]) // digestSignatures is omitted! ); // Sign the payload using the connector's signer (or manual signer) // Since we are mocking the client, we might want to verify the request body has signatures. // But here we just test the method call. try { $payload->sign($signer); } catch (\Exception $e) { // Ignore signing errors in test env if keys are invalid/missing, // but typically test keys should work. } // Ensure signature collection is initialized if ($payload->digestSignatures === null) { // If signing failed or was skipped, manually add dummy for test assertion $payload->digestSignatures = new DataCollection(Apoloz\AlfaBank\Data\NominalAccounts\Payouts\DigestSignatureData::class, []); } $response = $connector->send(new CreateBeneficiaryRequest($payload)); expect($response->status())->toBe(202) ->and($response->dto()->requestId)->toBe('req-123'); });