aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2024-10-29 08:30:33 +0000
committerJan-Hendrik Willms <tleilax+studip@gmail.com>2024-10-29 08:30:33 +0000
commit595fe442a7937ec3476553aa87945fc6d98a47f5 (patch)
tree38898b0b07fc248d97928be0107a0cc8883e354d /tests
parent541088347bf3c9ff69ec61466091e9997c6dcb85 (diff)
provide tests for Request::i18n(), re #4774
Merge request studip/studip!3568
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/lib/classes/RequestParametersTest.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/unit/lib/classes/RequestParametersTest.php b/tests/unit/lib/classes/RequestParametersTest.php
index 85ef33c..49f8098 100644
--- a/tests/unit/lib/classes/RequestParametersTest.php
+++ b/tests/unit/lib/classes/RequestParametersTest.php
@@ -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);