value)->toBe($informations); }); it('accepts additional countries next to France', function () use ($franceInformation, $beneluxInformation): void { // GIVEN $informations = [$beneluxInformation, $franceInformation]; // WHEN $array = new CouponLegalInformationArray($informations); // THEN expect($array->value)->toBe($informations); }); it('rejects an empty array', function (): void { // GIVEN / WHEN $action = fn (): CouponLegalInformationArray => new CouponLegalInformationArray([]); // THEN expect($action)->toThrow( \DomainException::class, 'CouponLegalInformations requires at least one CouponLegalInformation.', ); }); it('rejects two legal informations for the same country', function () use ($franceInformation): void { // GIVEN $informations = [ $franceInformation, new CouponLegalInformation('Lorem ipsum dolor sit amet consectetur adipiscing elit.', Country::FRANCE), ]; // WHEN $action = fn (): CouponLegalInformationArray => new CouponLegalInformationArray($informations); // THEN expect($action)->toThrow( \DomainException::class, 'Only one CouponLegalInformation is allowed per country, duplicate for FRANCE.', ); }); it('rejects a non legal information element', function (): void { // GIVEN / WHEN $action = fn (): CouponLegalInformationArray => new CouponLegalInformationArray(['legal']); // THEN expect($action)->toThrow( \DomainException::class, 'Value of CouponLegalInformationArray must be CouponLegalInformation instances.', ); }); it('rejects a non legal information element mixed with valid ones', function () use ($franceInformation): void { // GIVEN $informations = [$franceInformation, 'legal']; // WHEN $action = fn (): CouponLegalInformationArray => new CouponLegalInformationArray($informations); // THEN expect($action)->toThrow( \DomainException::class, 'Value of CouponLegalInformationArray must be CouponLegalInformation instances.', ); }); it('rejects an array without France legal information', function () use ($beneluxInformation): void { // GIVEN $informations = [$beneluxInformation]; // WHEN $action = fn (): CouponLegalInformationArray => new CouponLegalInformationArray($informations); // THEN expect($action)->toThrow( \DomainException::class, 'CouponLegalInformations requires a CouponLegalInformation for France.', ); }); });