|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +use Ecma\Intl\Locale\Options; |
| 6 | + |
| 7 | +it('throws an exception for invalid calendar', function (): void { |
| 8 | + expect(fn () => new Options(calendar: 'gregoryab')) |
| 9 | + ->toThrow(ValueError::class, 'calendar is not a well-formed calendar value'); |
| 10 | +}); |
| 11 | + |
| 12 | +it('throws an exception for invalid caseFirst', function (): void { |
| 13 | + expect(fn () => new Options(caseFirst: 'foobar')) |
| 14 | + ->toThrow(ValueError::class, 'caseFirst must be either "upper", "lower", or "false"'); |
| 15 | +}); |
| 16 | + |
| 17 | +it('throws an exception for invalid collation', function (): void { |
| 18 | + expect(fn () => new Options(collation: 'emojiabcd')) |
| 19 | + ->toThrow(ValueError::class, 'collation is not a well-formed collation value'); |
| 20 | +}); |
| 21 | + |
| 22 | +it('throws an exception for invalid hourCycle', function (): void { |
| 23 | + expect(fn () => new Options(hourCycle: 'hour12')) |
| 24 | + ->toThrow(ValueError::class, 'hourCycle must be "h11", "h12", "h23", or "h24"'); |
| 25 | +}); |
| 26 | + |
| 27 | +it('throws an exception for invalid language', function (): void { |
| 28 | + expect(fn () => new Options(language: 'english language')) |
| 29 | + ->toThrow(ValueError::class, 'language is not a well-formed language value'); |
| 30 | +}); |
| 31 | + |
| 32 | +it('throws an exception for invalid numberingSystem', function (): void { |
| 33 | + expect(fn () => new Options(numberingSystem: 'numbersystem')) |
| 34 | + ->toThrow(ValueError::class, 'numberingSystem is not a well-formed numbering system value'); |
| 35 | +}); |
| 36 | + |
| 37 | +it('throws an exception for invalid numeric', function (): void { |
| 38 | + expect(fn () => new Options(numeric: 1234)) |
| 39 | + ->toThrow( |
| 40 | + TypeError::class, |
| 41 | + 'Ecma\Intl\Locale\Options::__construct(): Argument #7 ($numeric) must be of type ?bool, int given', |
| 42 | + ); |
| 43 | +}); |
| 44 | + |
| 45 | +it('throws an exception for invalid region', function (): void { |
| 46 | + expect(fn () => new Options(region: 'region')) |
| 47 | + ->toThrow(ValueError::class, 'region is not a well-formed region value'); |
| 48 | +}); |
| 49 | + |
| 50 | +it('throws an exception for invalid script', function (): void { |
| 51 | + expect(fn () => new Options(script: 'script')) |
| 52 | + ->toThrow(ValueError::class, 'script is not a well-formed script value'); |
| 53 | +}); |
0 commit comments