Skip to content

Commit

Permalink
Merge branch '5.1.x' of github.com:baserproject/basercms into 5.1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring committed Sep 6, 2024
2 parents b5084db + d66f405 commit 98026de
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
3 changes: 2 additions & 1 deletion plugins/baser-core/src/Utility/BcLang.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public function isMatchDecisionKey()
* @return array|string
* @checked
* @noTodo
* @unitTest
*/
static public function parseLang($acceptLanguage)
{
Expand All @@ -121,5 +122,5 @@ static public function parseLang($acceptLanguage)
}
return $langs[0];
}

}
58 changes: 58 additions & 0 deletions plugins/baser-core/tests/TestCase/Utility/BcLangTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace BaserCore\Test\TestCase\Utility;

use BaserCore\TestSuite\BcTestCase;
use BaserCore\Utility\BcLang;

class BcLangTest extends BcTestCase
{
public function setUp(): void
{
parent::setUp();
}

public function tearDown(): void
{
parent::tearDown();
}

public function testSetConfig()
{
$this->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'],
];
}
}

0 comments on commit 98026de

Please sign in to comment.