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

A line of the customizing file whose identifier exists in another module or in another spelling is left out, named by getSkippedDuplicateEntries() and, for a PO module, not recorded as taken over (language.md rule 2). More...

+ Inheritance diagram for LanguageInstallationManagerDuplicateIdentifiersTest:
+ Collaboration diagram for LanguageInstallationManagerDuplicateIdentifiersTest:

Public Member Functions

 testACustomizingEntryWhoseIdentifierExistsInAnotherModuleIsSkippedButTheRestIsInstalled ()
 
 testTheSkippedDuplicatesAreResetOnEveryInsertLanguageCall ()
 
 testAnOldCollisionOfTheOwnModuleIsApplied ()
 An old collision stays editable: the own module holds the identifier in this very spelling. More...
 
 testEntriesOfTheSameRunCountAsExisting (array $shipped_lang_lines, ?array $shipped_po, string $expected_duplicate)
 lng_data is emptied before an installation, so what this run writes besides counts as existing: the lines of the shipped file and the shipped .po of a PO module. More...
 
 testAModuleWithADuplicateCustomizingEntryIsNotRecordedUntilItIsFixed ()
 

Static Public Member Functions

static entriesOfTheSameRun ()
 

Private Member Functions

 takenOver ()
 

Additional Inherited Members

- Protected Member Functions inherited from LanguageInstallationManagerMigratedModulesTestCase
 setUp ()
 
 tearDown ()
 
 db ()
 
 repository ()
 
 manager (?\Closure $client_data_dir_resolver=null, ?\Closure $language_cache_invalidator=null, bool $with_resolver=true, bool $with_logger=true, ?LoggerInterface $logger=null)
 
 expectManagerWarning ()
 
 assertPostConditions ()
 
 loggedWarnings ()
 
 shipPo (array $entries, string $lang_key='de')
 
 shipSecondModule (array $entries)
 A second migrated module "pilot2" next to "pilot". More...
 
 seedOverlay (array $entries)
 
 overlayBase ()
 
 overlayPo ()
 
 effective ()
 Shipped .po plus overlay delta, as served (MigratedLanguageFileSync::loadModuleTranslations()) - the overlay itself only holds the entries that differ from the shipped .po. More...
 
 writeLang (string $relative_file, array $lines)
 
 resolveToken (string $token)
 
 lngData ()
 
 applyLngDataDelete (string $query, array $rows)
 Applies one recorded "DELETE FROM lng_data" to $rows, in the two shapes LanguageInstallationManager issues: the bulk delete of unchanged rows of a migrated module ("... local_change IS NULL AND module IN (...)") and the per-module delete of dropped identifiers ("... AND module = ? AND identifier IN (...)"). More...
 
 droppedIdentifiers (string $module)
 Identifiers of $module dropped via the per-module "DELETE FROM lng_data ... AND identifier IN (...)", as opposed to keys merely absent because they were never touched. More...
 
 lngModules ()
 
 errorLog ()
 What error_log() wrote during this test so far - PHPUnit redirects error_log to a capture file per test (call expectErrorLog() in tests that expect logging, so it is not echoed). More...
 
 shipPluralPo (array $entries, string $header)
 
 writeLocalOverlay (array $flat_values)
 
 seedOverlayMarkedAsMerged (array $entries, array $merged)
 
- Protected Attributes inherited from LanguageInstallationManagerMigratedModulesTestCase
const string NOW = '2026-01-02 03:04:05'
 
const string MODULE = 'pilot'
 
string $root
 
LanguageFileDirectory $directory
 
array $further_directories = []
 
array $quoted = []
 
array $queries = []
 
array $collation_rows = null
 
array $pending_rows = []
 
array $duplicate_rows = []
 
array $local_change_rows = []
 
array $db_local_changes = []
 
array $db_entries = []
 
array $available_languages = []
 
array $logged_warnings = []
 
const string TWO_FORMS = 'nplurals=2; plural=(n != 1);'
 
const string THREE_FORMS = 'nplurals=3; plural=(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);'
 

Detailed Description

A line of the customizing file whose identifier exists in another module or in another spelling is left out, named by getSkippedDuplicateEntries() and, for a PO module, not recorded as taken over (language.md rule 2).

Definition at line 27 of file LanguageInstallationManagerDuplicateIdentifiersTest.php.

Member Function Documentation

◆ entriesOfTheSameRun()

static LanguageInstallationManagerDuplicateIdentifiersTest::entriesOfTheSameRun ( )
static
Returns
array<string, array{list<string>, ?array<string, string>, string}>

Definition at line 102 of file LanguageInstallationManagerDuplicateIdentifiersTest.php.

102 : array
103 {
104 return [
105 'a line of the shipped language file' => [['other#:#dup#:#Shipped'], null, 'other: dup'],
106 'another spelling in the shipped language file' => [['other#:#DUP#:#Shipped'], null, 'other: DUP'],
107 'an entry of a shipped .po' => [['common#:#yes#:#Ja'], ['dup' => 'Aus der PO'], 'pilot: dup'],
108 ];
109 }

◆ takenOver()

LanguageInstallationManagerDuplicateIdentifiersTest::takenOver ( )
private
Returns
list<string>

Definition at line 132 of file LanguageInstallationManagerDuplicateIdentifiersTest.php.

132 : array
133 {
134 return MigratedLanguageFileSync::modulesWithLocalChangesTakenOver($this->root . '/client-data', 'de');
135 }

Referenced by testAModuleWithADuplicateCustomizingEntryIsNotRecordedUntilItIsFixed().

+ Here is the caller graph for this function:

◆ testACustomizingEntryWhoseIdentifierExistsInAnotherModuleIsSkippedButTheRestIsInstalled()

LanguageInstallationManagerDuplicateIdentifiersTest::testACustomizingEntryWhoseIdentifierExistsInAnotherModuleIsSkippedButTheRestIsInstalled ( )

Definition at line 29 of file LanguageInstallationManagerDuplicateIdentifiersTest.php.

29 : void
30 {
31 $this->expectManagerWarning();
32 $this->writeLang('lang/ilias_de.lang', ['common#:#yes#:#Ja']);
33 $this->writeLang('lang/customizing/ilias_de.lang.local', ['common#:#yes#:#Jawohl', 'common#:#dup#:#Eigen']);
34 $this->duplicate_rows = [['module' => 'other', 'identifier' => 'dup']];
35
36 $manager = $this->manager();
37 $unwritten = $manager->insertLanguageForInstallation('de');
38
39 $this->assertSame([], $unwritten, 'a skipped entry is no unwritten overlay');
40 $this->assertSame('Jawohl', $this->lngModules()['common']['yes']);
41 $this->assertArrayNotHasKey('dup', $this->lngModules()['common'], 'the entry is not applied');
42 $this->assertSame(['de' => ['common#:#dup' => ['other: dup']]], $manager->getSkippedDuplicateEntries());
43 $this->assertStringContainsString('common#:#dup', $this->loggedWarnings());
44 }
manager(?\Closure $client_data_dir_resolver=null, ?\Closure $language_cache_invalidator=null, bool $with_resolver=true, bool $with_logger=true, ?LoggerInterface $logger=null)

References LanguageInstallationManagerMigratedModulesTestCase\expectManagerWarning(), LanguageInstallationManagerMigratedModulesTestCase\lngModules(), LanguageInstallationManagerMigratedModulesTestCase\loggedWarnings(), LanguageInstallationManagerMigratedModulesTestCase\manager(), and LanguageInstallationManagerMigratedModulesTestCase\writeLang().

+ Here is the call graph for this function:

◆ testAModuleWithADuplicateCustomizingEntryIsNotRecordedUntilItIsFixed()

LanguageInstallationManagerDuplicateIdentifiersTest::testAModuleWithADuplicateCustomizingEntryIsNotRecordedUntilItIsFixed ( )

Definition at line 111 of file LanguageInstallationManagerDuplicateIdentifiersTest.php.

111 : void
112 {
113 $this->expectManagerWarning();
114 $this->shipPo(['greeting' => 'Hallo']);
115 $this->shipSecondModule(['farewell' => 'Tschüss']);
116 $this->writeLang('lang/customizing/ilias_de.lang.local', ['pilot#:#extra#:#Eigen']);
117 $this->duplicate_rows = [['module' => 'other', 'identifier' => 'extra']];
118 $manager = $this->manager();
119
120 $manager->insertLanguageForInstallation('de');
121
122 $this->assertSame(['pilot2'], $this->takenOver());
123 $this->assertArrayHasKey('pilot#:#extra', $manager->getSkippedDuplicateEntries()['de'] ?? []);
124
125 $this->duplicate_rows = [];
126 $manager->insertLanguageForInstallation('de');
127
128 $this->assertSame([self::MODULE, 'pilot2'], $this->takenOver());
129 }
shipSecondModule(array $entries)
A second migrated module "pilot2" next to "pilot".

References LanguageInstallationManagerMigratedModulesTestCase\expectManagerWarning(), LanguageInstallationManagerMigratedModulesTestCase\manager(), LanguageInstallationManagerMigratedModulesTestCase\shipPo(), LanguageInstallationManagerMigratedModulesTestCase\shipSecondModule(), takenOver(), and LanguageInstallationManagerMigratedModulesTestCase\writeLang().

+ Here is the call graph for this function:

◆ testAnOldCollisionOfTheOwnModuleIsApplied()

LanguageInstallationManagerDuplicateIdentifiersTest::testAnOldCollisionOfTheOwnModuleIsApplied ( )

An old collision stays editable: the own module holds the identifier in this very spelling.

Definition at line 64 of file LanguageInstallationManagerDuplicateIdentifiersTest.php.

64 : void
65 {
66 $this->writeLang('lang/ilias_de.lang', ['common#:#dup#:#Shipped']);
67 $this->writeLang('lang/customizing/ilias_de.lang.local', ['common#:#dup#:#Eigen']);
68 $this->duplicate_rows = [['module' => 'other', 'identifier' => 'dup'], ['module' => 'common', 'identifier' => 'dup']];
69
70 $manager = $this->manager();
71 $manager->insertLanguageForInstallation('de');
72
73 $this->assertSame([], $manager->getSkippedDuplicateEntries());
74 $this->assertSame('Eigen', $this->lngModules()['common']['dup']);
75 }

References LanguageInstallationManagerMigratedModulesTestCase\lngModules(), LanguageInstallationManagerMigratedModulesTestCase\manager(), and LanguageInstallationManagerMigratedModulesTestCase\writeLang().

+ Here is the call graph for this function:

◆ testEntriesOfTheSameRunCountAsExisting()

LanguageInstallationManagerDuplicateIdentifiersTest::testEntriesOfTheSameRunCountAsExisting ( array  $shipped_lang_lines,
?array  $shipped_po,
string  $expected_duplicate 
)

lng_data is emptied before an installation, so what this run writes besides counts as existing: the lines of the shipped file and the shipped .po of a PO module.

Parameters
list<string>$shipped_lang_lines
?array<string,string>$shipped_po

Definition at line 85 of file LanguageInstallationManagerDuplicateIdentifiersTest.php.

85 : void
86 {
87 $this->expectManagerWarning();
88 $this->writeLang('lang/ilias_de.lang', $shipped_lang_lines);
89 if ($shipped_po !== null) {
90 $this->shipPo($shipped_po);
91 }
92 $this->writeLang('lang/customizing/ilias_de.lang.local', ['common#:#dup#:#Eigen']);
93
94 $manager = $this->manager();
95 $manager->insertLanguageForInstallation('de');
96
97 $this->assertSame(['de' => ['common#:#dup' => [$expected_duplicate]]], $manager->getSkippedDuplicateEntries());
98 $this->assertArrayNotHasKey('dup', $this->lngModules()['common'] ?? []);
99 }

References LanguageInstallationManagerMigratedModulesTestCase\expectManagerWarning(), LanguageInstallationManagerMigratedModulesTestCase\lngModules(), LanguageInstallationManagerMigratedModulesTestCase\manager(), LanguageInstallationManagerMigratedModulesTestCase\shipPo(), and LanguageInstallationManagerMigratedModulesTestCase\writeLang().

+ Here is the call graph for this function:

◆ testTheSkippedDuplicatesAreResetOnEveryInsertLanguageCall()

LanguageInstallationManagerDuplicateIdentifiersTest::testTheSkippedDuplicatesAreResetOnEveryInsertLanguageCall ( )

Definition at line 46 of file LanguageInstallationManagerDuplicateIdentifiersTest.php.

46 : void
47 {
48 $this->expectManagerWarning();
49 $this->writeLang('lang/ilias_de.lang', ['common#:#yes#:#Ja']);
50 $this->writeLang('lang/customizing/ilias_de.lang.local', ['common#:#dup#:#Eigen']);
51 $this->duplicate_rows = [['module' => 'other', 'identifier' => 'dup']];
52 $manager = $this->manager();
53 $manager->insertLanguageForInstallation('de');
54 $this->assertNotSame([], $manager->getSkippedDuplicateEntries(), 'precondition');
55
56 $this->duplicate_rows = [];
57 $manager->insertLanguageForInstallation('de');
58
59 $this->assertSame([], $manager->getSkippedDuplicateEntries());
60 $this->assertSame('Eigen', $this->lngModules()['common']['dup']);
61 }

References LanguageInstallationManagerMigratedModulesTestCase\expectManagerWarning(), LanguageInstallationManagerMigratedModulesTestCase\lngModules(), LanguageInstallationManagerMigratedModulesTestCase\manager(), and LanguageInstallationManagerMigratedModulesTestCase\writeLang().

+ Here is the call graph for this function:

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