Database-backed methods run against an ilDBInterface mock returning controlled rows; filesystem-backed methods use a real temporary installation root, like LanguageInstallationManagerTest.
More...
|
| | testGetAvailableLanguagesMapsObjIdAndStatusToTheCorrectLanguageNotSwapped () |
| |
| | testGetAvailableLanguagesReturnsEmptyArrayWhenNoLanguagesAreKnown () |
| |
| | testGetInstalledLanguagesQueriesForInstalledPrefixAndReturnsTitles () |
| |
| | testGetInstalledLocalLanguagesQueriesForExactlyInstalledLocalAndReturnsTitles () |
| |
| | testGetLocalChangesDefaultsMinAndMaxDateWhenEmptyStringsArePassed () |
| |
| | testGetLocalChangesKeepsExplicitlyGivenDatesInsteadOfDefaulting () |
| |
| | testGetLocalChangesStructuresResultAsModuleThenIdentifierThenValue () |
| |
| | testGetLocalChangesReturnsEmptyArrayWhenNothingMatches () |
| |
| | testGetLanguageEntriesStructuresResultAsModuleThenIdentifierThenValue () |
| |
| | testGetLanguageEntriesReturnsEmptyArrayWhenNothingMatches () |
| |
| | testGetLanguageEntriesQueryDoesNotFilterByLocalChange () |
| | Unlike getLocalChanges(), getLanguageEntries() returns every stored entry of the language key, so its query must not filter on local_change. More...
|
| |
| | testGetLocalLanguagesExtractsKeysFromLocalFilesAndIgnoresUnrelatedFiles () |
| |
| | testGetLocalLanguagesIgnoresFilesWithAnInvalidLanguageKeyShapeInTheirName () |
| | The discovery regex must accept exactly ParsesLanguageKeyList::LANGUAGE_KEY_FORMAT ('/^[a-z]{2}$/'): other file names must be ignored, or they would fail later in the Activity's stricter validation. More...
|
| |
| | testGetInstallableLanguagesIgnoresFilesWithAnInvalidLanguageKeyShapeInTheirName () |
| | Same for getInstallableLanguages() (lang/) instead of getLocalLanguages() (lang/customizing/). More...
|
| |
| | testGetInstallableLanguagesIgnoresAFileNameWithATrailingNewline () |
| | The regex ends in \z, not $, which in PCRE also matches before a trailing newline; file names may legally contain "\n". More...
|
| |
| | testGetLocalLanguagesReturnsEmptyArrayWhenCustomizingDirectoryIsEmpty () |
| |
| | testGetInstallableLanguagesExtractsKeysFromMainFilesAndIgnoresUnrelatedFiles () |
| |
| | testCheckLocalLanguageFileReturnsFalseWhenNoLocalFileExists () |
| |
| | testCheckLocalLanguageFileReturnsTrueForAValidLocalFile () |
| |
| | testCheckLocalLanguageFileReturnsFalseForAnInvalidLocalFile () |
| |
| | testCheckLocalLanguageFileReturnsFalseForMalformedLine () |
| |
| | testCheckLocalLanguageFileReturnsFalseWhenNoCustomizingDirectoryIsConfiguredAtAll () |
| | getCustomizingDirectories() always yields one directory in production, so the "zero directories" branch (return false) is reachable only with a mocked manager, which this class otherwise avoids. More...
|
| |
| | testCheckLanguageAcceptsAParsableShippedPo () |
| |
| | testCheckLanguageRejectsAnUnparsableShippedPo (string $po_content) |
| | Everything gettext/gettext's StrictPoLoader rejects invalidates the language, including what the old parser tolerated (a duplicate, a message without msgstr). More...
|
| |
| | testCheckLanguageAcceptsAShippedPoWithBomAndCrLf () |
| | A BOM and CRLF line endings are no reason to refuse the language. More...
|
| |
| | testCheckLanguageAcceptsAModuleWithoutShippedPoForTheLanguage () |
| |
| | testCheckLanguageDoesNotParsePoFilesOfTheLocalDirectory () |
| |
| | testCheckLanguageAcceptsAnEmptyShippedPo () |
| | An empty .po is a valid, empty catalog. More...
|
| |
| | testCheckShippedLanguageIgnoresAnInvalidCustomizingFileThatMakesCheckLanguageFail () |
| | checkShippedLanguage() is checkLanguage() without the customizing directory: an invalid "ilias_de.lang.local" must not block it. More...
|
| |
| | testCheckShippedLanguageRejectsAnInvalidGlobalLanguageFile () |
| | An invalid global "ilias_de.lang" is part of getDirectories(), so checkShippedLanguage() fails like checkLanguage(). More...
|
| |
| | testCheckShippedLanguageRejectsAnUnparsableShippedPo () |
| | An unparsable shipped .po of a PO-maintained module is part of getDirectories() too, so checkShippedLanguage() fails like checkLanguage(). More...
|
| |
Database-backed methods run against an ilDBInterface mock returning controlled rows; filesystem-backed methods use a real temporary installation root, like LanguageInstallationManagerTest.
Definition at line 34 of file InstalledLanguageDatabaseRepositoryTest.php.
◆ checkLanguageWithShippedPo()
| InstalledLanguageDatabaseRepositoryTest::checkLanguageWithShippedPo |
( |
?string |
$po_content, |
|
|
bool |
$local_directory = false |
|
) |
| |
|
private |
checkLanguage() for a migrated module: the shipped .po is the only source of its values, so an unparsable one invalidates the language.
Builds a root with a valid main lang file and a "pilot" component whose shipped de .po has $po_content (null = no .po).
Definition at line 481 of file InstalledLanguageDatabaseRepositoryTest.php.
481 : bool
482 {
484 file_put_contents($root . '/lang/ilias_de.lang', "<!-- language file start -->\ncommon#:#yes#:#Ja\n");
485 mkdir($root . '/components/pilot/lang', 0777, true);
486 if ($po_content !== null) {
487 file_put_contents($root . '/components/pilot/lang/pilot_de.po', $po_content);
488 }
490
491 try {
494 $local_directory
498 );
499 return $repository->checkLanguage('de');
500 } finally {
502 }
503 }
A root determined by the caller, for the classes which are not wired by the component bootstrap.
removeDirectory(string $dir)
createTempInstallationRoot()
static directory(string $prefix, string $path, bool $local=false)
References MigratedPoFixture\directory().
◆ configureDbToReturnObjectRows()
| InstalledLanguageDatabaseRepositoryTest::configureDbToReturnObjectRows |
( |
Stub &ilDBInterface |
$db, |
|
|
array |
$rows |
|
) |
| |
|
private |
The read methods call fetchObject() on the database object, not on the statement, so the rows are stubbed on $db.
query() is left to each test, so no two stubs compete.
- Parameters
-
| list<array<string,mixed>> | $rows each row as an associative array of column => value |
Definition at line 56 of file InstalledLanguageDatabaseRepositoryTest.php.
56 : void
57 {
58 $objects = array_map(
static fn(array $row): \stdClass => (
object) $row,
$rows);
59 $objects[] = null;
60 $db->method('fetchObject')->willReturn(...$objects);
61 }
References ILIAS\Scripts\PHPStan\$rows.
◆ createReadDatabaseMock()
| InstalledLanguageDatabaseRepositoryTest::createReadDatabaseMock |
( |
| ) |
|
|
private |
Definition at line 36 of file InstalledLanguageDatabaseRepositoryTest.php.
37 {
38 $db = $this->createStub(ilDBInterface::class);
39 $db->method('quote')->willReturnCallback(
40 static fn(mixed $value, string $type): string => "'" . (string) $value . "'"
41 );
42 $db->method('like')->willReturnCallback(
43 static fn(string $column, string $type, string $value = "?", bool $ci = true): string =>
44 $column . " LIKE " . "'" . $value . "'"
45 );
46
47 return $db;
48 }
◆ createRepository()
| InstalledLanguageDatabaseRepositoryTest::createRepository |
( |
ilDBInterface |
$db, |
|
|
string |
$absolute_path = '/does/not/matter/for/db-only/tests' |
|
) |
| |
|
private |
◆ createStatementReturningAssocRows()
| InstalledLanguageDatabaseRepositoryTest::createStatementReturningAssocRows |
( |
array |
$rows | ) |
|
|
private |
◆ createTempInstallationRoot()
| InstalledLanguageDatabaseRepositoryTest::createTempInstallationRoot |
( |
| ) |
|
|
private |
Definition at line 624 of file InstalledLanguageDatabaseRepositoryTest.php.
624 : string
625 {
626 $dir = sys_get_temp_dir() . '/ilias_lang_repo_test_' . bin2hex(random_bytes(8));
627 mkdir($dir . '/lang/customizing', 0777, true);
628 return $dir;
629 }
◆ removeDirectory()
| InstalledLanguageDatabaseRepositoryTest::removeDirectory |
( |
string |
$dir | ) |
|
|
private |
Definition at line 631 of file InstalledLanguageDatabaseRepositoryTest.php.
631 : void
632 {
633 if (!is_dir($dir)) {
634 return;
635 }
636 $items = scandir($dir);
637 foreach ($items as $item) {
638 if ($item === '.' || $item === '..') {
639 continue;
640 }
641 $path = $dir . '/' . $item;
642 if (is_dir($path) && !is_link($path)) {
644 } else {
645 unlink($path);
646 }
647 }
648 rmdir($dir);
649 }
◆ testCheckLanguageAcceptsAModuleWithoutShippedPoForTheLanguage()
| InstalledLanguageDatabaseRepositoryTest::testCheckLanguageAcceptsAModuleWithoutShippedPoForTheLanguage |
( |
| ) |
|
Definition at line 544 of file InstalledLanguageDatabaseRepositoryTest.php.
544 : void
545 {
547 }
checkLanguageWithShippedPo(?string $po_content, bool $local_directory=false)
checkLanguage() for a migrated module: the shipped .po is the only source of its values,...
◆ testCheckLanguageAcceptsAnEmptyShippedPo()
| InstalledLanguageDatabaseRepositoryTest::testCheckLanguageAcceptsAnEmptyShippedPo |
( |
| ) |
|
◆ testCheckLanguageAcceptsAParsableShippedPo()
| InstalledLanguageDatabaseRepositoryTest::testCheckLanguageAcceptsAParsableShippedPo |
( |
| ) |
|
◆ testCheckLanguageAcceptsAShippedPoWithBomAndCrLf()
| InstalledLanguageDatabaseRepositoryTest::testCheckLanguageAcceptsAShippedPoWithBomAndCrLf |
( |
| ) |
|
A BOM and CRLF line endings are no reason to refuse the language.
Definition at line 537 of file InstalledLanguageDatabaseRepositoryTest.php.
537 : void
538 {
540 "\xEF\xBB\xBFmsgid \"\"\r\nmsgstr \"\"\r\n\"Language: de\\n\"\r\n\r\nmsgctxt \"pilot\"\r\nmsgid \"greeting\"\r\nmsgstr \"Hallo\"\r\n"
541 ));
542 }
◆ testCheckLanguageDoesNotParsePoFilesOfTheLocalDirectory()
| InstalledLanguageDatabaseRepositoryTest::testCheckLanguageDoesNotParsePoFilesOfTheLocalDirectory |
( |
| ) |
|
◆ testCheckLanguageRejectsAnUnparsableShippedPo()
| InstalledLanguageDatabaseRepositoryTest::testCheckLanguageRejectsAnUnparsableShippedPo |
( |
string |
$po_content | ) |
|
Everything gettext/gettext's StrictPoLoader rejects invalidates the language, including what the old parser tolerated (a duplicate, a message without msgstr).
Definition at line 515 of file InstalledLanguageDatabaseRepositoryTest.php.
◆ testCheckLocalLanguageFileReturnsFalseForAnInvalidLocalFile()
| InstalledLanguageDatabaseRepositoryTest::testCheckLocalLanguageFileReturnsFalseForAnInvalidLocalFile |
( |
| ) |
|
Definition at line 421 of file InstalledLanguageDatabaseRepositoryTest.php.
421 : void
422 {
424 file_put_contents(
425 $root . '/lang/customizing/ilias_de.lang.local',
426 "common#:#test#:#Custom Value\n"
427 );
428
429 try {
431 $this->assertFalse($repository->checkLocalLanguageFile('de'));
432 } finally {
434 }
435 }
createRepository(ilDBInterface $db, string $absolute_path='/does/not/matter/for/db-only/tests')
◆ testCheckLocalLanguageFileReturnsFalseForMalformedLine()
| InstalledLanguageDatabaseRepositoryTest::testCheckLocalLanguageFileReturnsFalseForMalformedLine |
( |
| ) |
|
Definition at line 437 of file InstalledLanguageDatabaseRepositoryTest.php.
437 : void
438 {
440 file_put_contents(
441 $root . '/lang/customizing/ilias_de.lang.local',
442 "<!-- language file start -->\nonly_one_field\n"
443 );
444
445 try {
447 $this->assertFalse($repository->checkLocalLanguageFile('de'));
448 } finally {
450 }
451 }
◆ testCheckLocalLanguageFileReturnsFalseWhenNoCustomizingDirectoryIsConfiguredAtAll()
| InstalledLanguageDatabaseRepositoryTest::testCheckLocalLanguageFileReturnsFalseWhenNoCustomizingDirectoryIsConfiguredAtAll |
( |
| ) |
|
getCustomizingDirectories() always yields one directory in production, so the "zero directories" branch (return false) is reachable only with a mocked manager, which this class otherwise avoids.
Definition at line 457 of file InstalledLanguageDatabaseRepositoryTest.php.
457 : void
458 {
459 $manager = $this->createStub(LanguageFileDirectoryManager::class);
460 $manager->method('getCustomizingDirectories')->willReturnCallback(
461 static function (): \Generator {
462 return;
463 yield;
464 }
465 );
466
469 $manager,
471 );
472
473 $this->assertFalse($repository->checkLocalLanguageFile('de'));
474 }
◆ testCheckLocalLanguageFileReturnsFalseWhenNoLocalFileExists()
| InstalledLanguageDatabaseRepositoryTest::testCheckLocalLanguageFileReturnsFalseWhenNoLocalFileExists |
( |
| ) |
|
◆ testCheckLocalLanguageFileReturnsTrueForAValidLocalFile()
| InstalledLanguageDatabaseRepositoryTest::testCheckLocalLanguageFileReturnsTrueForAValidLocalFile |
( |
| ) |
|
Definition at line 405 of file InstalledLanguageDatabaseRepositoryTest.php.
405 : void
406 {
408 file_put_contents(
409 $root . '/lang/customizing/ilias_de.lang.local',
410 "<!-- language file start -->\ncommon#:#test#:#Custom Value\n"
411 );
412
413 try {
415 $this->assertTrue($repository->checkLocalLanguageFile('de'));
416 } finally {
418 }
419 }
◆ testCheckShippedLanguageIgnoresAnInvalidCustomizingFileThatMakesCheckLanguageFail()
| InstalledLanguageDatabaseRepositoryTest::testCheckShippedLanguageIgnoresAnInvalidCustomizingFileThatMakesCheckLanguageFail |
( |
| ) |
|
checkShippedLanguage() is checkLanguage() without the customizing directory: an invalid "ilias_de.lang.local" must not block it.
Definition at line 566 of file InstalledLanguageDatabaseRepositoryTest.php.
566 : void
567 {
569 file_put_contents($root . '/lang/ilias_de.lang', "<!-- language file start -->\ncommon#:#yes#:#Ja\n");
570 file_put_contents($root . '/lang/customizing/ilias_de.lang.local', "<!-- language file start -->\nonly_one_field\n");
571
572 try {
574
575 $this->assertTrue($repository->checkShippedLanguage('de'), 'the invalid customizing file is never consulted');
576 $this->assertFalse($repository->checkLanguage('de'), 'precondition: the same file makes checkLanguage() fail');
577 } finally {
579 }
580 }
◆ testCheckShippedLanguageRejectsAnInvalidGlobalLanguageFile()
| InstalledLanguageDatabaseRepositoryTest::testCheckShippedLanguageRejectsAnInvalidGlobalLanguageFile |
( |
| ) |
|
An invalid global "ilias_de.lang" is part of getDirectories(), so checkShippedLanguage() fails like checkLanguage().
Definition at line 585 of file InstalledLanguageDatabaseRepositoryTest.php.
585 : void
586 {
588 file_put_contents($root . '/lang/ilias_de.lang', "common#:#yes#:#Ja\n");
589
590 try {
592
593 $this->assertFalse($repository->checkShippedLanguage('de'));
594 } finally {
596 }
597 }
◆ testCheckShippedLanguageRejectsAnUnparsableShippedPo()
| InstalledLanguageDatabaseRepositoryTest::testCheckShippedLanguageRejectsAnUnparsableShippedPo |
( |
| ) |
|
An unparsable shipped .po of a PO-maintained module is part of getDirectories() too, so checkShippedLanguage() fails like checkLanguage().
Definition at line 603 of file InstalledLanguageDatabaseRepositoryTest.php.
603 : void
604 {
606 file_put_contents($root . '/lang/ilias_de.lang', "<!-- language file start -->\ncommon#:#yes#:#Ja\n");
607 mkdir($root . '/components/pilot/lang', 0777, true);
608 file_put_contents($root . '/components/pilot/lang/pilot_de.po', "msgctxt \"pilot\"\nmsgid \"abc\nmsgstr \"Hallo\"\n");
610
611 try {
616 );
617
618 $this->assertFalse($repository->checkShippedLanguage('de'));
619 } finally {
621 }
622 }
References MigratedPoFixture\directory().
◆ testGetAvailableLanguagesMapsObjIdAndStatusToTheCorrectLanguageNotSwapped()
| InstalledLanguageDatabaseRepositoryTest::testGetAvailableLanguagesMapsObjIdAndStatusToTheCorrectLanguageNotSwapped |
( |
| ) |
|
Definition at line 86 of file InstalledLanguageDatabaseRepositoryTest.php.
86 : void
87 {
89 $db->method('query')->willReturn($this->createStub(ilDBStatement::class));
91 ['title' => 'de', 'description' => 'installed', 'obj_id' => 5],
92 ['title' => 'en', 'description' => 'not_installed', 'obj_id' => 8],
93 ]);
94
96
97 $this->assertSame(
98 [
99 'de' => ['obj_id' => 5, 'status' => 'installed'],
100 'en' => ['obj_id' => 8, 'status' => 'not_installed'],
101 ],
102 $result
103 );
104 }
configureDbToReturnObjectRows(Stub &ilDBInterface $db, array $rows)
The read methods call fetchObject() on the database object, not on the statement, so the rows are stu...
◆ testGetAvailableLanguagesReturnsEmptyArrayWhenNoLanguagesAreKnown()
| InstalledLanguageDatabaseRepositoryTest::testGetAvailableLanguagesReturnsEmptyArrayWhenNoLanguagesAreKnown |
( |
| ) |
|
◆ testGetInstallableLanguagesExtractsKeysFromMainFilesAndIgnoresUnrelatedFiles()
| InstalledLanguageDatabaseRepositoryTest::testGetInstallableLanguagesExtractsKeysFromMainFilesAndIgnoresUnrelatedFiles |
( |
| ) |
|
Definition at line 371 of file InstalledLanguageDatabaseRepositoryTest.php.
371 : void
372 {
374 file_put_contents($root . '/lang/ilias_de.lang', 'irrelevant content');
375 file_put_contents($root . '/lang/ilias_en.lang', 'irrelevant content');
376
377 file_put_contents($root . '/lang/ilias_fr.lang.local', 'irrelevant content');
378 file_put_contents($root . '/lang/notes.txt', 'irrelevant content');
379
380 try {
382
383 $result = $repository->getInstallableLanguages();
384
386 $this->assertSame(['de', 'en'], $result);
387 } finally {
389 }
390 }
References ILIAS\UI\examples\Symbol\Glyph\Sort\sort().
◆ testGetInstallableLanguagesIgnoresAFileNameWithATrailingNewline()
| InstalledLanguageDatabaseRepositoryTest::testGetInstallableLanguagesIgnoresAFileNameWithATrailingNewline |
( |
| ) |
|
The regex ends in \z, not $, which in PCRE also matches before a trailing newline; file names may legally contain "\n".
Definition at line 341 of file InstalledLanguageDatabaseRepositoryTest.php.
341 : void
342 {
344 file_put_contents($root . '/lang/ilias_de.lang', 'irrelevant content');
345
346 file_put_contents($root . "/lang/ilias_zz.lang\n", 'irrelevant content');
347
348 try {
350
351 $result = $repository->getInstallableLanguages();
352
353 $this->assertSame(['de'], $result);
354 } finally {
356 }
357 }
◆ testGetInstallableLanguagesIgnoresFilesWithAnInvalidLanguageKeyShapeInTheirName()
| InstalledLanguageDatabaseRepositoryTest::testGetInstallableLanguagesIgnoresFilesWithAnInvalidLanguageKeyShapeInTheirName |
( |
| ) |
|
Same for getInstallableLanguages() (lang/) instead of getLocalLanguages() (lang/customizing/).
Definition at line 319 of file InstalledLanguageDatabaseRepositoryTest.php.
319 : void
320 {
322 file_put_contents($root . '/lang/ilias_de.lang', 'irrelevant content');
323 file_put_contents($root . '/lang/ilias_DE.lang', 'irrelevant content');
324 file_put_contents($root . '/lang/ilias_12.lang', 'irrelevant content');
325
326 try {
328
329 $result = $repository->getInstallableLanguages();
330
331 $this->assertSame(['de'], $result);
332 } finally {
334 }
335 }
◆ testGetInstalledLanguagesQueriesForInstalledPrefixAndReturnsTitles()
| InstalledLanguageDatabaseRepositoryTest::testGetInstalledLanguagesQueriesForInstalledPrefixAndReturnsTitles |
( |
| ) |
|
Definition at line 115 of file InstalledLanguageDatabaseRepositoryTest.php.
115 : void
116 {
118 $captured_query = null;
119 $db->method('query')->willReturnCallback(
120 function (
string $query) use (&$captured_query):
ilDBStatement {
121 $captured_query = $query;
122 return $this->createStub(ilDBStatement::class);
123 }
124 );
126 ['title' => 'de'],
127 ['title' => 'en'],
128 ]);
129
131
132 $this->assertSame(['de', 'en'], $result);
133 $this->assertStringContainsString("type = 'lng'", $captured_query);
134 $this->assertStringContainsString("description LIKE 'installed%'", $captured_query);
135 }
◆ testGetInstalledLocalLanguagesQueriesForExactlyInstalledLocalAndReturnsTitles()
| InstalledLanguageDatabaseRepositoryTest::testGetInstalledLocalLanguagesQueriesForExactlyInstalledLocalAndReturnsTitles |
( |
| ) |
|
Definition at line 137 of file InstalledLanguageDatabaseRepositoryTest.php.
137 : void
138 {
140 $captured_query = null;
141 $db->method('query')->willReturnCallback(
142 function (
string $query) use (&$captured_query):
ilDBStatement {
143 $captured_query = $query;
144 return $this->createStub(ilDBStatement::class);
145 }
146 );
148 ['title' => 'de'],
149 ]);
150
152
153 $this->assertSame(['de'], $result);
154 $this->assertStringContainsString("description = 'installed_local'", $captured_query);
155 }
◆ testGetLanguageEntriesQueryDoesNotFilterByLocalChange()
| InstalledLanguageDatabaseRepositoryTest::testGetLanguageEntriesQueryDoesNotFilterByLocalChange |
( |
| ) |
|
Unlike getLocalChanges(), getLanguageEntries() returns every stored entry of the language key, so its query must not filter on local_change.
Definition at line 253 of file InstalledLanguageDatabaseRepositoryTest.php.
253 : void
254 {
256 $captured_query = null;
257 $db->method('query')->willReturnCallback(
258 function (
string $query) use (&$captured_query):
ilDBStatement {
259 $captured_query = $query;
261 }
262 );
263
265
266 $this->assertStringContainsString("lang_key = 'de'", $captured_query);
267 $this->assertStringNotContainsString('local_change', $captured_query);
268 }
createStatementReturningAssocRows(array $rows)
◆ testGetLanguageEntriesReturnsEmptyArrayWhenNothingMatches()
| InstalledLanguageDatabaseRepositoryTest::testGetLanguageEntriesReturnsEmptyArrayWhenNothingMatches |
( |
| ) |
|
◆ testGetLanguageEntriesStructuresResultAsModuleThenIdentifierThenValue()
| InstalledLanguageDatabaseRepositoryTest::testGetLanguageEntriesStructuresResultAsModuleThenIdentifierThenValue |
( |
| ) |
|
Definition at line 221 of file InstalledLanguageDatabaseRepositoryTest.php.
221 : void
222 {
225 ['module' => 'common', 'identifier' => 'foo', 'value' => 'Foo Value'],
226 ['module' => 'common', 'identifier' => 'bar', 'value' => 'Bar Value'],
227 ['module' => 'other', 'identifier' => 'baz', 'value' => 'Baz Value'],
228 ]));
229
231
232 $this->assertSame(
233 [
234 'common' => ['foo' => 'Foo Value', 'bar' => 'Bar Value'],
235 'other' => ['baz' => 'Baz Value'],
236 ],
237 $result
238 );
239 }
◆ testGetLocalChangesDefaultsMinAndMaxDateWhenEmptyStringsArePassed()
| InstalledLanguageDatabaseRepositoryTest::testGetLocalChangesDefaultsMinAndMaxDateWhenEmptyStringsArePassed |
( |
| ) |
|
Definition at line 157 of file InstalledLanguageDatabaseRepositoryTest.php.
157 : void
158 {
160 $captured_query = null;
161 $db->method('query')->willReturnCallback(
162 function (
string $query) use (&$captured_query):
ilDBStatement {
163 $captured_query = $query;
165 }
166 );
167
169
170 $this->assertStringContainsString("'1980-01-01 00:00:00'", $captured_query);
171 $this->assertStringContainsString("'2200-01-01 00:00:00'", $captured_query);
172 }
◆ testGetLocalChangesKeepsExplicitlyGivenDatesInsteadOfDefaulting()
| InstalledLanguageDatabaseRepositoryTest::testGetLocalChangesKeepsExplicitlyGivenDatesInsteadOfDefaulting |
( |
| ) |
|
Definition at line 174 of file InstalledLanguageDatabaseRepositoryTest.php.
174 : void
175 {
177 $captured_query = null;
178 $db->method('query')->willReturnCallback(
179 function (
string $query) use (&$captured_query):
ilDBStatement {
180 $captured_query = $query;
182 }
183 );
184
185 $this->
createRepository($db)->getLocalChanges(
'de',
'2020-01-01 00:00:00',
'2021-01-01 00:00:00');
186
187 $this->assertStringContainsString("'2020-01-01 00:00:00'", $captured_query);
188 $this->assertStringContainsString("'2021-01-01 00:00:00'", $captured_query);
189 $this->assertStringNotContainsString('1980-01-01', $captured_query);
190 $this->assertStringNotContainsString('2200-01-01', $captured_query);
191 }
◆ testGetLocalChangesReturnsEmptyArrayWhenNothingMatches()
| InstalledLanguageDatabaseRepositoryTest::testGetLocalChangesReturnsEmptyArrayWhenNothingMatches |
( |
| ) |
|
◆ testGetLocalChangesStructuresResultAsModuleThenIdentifierThenValue()
| InstalledLanguageDatabaseRepositoryTest::testGetLocalChangesStructuresResultAsModuleThenIdentifierThenValue |
( |
| ) |
|
Definition at line 193 of file InstalledLanguageDatabaseRepositoryTest.php.
193 : void
194 {
197 ['module' => 'common', 'identifier' => 'foo', 'value' => 'Foo Value'],
198 ['module' => 'common', 'identifier' => 'bar', 'value' => 'Bar Value'],
199 ['module' => 'other', 'identifier' => 'baz', 'value' => 'Baz Value'],
200 ]));
201
203
204 $this->assertSame(
205 [
206 'common' => ['foo' => 'Foo Value', 'bar' => 'Bar Value'],
207 'other' => ['baz' => 'Baz Value'],
208 ],
209 $result
210 );
211 }
◆ testGetLocalLanguagesExtractsKeysFromLocalFilesAndIgnoresUnrelatedFiles()
| InstalledLanguageDatabaseRepositoryTest::testGetLocalLanguagesExtractsKeysFromLocalFilesAndIgnoresUnrelatedFiles |
( |
| ) |
|
Definition at line 270 of file InstalledLanguageDatabaseRepositoryTest.php.
270 : void
271 {
273 file_put_contents($root . '/lang/customizing/ilias_de.lang.local', 'irrelevant content');
274 file_put_contents($root . '/lang/customizing/ilias_en.lang.local', 'irrelevant content');
275
276 file_put_contents($root . '/lang/customizing/ilias_fr.lang', 'irrelevant content');
277 file_put_contents($root . '/lang/customizing/README.md', 'irrelevant content');
278
279 try {
281
282 $result = $repository->getLocalLanguages();
283
285 $this->assertSame(['de', 'en'], $result);
286 $this->assertSame(array_values(array_unique($result)), array_values($result));
287 } finally {
289 }
290 }
References ILIAS\UI\examples\Symbol\Glyph\Sort\sort().
◆ testGetLocalLanguagesIgnoresFilesWithAnInvalidLanguageKeyShapeInTheirName()
| InstalledLanguageDatabaseRepositoryTest::testGetLocalLanguagesIgnoresFilesWithAnInvalidLanguageKeyShapeInTheirName |
( |
| ) |
|
The discovery regex must accept exactly ParsesLanguageKeyList::LANGUAGE_KEY_FORMAT ('/^[a-z]{2}$/'): other file names must be ignored, or they would fail later in the Activity's stricter validation.
Definition at line 296 of file InstalledLanguageDatabaseRepositoryTest.php.
296 : void
297 {
299 file_put_contents($root . '/lang/customizing/ilias_de.lang.local', 'irrelevant content');
300 file_put_contents($root . '/lang/customizing/ilias_DE.lang.local', 'irrelevant content');
301 file_put_contents($root . '/lang/customizing/ilias_12.lang.local', 'irrelevant content');
302 file_put_contents($root . '/lang/customizing/ilias_Fr.lang.local', 'irrelevant content');
303 file_put_contents($root . '/lang/customizing/ilias_deu.lang.local', 'irrelevant content');
304
305 try {
307
308 $result = $repository->getLocalLanguages();
309
310 $this->assertSame(['de'], $result);
311 } finally {
313 }
314 }
◆ testGetLocalLanguagesReturnsEmptyArrayWhenCustomizingDirectoryIsEmpty()
| InstalledLanguageDatabaseRepositoryTest::testGetLocalLanguagesReturnsEmptyArrayWhenCustomizingDirectoryIsEmpty |
( |
| ) |
|
◆ unparsableShippedPo()
| static InstalledLanguageDatabaseRepositoryTest::unparsableShippedPo |
( |
| ) |
|
|
static |
Definition at line 520 of file InstalledLanguageDatabaseRepositoryTest.php.
520 : array
521 {
522 $message =
"msgctxt \"pilot\"\nmsgid \"greeting\"\nmsgstr \"Hallo\"\n";
523
524 return [
525 'unterminated string' => ["msgctxt \"pilot\"\nmsgid \"abc\nmsgstr \"Hallo\"\n"],
527 'message without msgstr' => ["msgctxt \"pilot\"\nmsgid \"greeting\"\n"],
528 'truncated inside a string' => [substr(
$message, 0, -4)],
529 'binary data' => ["\xde\x12\x04\x95\x00\x00\x00\x00"],
530 'header value with a line break' => [
"msgid \"\"\nmsgstr \"\"\n\"X-A: a\\rb\\n\"\n\n" .
$message],
531 ];
532 }
References $message.
The documentation for this class was generated from the following file: