Skip to content
Snippets Groups Projects
Commit 595fe442 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

provide tests for Request::i18n(), re #4774

Merge request !3568
parent 54108834
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,9 @@ class RequestParametersTest extends Codeception\Test\Unit
$_GET['datetime'] = '2025-03-25 17:39:04';
$_GET['invalid_date'] = 'foobar';
$_POST['localized'] = 'abc';
$_POST['localized_i18n']['en_GB'] = 'def';
$testconfig = new Config([
'USERNAME_REGULAR_EXPRESSION' => '/^([a-zA-Z0-9_@.-]{4,})$/',
]);
......@@ -284,6 +287,29 @@ class RequestParametersTest extends Codeception\Test\Unit
$this->assertFalse($invalid_date);
}
/**
* @covers Request::i18n
*/
public function testRequestI18n()
{
$i18n = Request::i18n('localized');
$this->assertEquals('abc', $i18n->original());
$this->assertEquals('def', $i18n->localized('en_GB'));
$this->assertNull($i18n->localized('no_LANG'));
}
/**
* @covers Request::i18n
*/
public function testRequestI18nWithDefault()
{
$default = new I18NString('foo', ['en_GB' => 'bar']);
$i18n = Request::i18n('unknown', $default);
$this->assertEquals('foo', $i18n->original());
$this->assertEquals('bar', $i18n->localized('en_GB'));
}
public function tearDown(): void
{
Config::set(null);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment