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

Covers the private static databaseRowsOfMigratedModule(): it folds the buffered per-form lng_data rows of a plural message into the single row the database must end up with (default form's value, first non-null remarks, local_change only if the merged value differs from the shipped default). More...

+ Inheritance diagram for LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest:
+ Collaboration diagram for LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest:

Public Member Functions

 testTwoFormRowsFoldIntoOneRowWithTheDefaultFormsValue ()
 Two buffered form rows fold into one row under the plain identifier, with the default form's (msgstr[1], count >= 2) value of the module's final content. More...
 
 testAPlainRowOfAnUnrelatedIdentifierIsKeptUnchanged ()
 A plain row of an identifier that is not a plural message of the shipped state (here the separately shipped "poll_population_singular", see pluralMessageOf()) is kept untouched. More...
 
 testRemarksParameterOverridesTheRowsOwnRemarkForAPlainIdentifier ()
 $remarks (from migratedModuleRemarks()) overrides the remark of the buffered rows, for plain identifiers and merged plural rows alike. More...
 
 testRemarksParameterOverridesTheMergedRemarkOfAPluralMessage ()
 
 testAnIdentifierNotInRemarksKeepsTheRowsOwnRemark ()
 An identifier not named in $remarks keeps the rows' own remark. More...
 
 testLocalChangeIsNullWhenTheMergedDefaultFormValueMatchesTheShippedOne ()
 local_change depends on the merged default-form VALUE differing from the shipped default, not on a stale local_change timestamp of some row. More...
 
 testTheFirstNonNullLocalChangeAndRemarksOfTheFormRowsAreKeptWhenTheValueActuallyChanged ()
 The first non-null local_change/remarks among the form rows wins once the merged value differs; a later null must not erase it. More...
 
 testAnEarlierNonNullLocalChangeSurvivesALaterRowsNullOnesWhenTheValueActuallyChanged ()
 Same, with the local_change-carrying row processed first. More...
 
 testFormRowsWithNoValueInTheFinalContentAreDroppedEntirely ()
 A form row whose message has no value in the final content is dropped instead of written with a bogus value. More...
 
 testASingleFormLanguageStillFoldsIntoOneRow ()
 A single-form language (nplurals=1) still folds into one row keyed by its identifier. More...
 

Private Member Functions

 call (array $rows, array $final_entries, array $shipped_entries, array $remarks=[])
 

Private Attributes

const SHIPPED
 

Detailed Description

Covers the private static databaseRowsOfMigratedModule(): it folds the buffered per-form lng_data rows of a plural message into the single row the database must end up with (default form's value, first non-null remarks, local_change only if the merged value differs from the shipped default).

Definition at line 29 of file LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest.php.

Member Function Documentation

◆ call()

LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest::call ( array  $rows,
array  $final_entries,
array  $shipped_entries,
array  $remarks = [] 
)
private
Parameters
array<string,array{0string, 1: ?string, 2: ?string}> $rows
array<string,string>$final_entries
array<string,string>$shipped_entries
array<string,string>$remarks identifier => remark (see migratedModuleRemarks()), written into the row instead of the buffered rows' own remark
Returns
array<string, array{0: string, 1: ?string, 2: ?string}>

Definition at line 41 of file LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest.php.

41 : array
42 {
43 $method = (new ReflectionClass(LanguageInstallationManager::class))->getMethod('databaseRowsOfMigratedModule');
44
45 return $method->invoke(null, $rows, $final_entries, $shipped_entries, $remarks);
46 }

References ILIAS\Scripts\PHPStan\$rows.

Referenced by testAnEarlierNonNullLocalChangeSurvivesALaterRowsNullOnesWhenTheValueActuallyChanged(), testAnIdentifierNotInRemarksKeepsTheRowsOwnRemark(), testAPlainRowOfAnUnrelatedIdentifierIsKeptUnchanged(), testASingleFormLanguageStillFoldsIntoOneRow(), testFormRowsWithNoValueInTheFinalContentAreDroppedEntirely(), testLocalChangeIsNullWhenTheMergedDefaultFormValueMatchesTheShippedOne(), testRemarksParameterOverridesTheMergedRemarkOfAPluralMessage(), testRemarksParameterOverridesTheRowsOwnRemarkForAPlainIdentifier(), testTheFirstNonNullLocalChangeAndRemarksOfTheFormRowsAreKeptWhenTheValueActuallyChanged(), and testTwoFormRowsFoldIntoOneRowWithTheDefaultFormsValue().

+ Here is the caller graph for this function:

◆ testAnEarlierNonNullLocalChangeSurvivesALaterRowsNullOnesWhenTheValueActuallyChanged()

LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest::testAnEarlierNonNullLocalChangeSurvivesALaterRowsNullOnesWhenTheValueActuallyChanged ( )

Same, with the local_change-carrying row processed first.

Definition at line 181 of file LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest.php.

181 : void
182 {
183 $rows = [
184 'poll_population [1]' => ['%s NEUE Stimmabgaben', '2024-01-01 00:00:00', 'lokal geändert'],
185 'poll_population [0]' => ['Eine Stimmabgabe', null, null],
186 ];
187 $final_entries = ['poll_population [0]' => 'Eine Stimmabgabe', 'poll_population [1]' => '%s NEUE Stimmabgaben'];
188
189 $result = $this->call($rows, $final_entries, self::SHIPPED);
190
191 $this->assertSame(
192 ['poll_population' => ['%s NEUE Stimmabgaben', '2024-01-01 00:00:00', 'lokal geändert']],
193 $result
194 );
195 }
call(array $rows, array $final_entries, array $shipped_entries, array $remarks=[])

References ILIAS\Scripts\PHPStan\$rows, and call().

+ Here is the call graph for this function:

◆ testAnIdentifierNotInRemarksKeepsTheRowsOwnRemark()

LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest::testAnIdentifierNotInRemarksKeepsTheRowsOwnRemark ( )

An identifier not named in $remarks keeps the rows' own remark.

Definition at line 127 of file LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest.php.

127 : void
128 {
129 $rows = ['poll_population_singular' => ['Eine Stimmabgabe', null, 'Eigene Anmerkung']];
130
131 $result = $this->call($rows, ['poll_population_singular' => 'Eine Stimmabgabe'], self::SHIPPED, []);
132
133 $this->assertSame('Eigene Anmerkung', $result['poll_population_singular'][2]);
134 }

References ILIAS\Scripts\PHPStan\$rows, and call().

+ Here is the call graph for this function:

◆ testAPlainRowOfAnUnrelatedIdentifierIsKeptUnchanged()

LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest::testAPlainRowOfAnUnrelatedIdentifierIsKeptUnchanged ( )

A plain row of an identifier that is not a plural message of the shipped state (here the separately shipped "poll_population_singular", see pluralMessageOf()) is kept untouched.

Definition at line 78 of file LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest.php.

78 : void
79 {
80 $rows = ['poll_population_singular' => ['Eine Stimmabgabe', '2024-01-01 00:00:00', 'Anmerkung']];
81
82 $result = $this->call($rows, ['poll_population_singular' => 'Eine Stimmabgabe'], self::SHIPPED);
83
84 $this->assertSame(
85 ['poll_population_singular' => ['Eine Stimmabgabe', '2024-01-01 00:00:00', 'Anmerkung']],
86 $result
87 );
88 }

References ILIAS\Scripts\PHPStan\$rows, and call().

+ Here is the call graph for this function:

◆ testASingleFormLanguageStillFoldsIntoOneRow()

LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest::testASingleFormLanguageStillFoldsIntoOneRow ( )

A single-form language (nplurals=1) still folds into one row keyed by its identifier.

Definition at line 219 of file LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest.php.

219 : void
220 {
221 $shipped = ['poll_population [0]' => 'ある投票'];
222 $rows = ['poll_population [0]' => ['ある投票NEU', null, null]];
223 $final_entries = ['poll_population [0]' => 'ある投票NEU'];
224
225 $result = $this->call($rows, $final_entries, $shipped);
226
227 $this->assertSame(['poll_population' => ['ある投票NEU', null, null]], $result);
228 }

References ILIAS\Scripts\PHPStan\$rows, and call().

+ Here is the call graph for this function:

◆ testFormRowsWithNoValueInTheFinalContentAreDroppedEntirely()

LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest::testFormRowsWithNoValueInTheFinalContentAreDroppedEntirely ( )

A form row whose message has no value in the final content is dropped instead of written with a bogus value.

Definition at line 200 of file LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest.php.

200 : void
201 {
202 $rows = [
203 'poll_population [0]' => ['Eine Stimmabgabe', null, null],
204 'poll_population [1]' => ['%s Stimmabgaben', null, null],
205 'poll_population_singular' => ['Eine Stimmabgabe', null, null],
206 ];
207 // final content no longer mentions "poll_population" at all
208 $final_entries = ['poll_population_singular' => 'Eine Stimmabgabe'];
209
210 $result = $this->call($rows, $final_entries, self::SHIPPED);
211
212 $this->assertArrayNotHasKey('poll_population', $result);
213 $this->assertSame(['poll_population_singular' => ['Eine Stimmabgabe', null, null]], $result);
214 }

References ILIAS\Scripts\PHPStan\$rows, and call().

+ Here is the call graph for this function:

◆ testLocalChangeIsNullWhenTheMergedDefaultFormValueMatchesTheShippedOne()

LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest::testLocalChangeIsNullWhenTheMergedDefaultFormValueMatchesTheShippedOne ( )

local_change depends on the merged default-form VALUE differing from the shipped default, not on a stale local_change timestamp of some row.

Remarks are independent of that: the first non-null one wins, here from the second row.

Definition at line 141 of file LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest.php.

141 : void
142 {
143 $rows = [
144 'poll_population [0]' => ['Eine Stimmabgabe', null, null],
145 'poll_population [1]' => ['%s Stimmabgaben', '2024-01-01 00:00:00', 'lokal geändert'],
146 ];
147 // identical to self::SHIPPED - the message did not actually change
148 $final_entries = ['poll_population [0]' => 'Eine Stimmabgabe', 'poll_population [1]' => '%s Stimmabgaben'];
149
150 $result = $this->call($rows, $final_entries, self::SHIPPED);
151
152 $this->assertSame(
153 ['poll_population' => ['%s Stimmabgaben', null, 'lokal geändert']],
154 $result
155 );
156 }

References ILIAS\Scripts\PHPStan\$rows, and call().

+ Here is the call graph for this function:

◆ testRemarksParameterOverridesTheMergedRemarkOfAPluralMessage()

LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest::testRemarksParameterOverridesTheMergedRemarkOfAPluralMessage ( )

Definition at line 111 of file LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest.php.

111 : void
112 {
113 $rows = [
114 'poll_population [0]' => ['Eine Stimmabgabe', null, null],
115 'poll_population [1]' => ['%s Stimmabgaben', null, 'Alte Anmerkung'],
116 ];
117 $final_entries = ['poll_population [0]' => 'Eine Stimmabgabe', 'poll_population [1]' => '%s Stimmabgaben'];
118
119 $result = $this->call($rows, $final_entries, self::SHIPPED, ['poll_population' => 'Neue Anmerkung']);
120
121 $this->assertSame('Neue Anmerkung', $result['poll_population'][2]);
122 }

References ILIAS\Scripts\PHPStan\$rows, and call().

+ Here is the call graph for this function:

◆ testRemarksParameterOverridesTheRowsOwnRemarkForAPlainIdentifier()

LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest::testRemarksParameterOverridesTheRowsOwnRemarkForAPlainIdentifier ( )

$remarks (from migratedModuleRemarks()) overrides the remark of the buffered rows, for plain identifiers and merged plural rows alike.

Definition at line 94 of file LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest.php.

94 : void
95 {
96 $rows = ['poll_population_singular' => ['Eine Stimmabgabe', '2024-01-01 00:00:00', 'Alte Anmerkung']];
97
98 $result = $this->call(
99 $rows,
100 ['poll_population_singular' => 'Eine Stimmabgabe'],
101 self::SHIPPED,
102 ['poll_population_singular' => 'Neue Anmerkung']
103 );
104
105 $this->assertSame(
106 ['poll_population_singular' => ['Eine Stimmabgabe', '2024-01-01 00:00:00', 'Neue Anmerkung']],
107 $result
108 );
109 }

References ILIAS\Scripts\PHPStan\$rows, and call().

+ Here is the call graph for this function:

◆ testTheFirstNonNullLocalChangeAndRemarksOfTheFormRowsAreKeptWhenTheValueActuallyChanged()

LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest::testTheFirstNonNullLocalChangeAndRemarksOfTheFormRowsAreKeptWhenTheValueActuallyChanged ( )

The first non-null local_change/remarks among the form rows wins once the merged value differs; a later null must not erase it.

Definition at line 162 of file LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest.php.

162 : void
163 {
164 $rows = [
165 'poll_population [0]' => ['Eine Stimmabgabe', null, null],
166 'poll_population [1]' => ['%s NEUE Stimmabgaben', '2024-01-01 00:00:00', 'lokal geändert'],
167 ];
168 $final_entries = ['poll_population [0]' => 'Eine Stimmabgabe', 'poll_population [1]' => '%s NEUE Stimmabgaben'];
169
170 $result = $this->call($rows, $final_entries, self::SHIPPED);
171
172 $this->assertSame(
173 ['poll_population' => ['%s NEUE Stimmabgaben', '2024-01-01 00:00:00', 'lokal geändert']],
174 $result
175 );
176 }

References ILIAS\Scripts\PHPStan\$rows, and call().

+ Here is the call graph for this function:

◆ testTwoFormRowsFoldIntoOneRowWithTheDefaultFormsValue()

LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest::testTwoFormRowsFoldIntoOneRowWithTheDefaultFormsValue ( )

Two buffered form rows fold into one row under the plain identifier, with the default form's (msgstr[1], count >= 2) value of the module's final content.

Definition at line 58 of file LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest.php.

58 : void
59 {
60 $rows = [
61 'poll_population [0]' => ['Eine Stimmabgabe', null, null],
62 'poll_population [1]' => ['%s NEUE Stimmabgaben', null, null],
63 ];
64 $final_entries = [
65 'poll_population [0]' => 'Eine Stimmabgabe',
66 'poll_population [1]' => '%s NEUE Stimmabgaben',
67 ];
68
69 $result = $this->call($rows, $final_entries, self::SHIPPED);
70
71 $this->assertSame(['poll_population' => ['%s NEUE Stimmabgaben', null, null]], $result);
72 }

References ILIAS\Scripts\PHPStan\$rows, and call().

+ Here is the call graph for this function:

Field Documentation

◆ SHIPPED

const LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest::SHIPPED
private
Initial value:
= [
'poll_population [0]' => 'Eine Stimmabgabe',
'poll_population [1]' => '%s Stimmabgaben',
'poll_population_singular' => 'Eine Stimmabgabe',
]

Definition at line 48 of file LanguageInstallationManagerDatabaseRowsOfMigratedModuleTest.php.


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