3 namespace Friendica\Test\src\Core\L10n;
5 use Friendica\Core\L10n;
6 use Friendica\Test\MockedTest;
8 class L10nTest extends MockedTest
10 public function dataDetectLanguage()
21 'get' => ['lang' => 'de'],
26 'server' => ['HTTP_ACCEPT_LANGUAGE' => 'en-gb'],
32 'server' => ['HTTP_ACCEPT_LANGUAGE' => 'fr'],
38 'server' => ['HTTP_ACCEPT_LANGUAGE' => 'fr;q=0.5,de'],
44 'server' => ['HTTP_ACCEPT_LANGUAGE' => 'fr;q=0.5,de;q=0.2'],
49 'withLangOverride' => [
50 'server' => ['HTTP_ACCEPT_LANGUAGE' => 'fr;q=0.5,de;q=0.2'],
51 'get' => ['lang' => 'it'],
55 'withQualityAndPipe' => [
56 'server' => ['HTTP_ACCEPT_LANGUAGE' => 'fr;q=0.5,de;q=0.2,nb-no;q=0.7'],
61 'withQualityAndInvalid' => [
62 'server' => ['HTTP_ACCEPT_LANGUAGE' => 'fr;q=0.5,bla;q=0.2,nb-no;q=0.7'],
67 'withQualityAndInvalid2' => [
68 'server' => ['HTTP_ACCEPT_LANGUAGE' => 'blu;q=0.9,bla;q=0.2,nb-no;q=0.7'],
73 'withQualityAndInvalidAndAbsolute' => [
74 'server' => ['HTTP_ACCEPT_LANGUAGE' => 'blu;q=0.9,de,nb-no;q=0.7'],
80 'server' => ['HTTP_ACCEPT_LANGUAGE' => 'blu;q=0.9,nb-no;q=0.7'],
81 'get' => ['lang' => 'blu'],
89 * @dataProvider dataDetectLanguage
91 public function testDetectLanguage(array $server, array $get, string $default, string $assert)
93 $this->assertEquals($assert, L10n::detectLanguage($server, $get, $default));