@@ -31,7 +31,7 @@ final class LanguageTest extends CIUnitTestCase
31
31
32
32
protected function setUp (): void
33
33
{
34
- $ this ->lang = new MockLanguage ('en ' );
34
+ $ this ->lang = new Language ('en ' );
35
35
}
36
36
37
37
public function testReturnsStringWithNoFileInMessage (): void
@@ -54,6 +54,8 @@ public function testReturnParsedStringWithNoFileInMessage(): void
54
54
55
55
public function testGetLineReturnsLine (): void
56
56
{
57
+ $ this ->lang = new MockLanguage ('en ' );
58
+
57
59
$ this ->lang ->setData ('books ' , [
58
60
'bookSaved ' => 'We kept the book free from the boogeyman ' ,
59
61
'booksSaved ' => 'We saved some more ' ,
@@ -64,6 +66,8 @@ public function testGetLineReturnsLine(): void
64
66
65
67
public function testGetLineReturnsLineWithKeyWithDots (): void
66
68
{
69
+ $ this ->lang = new MockLanguage ('en ' );
70
+
67
71
$ this ->lang ->setData ('books ' , [
68
72
'bookSaved.foo ' => 'We kept the book free from the boogeyman ' ,
69
73
'booksSaved.bar.baz ' => 'We saved some more ' ,
@@ -81,6 +85,8 @@ public function testGetLineReturnsLineWithKeyWithDots(): void
81
85
82
86
public function testGetLineCannotUseKeysWithLeadingDot (): void
83
87
{
88
+ $ this ->lang = new MockLanguage ('en ' );
89
+
84
90
$ this ->lang ->setData ('books ' , [
85
91
'.bookSaved.foo. ' => 'We kept the book free from the boogeyman ' ,
86
92
'.booksSaved.bar.baz. ' => 'We saved some more ' ,
@@ -98,6 +104,8 @@ public function testGetLineCannotUseKeysWithLeadingDot(): void
98
104
99
105
public function testGetLineCannotUseKeysWithTrailingDot (): void
100
106
{
107
+ $ this ->lang = new MockLanguage ('en ' );
108
+
101
109
$ this ->lang ->setData ('books ' , [
102
110
'bookSaved.foo. ' => 'We kept the book free from the boogeyman ' ,
103
111
'booksSaved.bar.baz. ' => 'We saved some more ' ,
@@ -115,6 +123,8 @@ public function testGetLineCannotUseKeysWithTrailingDot(): void
115
123
116
124
public function testGetLineReturnsFallbackLine (): void
117
125
{
126
+ $ this ->lang = new MockLanguage ('en ' );
127
+
118
128
$ this ->lang
119
129
->setLocale ('en-US ' )
120
130
->setData ('equivalent ' , [
@@ -137,6 +147,8 @@ public function testGetLineReturnsFallbackLine(): void
137
147
138
148
public function testGetLineArrayReturnsLineArray (): void
139
149
{
150
+ $ this ->lang = new MockLanguage ('en ' );
151
+
140
152
$ this ->lang ->setData ('books ' , [
141
153
'booksList ' => [
142
154
'The Boogeyman ' ,
@@ -157,6 +169,8 @@ public function testGetLineFormatsMessage(): void
157
169
$ this ->markTestSkipped ('No intl support. ' );
158
170
}
159
171
172
+ $ this ->lang = new MockLanguage ('en ' );
173
+
160
174
$ this ->lang ->setData ('books ' , [
161
175
'bookCount ' => '{0, number, integer} books have been saved. ' ,
162
176
]);
@@ -171,6 +185,8 @@ public function testGetLineArrayFormatsMessages(): void
171
185
$ this ->markTestSkipped ('No intl support. ' );
172
186
}
173
187
188
+ $ this ->lang = new MockLanguage ('en ' );
189
+
174
190
$ this ->lang ->setData ('books ' , [
175
191
'bookList ' => [
176
192
'{0, number, integer} related books. ' ,
@@ -190,6 +206,8 @@ public function testGetLineInvalidFormatMessage(): void
190
206
$ this ->markTestSkipped ('No intl support. ' );
191
207
}
192
208
209
+ $ this ->lang = new MockLanguage ('en ' );
210
+
193
211
$ this ->lang ->setLocale ('ar ' );
194
212
195
213
$ line = 'تم الكشف عن كلمة المرور {0} بسبب اختراق البيانات وشوهدت {1 ، عدد} مرة في {2} في كلمات المرور المخترقة. ' ;
@@ -214,6 +232,8 @@ public function testLangAllowsOtherLocales(): void
214
232
215
233
public function testLangDoesntFormat (): void
216
234
{
235
+ $ this ->lang = new MockLanguage ('en ' );
236
+
217
237
$ this ->lang ->disableIntlSupport ();
218
238
219
239
$ this ->lang ->setData ('books ' , [
@@ -236,40 +256,42 @@ public function testLanguageDuplicateKey(): void
236
256
237
257
public function testLanguageFileLoading (): void
238
258
{
239
- $ this -> lang = new SecondMockLanguage ('en ' );
259
+ $ lang = new SecondMockLanguage ('en ' );
240
260
241
- $ this -> lang ->loadem ('More ' , 'en ' );
242
- $ this ->assertContains ('More ' , $ this -> lang ->loaded ());
261
+ $ lang ->loadem ('More ' , 'en ' );
262
+ $ this ->assertContains ('More ' , $ lang ->loaded ());
243
263
244
- $ this -> lang ->loadem ('More ' , 'en ' );
245
- $ this ->assertCount (1 , $ this -> lang ->loaded ()); // should only be there once
264
+ $ lang ->loadem ('More ' , 'en ' );
265
+ $ this ->assertCount (1 , $ lang ->loaded ()); // should only be there once
246
266
}
247
267
248
268
public function testLanguageFileLoadingReturns (): void
249
269
{
250
- $ this -> lang = new SecondMockLanguage ('en ' );
270
+ $ lang = new SecondMockLanguage ('en ' );
251
271
252
- $ result = $ this -> lang ->loadem ('More ' , 'en ' , true );
253
- $ this ->assertNotContains ('More ' , $ this -> lang ->loaded ());
272
+ $ result = $ lang ->loadem ('More ' , 'en ' , true );
273
+ $ this ->assertNotContains ('More ' , $ lang ->loaded ());
254
274
$ this ->assertCount (3 , $ result );
255
275
256
- $ this -> lang ->loadem ('More ' , 'en ' );
257
- $ this ->assertContains ('More ' , $ this -> lang ->loaded ());
258
- $ this ->assertCount (1 , $ this -> lang ->loaded ());
276
+ $ lang ->loadem ('More ' , 'en ' );
277
+ $ this ->assertContains ('More ' , $ lang ->loaded ());
278
+ $ this ->assertCount (1 , $ lang ->loaded ());
259
279
}
260
280
261
281
public function testLanguageSameKeyAndFileName (): void
262
282
{
283
+ $ lang = new MockLanguage ('en ' );
284
+
263
285
// first file data | example.message
264
- $ this -> lang ->setData ('example ' , ['message ' => 'This is an example message ' ]);
286
+ $ lang ->setData ('example ' , ['message ' => 'This is an example message ' ]);
265
287
266
288
// force loading data into file Example
267
- $ this ->assertSame ('This is an example message ' , $ this -> lang ->getLine ('example.message ' ));
289
+ $ this ->assertSame ('This is an example message ' , $ lang ->getLine ('example.message ' ));
268
290
269
291
// second file data | another.example
270
- $ this -> lang ->setData ('another ' , ['example ' => 'Another example ' ]);
292
+ $ lang ->setData ('another ' , ['example ' => 'Another example ' ]);
271
293
272
- $ this ->assertSame ('Another example ' , $ this -> lang ->getLine ('another.example ' ));
294
+ $ this ->assertSame ('Another example ' , $ lang ->getLine ('another.example ' ));
273
295
}
274
296
275
297
public function testGetLocale (): void
0 commit comments