ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilSetupLanguageTest Class Reference

Class ilSetupLanguageTest. More...

+ Inheritance diagram for ilSetupLanguageTest:
+ Collaboration diagram for ilSetupLanguageTest:

Public Member Functions

 testRetrieveLanguageKey ()
 
 testRetrieveInstalledLanguage ()
 
 testDatabaseSourcePrecedence (bool $handler, bool $constructor, bool $global, string $winner)
 
 testFileBasedMethodsWorkWithoutAnyDatabase ()
 
 testInstallableLanguagesAreTheKeysWithAMainLanguageFile ()
 
 testDatabaseMethodsWithoutDatabaseThrowLogicException (Closure $call)
 
 testCheckLanguageWithOnlyMainFile ()
 
 testCheckLanguageWithBothMainAndComponentFiles ()
 
 testCheckLanguageWithMissingMainFile ()
 
 testCheckLanguageFailsOnInvalidComponentLanguageFile ()
 
 testCheckLanguageFailsOnNonUtf8Value ()
 
 testGetInvalidLocalLanguageFilesReturnsEmptyForValidFile ()
 
 testGetInvalidLocalLanguageFilesIgnoresMissingFile ()
 
 testGetInvalidLocalLanguageFilesReturnsMalformedFileName ()
 
 testRegisterInstalledLanguageInsertsUnknownLanguage ()
 
 testRegisterInstalledLanguageInsertsAsInstalledLocalWhenLocalFileIsPresent ()
 
 testRegisterInstalledLanguageUpdatesKnownLanguage ()
 
 testWithoutInjectedDirectoriesOnlyTheDefaultDirectoriesAreUsed ()
 
 testAnInjectedDirectoryManagerIsUsedAndReported ()
 The flag says who built the instance (component graph vs. More...
 
 testOverlaysOfUnshippedModulesAreOnlyReportedWithContributedDirectories ()
 
 testNothingIsReportedBeforeAManagerExists ()
 
 testSetClientDataDirOverridesTheResolutionUntilResetWithNull ()
 setClientDataDir() overrides the resolution lazily, also after construction; null restores resolveClientDataDir(). More...
 
 testTheTranslationCacheIsANoOpWithoutGlobalCache ()
 CLI Setup has no global cache: the translation cache must be a silent no-op. More...
 
 testGetClientDataDirReturnsTheSetDirectoryOrTheDefaultResolution ()
 
 testFindUnwritableOverlayDirectoriesChecksTheSetClientDataDir ()
 

Static Public Member Functions

static databaseSources ()
 
static databaseMethods ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 
- Protected Member Functions inherited from ilLanguageBaseTestCase
 setUp ()
 
 setGlobalVariable (string $name, $value)
 
 rbacOf (\ilRbacSystem $system)
 
 languageFolder (int $ref_id=0)
 

Private Member Functions

 cleanupTempDir ()
 
 createMockComponentDirectory (string $path='artifacts/test_lang_component', string $prefix='test')
 
 createMockCustomizingDirectory ()
 
 emptyDatabase (bool $expect_query)
 
 callCheckLanguage (ilSetupLanguage $setup_language, string $lang_key)
 
 createDatabaseMock ()
 
 withManagerReporting (ilSetupLanguage $setup_language)
 
 managerOf (ilSetupLanguage $setup_language)
 
 resolvedClientDataDir (ilSetupLanguage $setup_language)
 

Private Attributes

ilSetupLanguage $newLangSetupDe
 
ilSetupLanguage $newLangSetupEs
 
array $langInstalled
 
string $tempComponentDir = 'artifacts/test_lang_component'
 

Detailed Description

Class ilSetupLanguageTest.

Definition at line 31 of file ilSetupLanguageTest.php.

Member Function Documentation

◆ callCheckLanguage()

ilSetupLanguageTest::callCheckLanguage ( ilSetupLanguage  $setup_language,
string  $lang_key 
)
private

Definition at line 233 of file ilSetupLanguageTest.php.

233 : bool
234 {
235 $reflection = new ReflectionMethod($setup_language, 'checkLanguage');
236 return $reflection->invoke($setup_language, $lang_key);
237 }

◆ cleanupTempDir()

ilSetupLanguageTest::cleanupTempDir ( )
private

Definition at line 56 of file ilSetupLanguageTest.php.

56 : void
57 {
58 $fullPath = __DIR__ . '/../../../../' . $this->tempComponentDir;
59 if (is_dir($fullPath)) {
60 $files = glob($fullPath . '/*');
61 if ($files !== false) {
62 foreach ($files as $file) {
63 if (is_file($file)) {
64 unlink($file);
65 }
66 }
67 }
68 rmdir($fullPath);
69 }
70 }

References $files, and $tempComponentDir.

Referenced by tearDown().

+ Here is the caller graph for this function:

◆ createDatabaseMock()

ilSetupLanguageTest::createDatabaseMock ( )
private

Definition at line 397 of file ilSetupLanguageTest.php.

397 : ilDBInterface&MockObject
398 {
399 $db = $this->createMock(ilDBInterface::class);
400 $db->method('nextId')->willReturn(42);
401 $db->method('quote')->willReturnCallback(
402 static fn(mixed $value): string => "'" . (string) $value . "'"
403 );
404 $db->method('now')->willReturn('NOW()');
405 $db->method('manipulate')->willReturn(1);
406
407 return $db;
408 }
Interface ilDBInterface.

◆ createMockComponentDirectory()

ilSetupLanguageTest::createMockComponentDirectory ( string  $path = 'artifacts/test_lang_component',
string  $prefix = 'test' 
)
private

Definition at line 72 of file ilSetupLanguageTest.php.

76 return new class ($path, $prefix) implements LanguageFileDirectory {
77 public function __construct(private string $path, private string $prefix)
78 {
79 }
80
81 public function getPrefix(): string
82 {
83 return $this->prefix;
84 }
85
86 public function getPath(): string
87 {
88 return $this->path;
89 }
90
91 public function getSuffix(): string
92 {
93 return '';
94 }
95
96 public function isLocal(): bool
97 {
98 return false;
99 }
100 };
101 }
A directory of language files with a path and a prefix for them.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

◆ createMockCustomizingDirectory()

ilSetupLanguageTest::createMockCustomizingDirectory ( )
private

Definition at line 103 of file ilSetupLanguageTest.php.

104 {
105 return new class ($this->tempComponentDir) implements LanguageFileDirectory {
106 public function __construct(private string $path)
107 {
108 }
109
110 public function getPrefix(): string
111 {
112 return '';
113 }
114
115 public function getPath(): string
116 {
117 return $this->path;
118 }
119
120 public function getSuffix(): string
121 {
122 return '.local';
123 }
124
125 public function isLocal(): bool
126 {
127 return true;
128 }
129 };
130 }

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

◆ databaseMethods()

static ilSetupLanguageTest::databaseMethods ( )
static
Returns
array<string, array{0: Closure(ilSetupLanguage): mixed}>

Definition at line 217 of file ilSetupLanguageTest.php.

217 : array
218 {
219 return [
220 'repository' => [static fn(ilSetupLanguage $l): array => $l->getInstalledLanguages()],
221 'manager' => [static fn(ilSetupLanguage $l) => $l->insertLanguageForInstallation('en')],
222 ];
223 }
language handling for setup

References ilSetupLanguage\getInstalledLanguages(), and ilSetupLanguage\insertLanguageForInstallation().

+ Here is the call graph for this function:

◆ databaseSources()

static ilSetupLanguageTest::databaseSources ( )
static
Returns
array<string, array{0: bool, 1: bool, 2: bool, 3: string}> handler, constructor, global, winner

Definition at line 164 of file ilSetupLanguageTest.php.

164 : array
165 {
166 return [
167 'handler beats constructor and global' => [true, true, true, 'handler'],
168 'handler beats constructor' => [true, true, false, 'handler'],
169 'handler beats global' => [true, false, true, 'handler'],
170 'constructor beats global' => [false, true, true, 'constructor'],
171 'only constructor' => [false, true, false, 'constructor'],
172 'only global' => [false, false, true, 'global'],
173 ];
174 }

◆ emptyDatabase()

ilSetupLanguageTest::emptyDatabase ( bool  $expect_query)
private

Definition at line 149 of file ilSetupLanguageTest.php.

149 : ilDBInterface&\PHPUnit\Framework\MockObject\MockObject
150 {
151 $db = $this->createMock(ilDBInterface::class);
152 $db->method('quote')->willReturn("'x'");
153 $db->method('like')->willReturn('1=1');
154 $db->method('fetchObject')->willReturn(null);
155 $db->expects($expect_query ? self::once() : self::never())->method('query')
156 ->willReturn($this->createStub(ilDBStatement::class));
157
158 return $db;
159 }

◆ managerOf()

ilSetupLanguageTest::managerOf ( ilSetupLanguage  $setup_language)
private

Definition at line 510 of file ilSetupLanguageTest.php.

511 {
512 $setup_language->setDbHandler($this->createStub(ilDBInterface::class));
513
514 return (new ReflectionMethod(ilSetupLanguage::class, 'manager'))->invoke($setup_language);
515 }
Write access to the language installation: installing, flushing and registering languages in the data...
setDbHandler(ilDBInterface $a_db_handler)
Takes precedence over $GLOBALS['ilDB'].

References ilSetupLanguage\setDbHandler().

+ Here is the call graph for this function:

◆ resolvedClientDataDir()

ilSetupLanguageTest::resolvedClientDataDir ( ilSetupLanguage  $setup_language)
private

Definition at line 517 of file ilSetupLanguageTest.php.

517 : ?string
518 {
519 $manager = $this->managerOf($setup_language);
520 $resolver = (new ReflectionProperty(\ILIAS\Language\Setup\LanguageInstallationManager::class, 'client_data_dir_resolver'))
521 ->getValue($manager);
522
523 return $resolver();
524 }
foreach($components as $component) $resolver
managerOf(ilSetupLanguage $setup_language)
getValue()
Get the value that is displayed in the input client side.
Definition: Group.php:49
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

References $resolver, and ILIAS\UI\Implementation\Component\Input\getValue().

+ Here is the call graph for this function:

◆ setUp()

ilSetupLanguageTest::setUp ( )
protected

Reimplemented from ilLanguageBaseTestCase.

Definition at line 38 of file ilSetupLanguageTest.php.

38 : void
39 {
40 unset($GLOBALS['ilDB']);
41 // per process: two PHPUnit runs at once must not share (and delete) the same directory
42 $this->tempComponentDir .= '_' . getmypid();
43 $this->newLangSetupDe = new ilSetupLanguage('de');
44 $this->newLangSetupEs = new ilSetupLanguage('es');
45
46 $this->langInstalled[] = $this->newLangSetupDe;
47 $this->langInstalled[] = $this->newLangSetupEs;
48 }
ilSetupLanguage $newLangSetupEs
ilSetupLanguage $newLangSetupDe
$GLOBALS["DIC"]
Definition: wac.php:66

References $GLOBALS, $newLangSetupDe, and $newLangSetupEs.

◆ tearDown()

ilSetupLanguageTest::tearDown ( )
protected

Definition at line 50 of file ilSetupLanguageTest.php.

50 : void
51 {
52 $this->cleanupTempDir();
54 }

References cleanupTempDir(), and tearDown().

+ Here is the call graph for this function:

◆ testAnInjectedDirectoryManagerIsUsedAndReported()

ilSetupLanguageTest::testAnInjectedDirectoryManagerIsUsedAndReported ( )

The flag says who built the instance (component graph vs.

plugin Setup objective), so even a manager with only the default directories counts as injected.

Definition at line 472 of file ilSetupLanguageTest.php.

472 : void
473 {
475 $setup_language = new ilSetupLanguage('de', $manager);
476
477 $this->assertFalse($setup_language->usesDefaultLanguageFileDirectories());
478 $this->assertSame($manager, $setup_language->getLanguageFileDirectoryManager());
479 }

◆ testCheckLanguageFailsOnInvalidComponentLanguageFile()

ilSetupLanguageTest::testCheckLanguageFailsOnInvalidComponentLanguageFile ( )

Definition at line 293 of file ilSetupLanguageTest.php.

293 : void
294 {
295 $fullPath = __DIR__ . '/../../../../' . $this->tempComponentDir;
296 if (!is_dir($fullPath)) {
297 mkdir($fullPath, 0777, true);
298 }
299
300 try {
301 file_put_contents($fullPath . '/ilias_en.lang', "invalid content without header\n");
302
303 $mockDir = $this->createMockComponentDirectory($this->tempComponentDir, 'test');
304 $manager = new LanguageFileDirectoryManager(
306 $mockDir
307 );
308 $setup_language = new ilSetupLanguage('en', $manager);
309
310 $this->assertFalse($this->callCheckLanguage($setup_language, 'en'));
311
312 file_put_contents(
313 $fullPath . '/ilias_en.lang',
314 "<!-- language file start -->\nonly_one_part\n"
315 );
316 $this->assertFalse($this->callCheckLanguage($setup_language, 'en'));
317 } finally {
318 $this->cleanupTempDir();
319 }
320 }
callCheckLanguage(ilSetupLanguage $setup_language, string $lang_key)
createMockComponentDirectory(string $path='artifacts/test_lang_component', string $prefix='test')

◆ testCheckLanguageFailsOnNonUtf8Value()

ilSetupLanguageTest::testCheckLanguageFailsOnNonUtf8Value ( )

Definition at line 322 of file ilSetupLanguageTest.php.

322 : void
323 {
324 $fullPath = __DIR__ . '/../../../../' . $this->tempComponentDir;
325 if (!is_dir($fullPath)) {
326 mkdir($fullPath, 0777, true);
327 }
328
329 try {
330 file_put_contents(
331 $fullPath . '/ilias_en.lang',
332 "<!-- language file start -->\n" .
333 "test_key#:#" . chr(0xFF) . chr(0xFE) . "\n"
334 );
335
336 $mockDir = $this->createMockComponentDirectory($this->tempComponentDir, 'test');
337 $manager = new LanguageFileDirectoryManager(
340 $mockDir
341 );
342 $setup_language = new ilSetupLanguage('en', $manager);
343
344 $this->assertFalse($this->callCheckLanguage($setup_language, 'en'));
345 } finally {
346 $this->cleanupTempDir();
347 }
348 }

◆ testCheckLanguageWithBothMainAndComponentFiles()

ilSetupLanguageTest::testCheckLanguageWithBothMainAndComponentFiles ( )

Definition at line 253 of file ilSetupLanguageTest.php.

253 : void
254 {
255 $fullPath = __DIR__ . '/../../../../' . $this->tempComponentDir;
256 if (!is_dir($fullPath)) {
257 mkdir($fullPath, 0777, true);
258 }
259
260 try {
261 file_put_contents(
262 $fullPath . '/ilias_en.lang',
263 "<!-- language file start -->\ntest_key#:#test_value\n"
264 );
265
266 $mockDir = $this->createMockComponentDirectory($this->tempComponentDir, 'test');
267 $manager = new LanguageFileDirectoryManager(
270 $mockDir
271 );
272 $setup_language = new ilSetupLanguage('en', $manager);
273
274 $this->assertTrue($this->callCheckLanguage($setup_language, 'en'));
275 } finally {
276 $this->cleanupTempDir();
277 }
278 }

◆ testCheckLanguageWithMissingMainFile()

ilSetupLanguageTest::testCheckLanguageWithMissingMainFile ( )

Definition at line 280 of file ilSetupLanguageTest.php.

280 : void
281 {
282 $mockDir = $this->createMockComponentDirectory();
283 $manager = new LanguageFileDirectoryManager(
286 $mockDir
287 );
288 $setup_language = new ilSetupLanguage('xx', $manager);
289
290 $this->assertFalse($this->callCheckLanguage($setup_language, 'xx'));
291 }

◆ testCheckLanguageWithOnlyMainFile()

ilSetupLanguageTest::testCheckLanguageWithOnlyMainFile ( )

Definition at line 239 of file ilSetupLanguageTest.php.

239 : void
240 {
241 $mockDir = $this->createMockComponentDirectory();
242 $manager = new LanguageFileDirectoryManager(
245 $mockDir
246 );
247 $setup_language = new ilSetupLanguage('en', $manager);
248
249 $this->assertTrue($this->callCheckLanguage($setup_language, 'en'));
250 $this->assertTrue($this->callCheckLanguage($setup_language, 'de'));
251 }

◆ testDatabaseMethodsWithoutDatabaseThrowLogicException()

ilSetupLanguageTest::testDatabaseMethodsWithoutDatabaseThrowLogicException ( Closure  $call)

Definition at line 226 of file ilSetupLanguageTest.php.

226 : void
227 {
228 $this->expectException(LogicException::class);
229
230 $call(new ilSetupLanguage('en'));
231 }

◆ testDatabaseSourcePrecedence()

ilSetupLanguageTest::testDatabaseSourcePrecedence ( bool  $handler,
bool  $constructor,
bool  $global,
string  $winner 
)

Definition at line 177 of file ilSetupLanguageTest.php.

177 : void
178 {
179 $dbs = [];
180 foreach (['handler' => $handler, 'constructor' => $constructor, 'global' => $global] as $name => $present) {
181 if ($present) {
182 $dbs[$name] = $this->emptyDatabase($name === $winner);
183 }
184 }
185 if (isset($dbs['global'])) {
186 $GLOBALS['ilDB'] = $dbs['global'];
187 }
188
189 $setup_language = new ilSetupLanguage('en', null, $dbs['constructor'] ?? null);
190 if (isset($dbs['handler'])) {
191 $setup_language->setDbHandler($dbs['handler']);
192 }
193
194 self::assertSame([], $setup_language->getInstalledLanguages());
195 }
emptyDatabase(bool $expect_query)
$handler
Definition: oai.php:31

References $GLOBALS, and $handler.

◆ testFileBasedMethodsWorkWithoutAnyDatabase()

ilSetupLanguageTest::testFileBasedMethodsWorkWithoutAnyDatabase ( )

Definition at line 197 of file ilSetupLanguageTest.php.

197 : void
198 {
199 $setup_language = new ilSetupLanguage('en');
200
201 self::assertContainsOnlyString($setup_language->getLocalLanguages());
202 self::assertTrue($setup_language->checkLanguageForInstallation('en'));
203 }

◆ testFindUnwritableOverlayDirectoriesChecksTheSetClientDataDir()

ilSetupLanguageTest::testFindUnwritableOverlayDirectoriesChecksTheSetClientDataDir ( )

Definition at line 565 of file ilSetupLanguageTest.php.

565 : void
566 {
567 $fixture = 'tmp-setup-unwritable-' . bin2hex(random_bytes(4));
568 $client_data_dir = sys_get_temp_dir() . '/ilias_setup_unwritable_' . bin2hex(random_bytes(4));
569 MigratedPoFixture::writePo(__DIR__ . '/' . $fixture . '/stest_de.po', MigratedPoFixture::catalog('stest', ['a' => 'b']));
570 mkdir($client_data_dir);
571 file_put_contents($client_data_dir . '/lang', 'not a directory');
572
573 try {
574 $setup_language = new ilSetupLanguage('de', new \ILIAS\Language\ComponentTranslation\LanguageFileDirectoryManager(
575 new \ILIAS\Language\ComponentTranslation\CustomizingLanguageFileDirectory(),
576 MigratedPoFixture::directory('stest', 'components/ILIAS/Language/tests/' . $fixture . '/')
577 ));
578 $setup_language->setClientDataDir($client_data_dir);
579
580 $this->assertSame(
581 [$client_data_dir . '/lang/stest/de'],
582 $setup_language->findUnwritableOverlayDirectories(['de'])
583 );
584 $this->assertSame([], $setup_language->findUnwritableOverlayDirectories(['en']));
585 } finally {
586 MigratedPoFixture::removeDirectory(__DIR__ . '/' . $fixture);
587 MigratedPoFixture::removeDirectory($client_data_dir);
588 }
589 }
static directory(string $prefix, string $path, bool $local=false)
static catalog(string $module, array $entries)
static writePo(string $file, TranslationCatalog $catalog)
static removeDirectory(string $directory)

References MigratedPoFixture\catalog(), MigratedPoFixture\directory(), MigratedPoFixture\removeDirectory(), and MigratedPoFixture\writePo().

+ Here is the call graph for this function:

◆ testGetClientDataDirReturnsTheSetDirectoryOrTheDefaultResolution()

ilSetupLanguageTest::testGetClientDataDirReturnsTheSetDirectoryOrTheDefaultResolution ( )

Definition at line 553 of file ilSetupLanguageTest.php.

553 : void
554 {
555 $setup_language = new ilSetupLanguage('de');
557 (string) realpath(__DIR__ . '/../../../../')
558 );
559
560 $this->assertSame($default, $setup_language->getClientDataDir());
561 $setup_language->setClientDataDir('/from/the/setup/environment');
562 $this->assertSame('/from/the/setup/environment', $setup_language->getClientDataDir());
563 }
static resolveClientDataDir(?string $ilias_absolute_path=null)
The client data directory (CLIENT_DATA_DIR) of this installation, null if it cannot be determined or ...

References ILIAS\Language\ComponentTranslation\MigratedLanguageFilePaths\resolveClientDataDir().

+ Here is the call graph for this function:

◆ testGetInvalidLocalLanguageFilesIgnoresMissingFile()

ilSetupLanguageTest::testGetInvalidLocalLanguageFilesIgnoresMissingFile ( )

Definition at line 365 of file ilSetupLanguageTest.php.

365 : void
366 {
367 $fullPath = __DIR__ . '/../../../../' . $this->tempComponentDir;
368 mkdir($fullPath, 0777, true);
369
370 $manager = new LanguageFileDirectoryManager(
373 );
374 $setup_language = new ilSetupLanguage('en', $manager);
375
376 $this->assertSame([], $setup_language->getInvalidLocalLanguageFiles(['en']));
377 }

◆ testGetInvalidLocalLanguageFilesReturnsEmptyForValidFile()

ilSetupLanguageTest::testGetInvalidLocalLanguageFilesReturnsEmptyForValidFile ( )

Definition at line 350 of file ilSetupLanguageTest.php.

350 : void
351 {
352 $fullPath = __DIR__ . '/../../../../' . $this->tempComponentDir;
353 mkdir($fullPath, 0777, true);
354 file_put_contents($fullPath . '/ilias_en.lang.local', 'custom');
355
356 $manager = new LanguageFileDirectoryManager(
359 );
360 $setup_language = new ilSetupLanguage('en', $manager);
361
362 $this->assertSame([], $setup_language->getInvalidLocalLanguageFiles(['en']));
363 }

◆ testGetInvalidLocalLanguageFilesReturnsMalformedFileName()

ilSetupLanguageTest::testGetInvalidLocalLanguageFilesReturnsMalformedFileName ( )

Definition at line 379 of file ilSetupLanguageTest.php.

379 : void
380 {
381 $fullPath = __DIR__ . '/../../../../' . $this->tempComponentDir;
382 mkdir($fullPath, 0777, true);
383 file_put_contents($fullPath . '/ilias_en.lang.locl', 'custom');
384
385 $manager = new LanguageFileDirectoryManager(
388 );
389 $setup_language = new ilSetupLanguage('en', $manager);
390
391 $this->assertSame(
392 ['ilias_en.lang.locl'],
393 $setup_language->getInvalidLocalLanguageFiles(['en'])
394 );
395 }

◆ testInstallableLanguagesAreTheKeysWithAMainLanguageFile()

ilSetupLanguageTest::testInstallableLanguagesAreTheKeysWithAMainLanguageFile ( )

Definition at line 205 of file ilSetupLanguageTest.php.

205 : void
206 {
207 $installable = (new ilSetupLanguage('en'))->getInstallableLanguagesForInstallation();
208
209 $this->assertContains('en', $installable);
210 $this->assertContains('de', $installable);
211 $this->assertNotContains('qq', $installable);
212 }

◆ testNothingIsReportedBeforeAManagerExists()

ilSetupLanguageTest::testNothingIsReportedBeforeAManagerExists ( )

Definition at line 502 of file ilSetupLanguageTest.php.

502 : void
503 {
505
506 $this->assertSame([], $setup_language->getOverlaysOfUnshippedModules());
507 $this->assertSame([], $setup_language->getUnrecordedTakenOverModules());
508 }

◆ testOverlaysOfUnshippedModulesAreOnlyReportedWithContributedDirectories()

ilSetupLanguageTest::testOverlaysOfUnshippedModulesAreOnlyReportedWithContributedDirectories ( )

Definition at line 489 of file ilSetupLanguageTest.php.

489 : void
490 {
491 $default = new ilSetupLanguage('de');
492 $this->withManagerReporting($default);
494 $this->withManagerReporting($injected);
495
496 $this->assertSame([], $default->getOverlaysOfUnshippedModules());
497 $this->assertSame(['de' => ['ghost']], $injected->getOverlaysOfUnshippedModules());
498 $this->assertSame(['de' => ['pilot']], $default->getUnrecordedTakenOverModules());
499 $this->assertSame(['de' => ['pilot']], $injected->getUnrecordedTakenOverModules());
500 }
withManagerReporting(ilSetupLanguage $setup_language)

◆ testRegisterInstalledLanguageInsertsAsInstalledLocalWhenLocalFileIsPresent()

ilSetupLanguageTest::testRegisterInstalledLanguageInsertsAsInstalledLocalWhenLocalFileIsPresent ( )

Definition at line 426 of file ilSetupLanguageTest.php.

426 : void
427 {
428 $db = $this->createDatabaseMock();
429 $db->expects($this->once())
430 ->method('manipulate')
431 ->with($this->stringContains("'installed_local'"));
432
433 $this->newLangSetupDe->setDbHandler($db);
434 $this->newLangSetupDe->registerInstalledLanguage('de', [], ['de']);
435 }

◆ testRegisterInstalledLanguageInsertsUnknownLanguage()

ilSetupLanguageTest::testRegisterInstalledLanguageInsertsUnknownLanguage ( )

@lang text

Definition at line 410 of file ilSetupLanguageTest.php.

410 : void
411 {
412 $db = $this->createDatabaseMock();
413 $db->expects($this->once())
414 ->method('manipulate')
415 ->with($this->logicalAnd(
416 $this->stringContains( 'INSERT INTO object_data'),
417 $this->stringContains("'de'"),
418 $this->stringContains("'installed'")
419 ))
420 ->willReturn(1);
421
422 $this->newLangSetupDe->setDbHandler($db);
423 $this->newLangSetupDe->registerInstalledLanguage('de', [], []);
424 }

◆ testRegisterInstalledLanguageUpdatesKnownLanguage()

ilSetupLanguageTest::testRegisterInstalledLanguageUpdatesKnownLanguage ( )

Definition at line 437 of file ilSetupLanguageTest.php.

437 : void
438 {
439 $db = $this->createDatabaseMock();
440 $db->expects($this->once())
441 ->method('manipulate')
442 ->with($this->logicalAnd(
443 $this->stringContains('UPDATE object_data'),
444 $this->stringContains("'installed'"),
445 $this->stringContains('obj_id = ' . "'7'")
446 ))
447 ->willReturn(1);
448
449 $this->newLangSetupDe->setDbHandler($db);
450 $this->newLangSetupDe->registerInstalledLanguage(
451 'de',
452 ['de' => ['obj_id' => 7, 'status' => 'not_installed']],
453 []
454 );
455 }

◆ testRetrieveInstalledLanguage()

ilSetupLanguageTest::testRetrieveInstalledLanguage ( )

Definition at line 138 of file ilSetupLanguageTest.php.

138 : void
139 {
140 $languagesAsKeys = [];
141 foreach ($this->langInstalled as $languageAsKey) {
142 $languagesAsKeys[] = $languageAsKey->getLangKey();
143 }
144
145 $this->assertContains('de', $languagesAsKeys);
146 $this->assertContains('es', $languagesAsKeys);
147 }

◆ testRetrieveLanguageKey()

ilSetupLanguageTest::testRetrieveLanguageKey ( )

Definition at line 132 of file ilSetupLanguageTest.php.

132 : void
133 {
134 $this->assertEquals('de', $this->newLangSetupDe->getLangKey());
135 $this->assertEquals('es', $this->newLangSetupEs->getLangKey());
136 }

◆ testSetClientDataDirOverridesTheResolutionUntilResetWithNull()

ilSetupLanguageTest::testSetClientDataDirOverridesTheResolutionUntilResetWithNull ( )

setClientDataDir() overrides the resolution lazily, also after construction; null restores resolveClientDataDir().

Definition at line 527 of file ilSetupLanguageTest.php.

527 : void
528 {
529 $setup_language = new ilSetupLanguage('de');
531 (string) realpath(__DIR__ . '/../../../../')
532 );
533
534 $setup_language->setClientDataDir('/from/the/setup/environment');
535 $this->assertSame('/from/the/setup/environment', $this->resolvedClientDataDir($setup_language));
536
537 $setup_language->setClientDataDir(null);
538 $this->assertSame($default, $this->resolvedClientDataDir($setup_language));
539 }
resolvedClientDataDir(ilSetupLanguage $setup_language)

References ILIAS\Language\ComponentTranslation\MigratedLanguageFilePaths\resolveClientDataDir().

+ Here is the call graph for this function:

◆ testTheTranslationCacheIsANoOpWithoutGlobalCache()

ilSetupLanguageTest::testTheTranslationCacheIsANoOpWithoutGlobalCache ( )

CLI Setup has no global cache: the translation cache must be a silent no-op.

Definition at line 542 of file ilSetupLanguageTest.php.

542 : void
543 {
544 $setup_language = new ilSetupLanguage('de');
545 $manager = $this->managerOf($setup_language);
546 $translation_cache = (new ReflectionProperty(\ILIAS\Language\Setup\LanguageInstallationManager::class, 'translation_cache'))
547 ->getValue($manager);
548
549 $this->assertInstanceOf(\ILIAS\Language\Setup\NullTranslationCache::class, $translation_cache);
550 $translation_cache->invalidate('de');
551 }

References ILIAS\UI\Implementation\Component\Input\getValue().

+ Here is the call graph for this function:

◆ testWithoutInjectedDirectoriesOnlyTheDefaultDirectoriesAreUsed()

ilSetupLanguageTest::testWithoutInjectedDirectoriesOnlyTheDefaultDirectoriesAreUsed ( )

Definition at line 457 of file ilSetupLanguageTest.php.

457 : void
458 {
459 $setup_language = new ilSetupLanguage('de');
460
461 $this->assertTrue($setup_language->usesDefaultLanguageFileDirectories());
462 $this->assertSame(
463 [MainLanguageFileDirectory::class, CustomizingLanguageFileDirectory::class],
464 array_map(
465 static fn(LanguageFileDirectory $d): string => $d::class,
466 iterator_to_array($setup_language->getLanguageFileDirectoryManager()->getAllDirectories(), false)
467 )
468 );
469 }

References Vendor\Package\$d.

◆ withManagerReporting()

ilSetupLanguageTest::withManagerReporting ( ilSetupLanguage  $setup_language)
private

Definition at line 481 of file ilSetupLanguageTest.php.

481 : void
482 {
483 $manager = $this->createStub(\ILIAS\Language\Setup\LanguageInstallationManager::class);
484 $manager->method('getOverlaysOfUnshippedModules')->willReturn(['de' => ['ghost']]);
485 $manager->method('getUnrecordedTakenOverModules')->willReturn(['de' => ['pilot']]);
486 (new ReflectionProperty(ilSetupLanguage::class, 'manager'))->setValue($setup_language, $manager);
487 }

Field Documentation

◆ $langInstalled

array ilSetupLanguageTest::$langInstalled
private

Definition at line 35 of file ilSetupLanguageTest.php.

◆ $newLangSetupDe

ilSetupLanguage ilSetupLanguageTest::$newLangSetupDe
private

Definition at line 33 of file ilSetupLanguageTest.php.

Referenced by setUp().

◆ $newLangSetupEs

ilSetupLanguage ilSetupLanguageTest::$newLangSetupEs
private

Definition at line 34 of file ilSetupLanguageTest.php.

Referenced by setUp().

◆ $tempComponentDir

string ilSetupLanguageTest::$tempComponentDir = 'artifacts/test_lang_component'
private

Definition at line 36 of file ilSetupLanguageTest.php.

Referenced by cleanupTempDir().


The documentation for this class was generated from the following file: