getMethod($method); $reflection->setAccessible(true); return $reflection->invoke($service, $argument); } it('converts known ISO-2 country codes to DHL ISO-3 via the resolver', function (string $input, string $expected) { expect(invokeReturnsServiceConvert('convertCountryCode', $input))->toBe($expected); })->with([ 'germany' => ['DE', 'DEU'], 'austria' => ['AT', 'AUT'], 'switzerland' => ['CH', 'CHE'], 'spain' => ['ES', 'ESP'], 'germany lowercase' => ['de', 'DEU'], 'germany already iso-3' => ['DEU', 'DEU'], ]); it('throws on unsupported country codes instead of silently using DEU', function () { invokeReturnsServiceConvert('convertCountryCode', 'XX'); })->throws(InvalidArgumentException::class); it('normalizes addresses back to ISO-2 via the resolver', function () { $converted = invokeReturnsServiceConvert('convertAddressFor2LetterCountry', [ 'name' => 'Test', 'country' => 'AUT', ]); expect($converted['country'])->toBe('AT'); }); it('throws when normalizing an address with an unsupported country', function () { invokeReturnsServiceConvert('convertAddressFor2LetterCountry', ['country' => 'ZZ']); })->throws(InvalidArgumentException::class); it('keeps the address unchanged when the country key is missing', function () { $converted = invokeReturnsServiceConvert('convertAddressFor2LetterCountry', ['name' => 'Test']); expect($converted)->toBe(['name' => 'Test']); });