@@ -31,7 +31,7 @@ final class LanguageTest extends CIUnitTestCase
3131
3232 protected function setUp (): void
3333 {
34- $ this ->lang = new MockLanguage ('en ' );
34+ $ this ->lang = new Language ('en ' );
3535 }
3636
3737 public function testReturnsStringWithNoFileInMessage (): void
@@ -54,6 +54,8 @@ public function testReturnParsedStringWithNoFileInMessage(): void
5454
5555 public function testGetLineReturnsLine (): void
5656 {
57+ $ this ->lang = new MockLanguage ('en ' );
58+
5759 $ this ->lang ->setData ('books ' , [
5860 'bookSaved ' => 'We kept the book free from the boogeyman ' ,
5961 'booksSaved ' => 'We saved some more ' ,
@@ -64,6 +66,8 @@ public function testGetLineReturnsLine(): void
6466
6567 public function testGetLineReturnsLineWithKeyWithDots (): void
6668 {
69+ $ this ->lang = new MockLanguage ('en ' );
70+
6771 $ this ->lang ->setData ('books ' , [
6872 'bookSaved.foo ' => 'We kept the book free from the boogeyman ' ,
6973 'booksSaved.bar.baz ' => 'We saved some more ' ,
@@ -81,6 +85,8 @@ public function testGetLineReturnsLineWithKeyWithDots(): void
8185
8286 public function testGetLineCannotUseKeysWithLeadingDot (): void
8387 {
88+ $ this ->lang = new MockLanguage ('en ' );
89+
8490 $ this ->lang ->setData ('books ' , [
8591 '.bookSaved.foo. ' => 'We kept the book free from the boogeyman ' ,
8692 '.booksSaved.bar.baz. ' => 'We saved some more ' ,
@@ -98,6 +104,8 @@ public function testGetLineCannotUseKeysWithLeadingDot(): void
98104
99105 public function testGetLineCannotUseKeysWithTrailingDot (): void
100106 {
107+ $ this ->lang = new MockLanguage ('en ' );
108+
101109 $ this ->lang ->setData ('books ' , [
102110 'bookSaved.foo. ' => 'We kept the book free from the boogeyman ' ,
103111 'booksSaved.bar.baz. ' => 'We saved some more ' ,
@@ -115,6 +123,8 @@ public function testGetLineCannotUseKeysWithTrailingDot(): void
115123
116124 public function testGetLineReturnsFallbackLine (): void
117125 {
126+ $ this ->lang = new MockLanguage ('en ' );
127+
118128 $ this ->lang
119129 ->setLocale ('en-US ' )
120130 ->setData ('equivalent ' , [
@@ -137,6 +147,8 @@ public function testGetLineReturnsFallbackLine(): void
137147
138148 public function testGetLineArrayReturnsLineArray (): void
139149 {
150+ $ this ->lang = new MockLanguage ('en ' );
151+
140152 $ this ->lang ->setData ('books ' , [
141153 'booksList ' => [
142154 'The Boogeyman ' ,
@@ -157,6 +169,8 @@ public function testGetLineFormatsMessage(): void
157169 $ this ->markTestSkipped ('No intl support. ' );
158170 }
159171
172+ $ this ->lang = new MockLanguage ('en ' );
173+
160174 $ this ->lang ->setData ('books ' , [
161175 'bookCount ' => '{0, number, integer} books have been saved. ' ,
162176 ]);
@@ -171,6 +185,8 @@ public function testGetLineArrayFormatsMessages(): void
171185 $ this ->markTestSkipped ('No intl support. ' );
172186 }
173187
188+ $ this ->lang = new MockLanguage ('en ' );
189+
174190 $ this ->lang ->setData ('books ' , [
175191 'bookList ' => [
176192 '{0, number, integer} related books. ' ,
@@ -190,6 +206,8 @@ public function testGetLineInvalidFormatMessage(): void
190206 $ this ->markTestSkipped ('No intl support. ' );
191207 }
192208
209+ $ this ->lang = new MockLanguage ('en ' );
210+
193211 $ this ->lang ->setLocale ('ar ' );
194212
195213 $ line = 'تم الكشف عن كلمة المرور {0} بسبب اختراق البيانات وشوهدت {1 ، عدد} مرة في {2} في كلمات المرور المخترقة. ' ;
@@ -214,6 +232,8 @@ public function testLangAllowsOtherLocales(): void
214232
215233 public function testLangDoesntFormat (): void
216234 {
235+ $ this ->lang = new MockLanguage ('en ' );
236+
217237 $ this ->lang ->disableIntlSupport ();
218238
219239 $ this ->lang ->setData ('books ' , [
@@ -236,40 +256,42 @@ public function testLanguageDuplicateKey(): void
236256
237257 public function testLanguageFileLoading (): void
238258 {
239- $ this -> lang = new SecondMockLanguage ('en ' );
259+ $ lang = new SecondMockLanguage ('en ' );
240260
241- $ this -> lang ->loadem ('More ' , 'en ' );
242- $ this ->assertContains ('More ' , $ this -> lang ->loaded ());
261+ $ lang ->loadem ('More ' , 'en ' );
262+ $ this ->assertContains ('More ' , $ lang ->loaded ());
243263
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
246266 }
247267
248268 public function testLanguageFileLoadingReturns (): void
249269 {
250- $ this -> lang = new SecondMockLanguage ('en ' );
270+ $ lang = new SecondMockLanguage ('en ' );
251271
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 ());
254274 $ this ->assertCount (3 , $ result );
255275
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 ());
259279 }
260280
261281 public function testLanguageSameKeyAndFileName (): void
262282 {
283+ $ lang = new MockLanguage ('en ' );
284+
263285 // 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 ' ]);
265287
266288 // 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 ' ));
268290
269291 // second file data | another.example
270- $ this -> lang ->setData ('another ' , ['example ' => 'Another example ' ]);
292+ $ lang ->setData ('another ' , ['example ' => 'Another example ' ]);
271293
272- $ this ->assertSame ('Another example ' , $ this -> lang ->getLine ('another.example ' ));
294+ $ this ->assertSame ('Another example ' , $ lang ->getLine ('another.example ' ));
273295 }
274296
275297 public function testGetLocale (): void
0 commit comments