toBeInstanceOf(CountryAuthorized::class) ->and($authorized->country)->toBe($country); })->with([ 'france' => 'france', 'belgium' => 'belgium', 'luxembourg' => 'luxembourg', ]); it('rejects a country that is not authorized', function (): void { // WHEN $action = fn (): CountryAuthorized => new CountryAuthorized(Country::GERMANY); // THEN expect($action)->toThrow(\DomainException::class, 'Country "GERMANY" is not authorized.'); }); it('lists the authorized countries', function (): void { // THEN expect(CountryAuthorized::authorizedCountries())->toBe([ Country::FRANCE, Country::BELGIUM, Country::LUXEMBOURG, ]); }); it('implements equals correctly', function (): void { // GIVEN $france1 = new CountryAuthorized(Country::FRANCE); $france2 = new CountryAuthorized(Country::FRANCE); $belgium = new CountryAuthorized(Country::BELGIUM); // THEN expect($france1->equals($france2))->toBeTrue() ->and($france1->equals($belgium))->toBeFalse() ->and($france1->equals(null))->toBeFalse(); }); it('converts to string as the country backing value', function (): void { // GIVEN $authorized = new CountryAuthorized(Country::FRANCE); // THEN expect((string) $authorized)->toBe('france'); }); });