value)->toBe($validSignature); }); }); describe('RequestSignature Value Object Validation Rules', function (): void { it('throws InvalidArgumentException when given an empty signature', function (string $invalid): void { // GIVEN $input = $invalid; // WHEN $execution = fn () => new RequestSignature($input); // THEN expect($execution)->toThrow( \InvalidArgumentException::class, 'RequestSignature cannot be empty.' ); })->with(['', ' ']); it('throws InvalidArgumentException when signature format is invalid', function (string $invalid): void { // GIVEN $input = $invalid; // WHEN $execution = fn () => new RequestSignature($input); // THEN expect($execution)->toThrow( \InvalidArgumentException::class, 'RequestSignature must be a valid 64-character hex HMAC-SHA256 string.' ); })->with([ 'invalid_hex', '123456', str_repeat('g', 64), // Invalid hex character 'g' str_repeat('a', 63), // 63 chars (too short) str_repeat('a', 65), // 65 chars (too long) ]); });