value)->toBe($processingCodes); }); it('accepts additional countries next to France', function () use ($franceCode, $beneluxCode): void { // GIVEN $processingCodes = [$beneluxCode, $franceCode]; // WHEN $array = new ProcessingCodeArray($processingCodes); // THEN expect($array->value)->toBe($processingCodes); }); it('rejects an empty array', function (): void { // GIVEN / WHEN $action = fn (): ProcessingCodeArray => new ProcessingCodeArray([]); // THEN expect($action)->toThrow( \DomainException::class, 'ProcessingCodes requires at least one ProcessingCode.', ); }); it('rejects two legal informations for the same country', function () use ($franceCode): void { // GIVEN $informations = [ $franceCode, new ProcessingCode('5425003944130', Country::FRANCE), ]; // WHEN $action = fn (): ProcessingCodeArray => new ProcessingCodeArray($informations); // THEN expect($action)->toThrow( \DomainException::class, 'Only one ProcessingCode is allowed per country, duplicate for FRANCE.', ); }); it('rejects a non processing code element', function (): void { // GIVEN / WHEN $action = fn (): ProcessingCodeArray => new ProcessingCodeArray(['ABC1234567890']); // THEN expect($action)->toThrow( \DomainException::class, 'Value of ProcessingCodeArray must be ProcessingCode instances.', ); }); it('rejects a non processing code element mixed with valid ones', function () use ($franceCode): void { // GIVEN $processingCodes = [$franceCode, 'ABC1234567890']; // WHEN $action = fn (): ProcessingCodeArray => new ProcessingCodeArray($processingCodes); // THEN expect($action)->toThrow( \DomainException::class, 'Value of ProcessingCodeArray must be ProcessingCode instances.', ); }); it('rejects an array without France processing code', function () use ($beneluxCode): void { // GIVEN $processingCodes = [$beneluxCode]; // WHEN $action = fn (): ProcessingCodeArray => new ProcessingCodeArray($processingCodes); // THEN expect($action)->toThrow( \DomainException::class, 'ProcessingCodes requires a ProcessingCode for France.', ); }); });