ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
LanguageTagTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Tests\Data;
22
24use PHPUnit\Framework\TestCase;
26
27class LanguageTagTest extends TestCase
28{
29 public function testFromString(): void
30 {
31 $tag = LanguageTag::fromString('de');
32 $this->assertInstanceOf(LanguageTag::class, $tag);
33 }
34
35 #[\PHPUnit\Framework\Attributes\DataProvider('SaveToRun')]
36 public function testParse(string $input, bool $isOk): void
37 {
38 if (!$isOk) {
39 $this->expectException(NotOKException::class);
40 }
41 $tag = LanguageTag::fromString($input);
42 $this->assertInstanceOf(LanguageTag::class, $tag);
43 }
44
45 #[\PHPUnit\Framework\Attributes\DataProvider('risky')]
46 public function testRisky(string $input, bool $isOk): void
47 {
48 $this->testParse($input, $isOk);
49 }
50
55 public static function saveToRun(): array
56 {
57 return [
58 ['de', true],
59 ['d$', false],
60 ['aa-111', true],
61 ['aa-b1b1b', true],
62 ['aa-bb', true],
63 ['aa-bbb-ccc-ddd', true],
64 ['aa-bbb', true],
65 ['aa-bbbb-cc', true],
66 ['aa-bbbb', true],
67 ['aa-x-1234ab-d', true],
68 ['aa', true],
69 ['aaa-bbb-ccc', true],
70 ['aaaa', true],
71 ['aaaaa', true],
72 ['aaaaaa', true],
73 ['aaaaaaa', true],
74 ['aaaaaaaa', true],
75 ['afb', true],
76 ['ar-afb', true],
77 ['art-lojban', true],
78 ['ast', true],
79 ['az-Latn', true],
80 ['cel-gaulish', true],
81 ['cmn-Hans-CN', true],
82 ['de-CH-1901', true],
83 ['de-DE', true],
84 ['de-Qaaa', true],
85 ['de', true],
86 ['en-GB-oed', true],
87 ['en-US-x-twain', true],
88 ['en-US', true],
89 ['en', true],
90 ['es-005', true],
91 ['es-419', true],
92 ['fr-CA', true],
93 ['fr', true],
94 ['hak', true],
95 ['i-ami', true],
96 ['i-bnn', true],
97 ['i-default', true],
98 ['i-enochian', true],
99 ['i-hak', true],
100 ['i-klingon', true],
101 ['i-lux', true],
102 ['i-mingo', true],
103 ['i-navajo', true],
104 ['i-pwn', true],
105 ['i-tao', true],
106 ['i-tay', true],
107 ['i-tsu', true],
108 ['ja', true],
109 ['mas', true],
110 ['no-bok', true],
111 ['no-nyn', true],
112 ['sgn-BE-FR', true],
113 ['sgn-BE-NL', true],
114 ['sgn-CH-DE', true],
115 ['sl-IT-nedis', true],
116 ['sl-nedis', true],
117 ['sl-rozaj-biske', true],
118 ['sl-rozaj', true],
119 ['sr-Cyrl', true],
120 ['sr-Latn-QM', true],
121 ['sr-Latn-RS', true],
122 ['sr-Latn', true],
123 ['sr-Qaaa-RS', true],
124 ['x-111-aaaaa-BBB', true],
125 ['x-whatever', true],
126 ['yue-HK', true],
127 ['zh-Hans-CN', true],
128 ['zh-Hans', true],
129 ['zh-Hant-HK', true],
130 ['zh-Hant', true],
131 ['zh-cmn-Hans-CN', true],
132 ['zh-guoyu', true],
133 ['zh-hakka', true],
134 ['zh-min-nan', true],
135 ['zh-min', true],
136 ['zh-xiang', true],
137 ['zh-yue-HK', true],
138 ['zh-yue', true],
139 ];
140 }
141
145 public static function risky(): array
146 {
147 if (function_exists('xdebug_info') && ((int) ini_get('xdebug.max_nesting_level')) < 780) {
148 self::markTestSkipped(sprintf(
149 'You are running under Xdebug. To be able to run all tests xdebug.max_nesting_level must be at least 780 (Currently %d).',
150 (int) ini_get('xdebug.max_nesting_level')
151 ));
152 }
153
154 return [
155 ['aa-bbb-ccc-1111-ccccc-b1b1b', true],
156 ['aaa-bbb-ccc-ddd-abcd-123-abc123-0abc-b-01-abc123-x-01ab-abc12', true],
157 ['az-Arab-x-AZE-derbend', true],
158 ['de-CH-x-phonebk', true],
159 ['de-DE-u-co-phonebk', true],
160 ['en-US-u-islamcal', true],
161 ['en-a-myext-b-another', true],
162 ['hy-Latn-IT-arevela', true],
163 ['qaa-Qaaa-QM-x-southern', true],
164 ['aa-7-123abc-abc-a-12', true],
165 ['aa-b1b1b-6a8b-cccccc', true],
166 ['zh-CN-a-myext-x-private', true],
167 ];
168 }
169}
static fromString(string $string)
Definition: LanguageTag.php:48
Signals that a result contains no value.
testRisky(string $input, bool $isOk)
testParse(string $input, bool $isOk)