iso(); // THEN expect($iso)->toBe('FR'); }); it('throws exception if iso code is missing', function () { // GIVEN $country = Country::afghanistan; // WHEN $action = fn () => $country->iso(); // THEN expect($action)->toThrow(UnknownCountryIsoCodeException::class); }); it('returns iso num for France', function () { // GIVEN $country = Country::france; // WHEN $isoNum = $country->isoNum(); // THEN expect($isoNum)->toBe(250); }); it('throws exception if iso num is missing', function () { // GIVEN $country = Country::afghanistan; // WHEN $action = fn () => $country->isoNum(); // THEN expect($action)->toThrow(UnknownCountryIsoCodeException::class); }); it('returns null if iso code is missing via isoCode method', function () { // GIVEN $country = Country::afghanistan; // WHEN $isoCode = $country->isoCode(); // THEN expect($isoCode)->toBeNull(); }); it('can be created from iso code', function () { // GIVEN $iso = 'FR'; // WHEN $country = Country::fromIsoCode($iso); // THEN expect($country)->toBe(Country::france); }); it('throws exception if created from invalid iso code', function () { // GIVEN $iso = 'ZZ'; // WHEN $action = fn () => Country::fromIsoCode($iso); // THEN expect($action)->toThrow(UnknownCountryIsoCodeException::class); }); it('can list all iso codes', function () { // GIVEN $dummy = true; // WHEN $isoCodes = Country::toIsoCodes(); // THEN expect($isoCodes)->toBeArray()->toHaveKey('france', 'FR'); }); });