14declare(strict_types=1);
20use PHPUnit\Framework\Attributes\DataProvider;
21use PHPUnit\Framework\TestCase;
32 private function parse(mixed $value): array
34 $host =
new class () {
40 public function parse(mixed $value): array
46 return $host->parse($value);
51 $this->assertSame([
'de'], $this->
parse(
'de'));
58 #[DataProvider('whitespaceWrappedDeProvider')]
61 $this->assertSame([
'de'], $this->
parse($value));
70 'plain spaces' => [
' de '],
71 'trailing newline' => [
"de\n"],
72 'trailing CRLF' => [
"de\r\n"],
79 #[DataProvider('invalidLanguageKeysProvider')]
82 $this->expectException(InvalidInputException::class);
93 'uppercase' => [
'DE'],
94 'one letter' => [
'd'],
95 'three letters' => [
'deu'],
96 'contains a digit' => [
'de1'],
97 'contains a hyphen' => [
'de-at'],
103 $this->assertSame([
'de',
'fr'], $this->
parse([
' de, fr ',
'de']));
108 $this->expectException(InvalidInputException::class);
115 $this->expectException(InvalidInputException::class);
122 $this->expectException(InvalidInputException::class);
124 $this->
parse([
'de', [
'fr']]);
ParsesLanguageKeyList is a trait, exercised through a test double exposing its private toLanguageKeyL...
testRejectsANestedArrayValue()
testTrimsSurroundingWhitespaceIncludingNewlinesBeforeValidating(string $value)
Items are trimmed before validation, including a trailing newline (comma-separated request values car...
testDeduplicatesAcrossACommaSeparatedStringAndAnArray()
testRejectsAnEmptyValueAsAtLeastOneLanguageKeyIsRequired()
testRejectsANonStringNonArrayValue()
static invalidLanguageKeysProvider()
static whitespaceWrappedDeProvider()
testAcceptsAPlainTwoLetterLanguageKey()
testRejectsAMalformedLanguageKey(string $value)
LANGUAGE_KEY_FORMAT after trimming: exactly two lowercase ASCII letters.
toLanguageKeyList(mixed $value)
trait ParsesLanguageKeyList
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...