ソースを参照

Added test for default locale

Livia Scapin 8 年 前
コミット
de5020c9ff
1 ファイル変更14 行追加1 行削除
  1. 14 1
      tests/TestCase/I18n/I18nTest.php

+ 14 - 1
tests/TestCase/I18n/I18nTest.php

@@ -19,6 +19,7 @@ use Cake\Cache\Cache;
 use Cake\Core\Plugin;
 use Cake\I18n\I18n;
 use Cake\TestSuite\TestCase;
+use Locale;
 
 /**
  * I18nTest class
@@ -41,7 +42,7 @@ class I18nTest extends TestCase
     public function setUp()
     {
         parent::setUp();
-        $this->locale = I18n::getLocale();
+        $this->locale = Locale::getDefault() ?: I18n::DEFAULT_LOCALE;
     }
 
     /**
@@ -58,6 +59,18 @@ class I18nTest extends TestCase
         Plugin::unload();
         Cache::clear(false, '_cake_core_');
     }
+    
+    /**
+     * Tests that the default locale is set correctly
+     *
+     * @return void
+     */
+    public function testDefaultLocale() {
+        $newLocale = 'de_DE';
+        I18n::setLocale($newLocale);
+        $this->assertEquals($newLocale, I18n::getLocale());
+        $this->assertEquals($this->locale, I18n::getDefaultLocale());
+    }
 
     /**
      * Tests that a default translator is created and messages are parsed