diff --git a/plugins/baser-core/src/Utility/BcLang.php b/plugins/baser-core/src/Utility/BcLang.php index 842018982f..12ee0fd491 100644 --- a/plugins/baser-core/src/Utility/BcLang.php +++ b/plugins/baser-core/src/Utility/BcLang.php @@ -99,6 +99,7 @@ public function isMatchDecisionKey() * @return array|string * @checked * @noTodo + * @unitTest */ static public function parseLang($acceptLanguage) { @@ -121,5 +122,5 @@ static public function parseLang($acceptLanguage) } return $langs[0]; } - + } diff --git a/plugins/baser-core/tests/TestCase/Utility/BcLangTest.php b/plugins/baser-core/tests/TestCase/Utility/BcLangTest.php new file mode 100644 index 0000000000..d09e64aaf4 --- /dev/null +++ b/plugins/baser-core/tests/TestCase/Utility/BcLangTest.php @@ -0,0 +1,58 @@ +markTestIncomplete('このテストは、まだ実装されていません。'); + } + + public function testGetDefaultConfig() + { + $this->markTestIncomplete('このテストは、まだ実装されていません。'); + } + + public function testGetPattern() + { + $this->markTestIncomplete('このテストは、まだ実装されていません。'); + } + + /** + * Test parseLang + * @dataProvider parseLangDataProvider + */ + public function testParseLang($acceptLanguage, $expected) + { + $result = BcLang::parseLang($acceptLanguage); + $this->assertEquals($expected, $result); + } + + public static function parseLangDataProvider() + { + return [ + [null, 'ja'], + ['', 'ja'], + ['en-US', 'en'], + ['fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5', 'fr'], + ['en-US,en;q=0.9', 'en'], + ['zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7', 'zh'], + ['en-US,en;q=0.8,es-ES;q=0.5,es;q=0.3', 'en'], + ['123,456', '123'], + ]; + } +}