20declare(strict_types=1);
23use PHPUnit\Framework\Attributes\DataProvider;
36 $content = MigratedLanguageFileSync::loadEditableModuleTranslations(
45 return $content ===
null ? null : array_map(
static fn(array $entry):
string => $entry[
'value'], $content);
50 $this->
seedShipped([
'greeting' =>
'Hallo',
'farewell' =>
'Tschüss']);
53 $this->assertSame([
'greeting' =>
'Moin',
'farewell' =>
'Tschüss'], $this->
editable());
60 file_put_contents($this->
overlayBase() .
'.po',
"msgid \"kaputt\n");
62 $this->expectOutputRegex(
'/The local changes of module "stest" for "de" cannot be read, the shipped values are used/');
63 $this->assertSame([
'greeting' =>
'Hallo'], $this->
editable());
71 file_put_contents($this->
overlayBase() .
'.po',
"msgid \"kaputt\n");
73 $this->expectException(\RuntimeException::class);
74 $this->
editable(
'default', self::MODULE,
'de',
true);
79 $this->
seedShipped([
'greeting' =>
'Hallo',
'farewell' =>
'Tschüss']);
82 $this->assertSame([
'greeting' =>
'Moin',
'farewell' =>
'Tschüss'], $this->
editable(
'default', self::MODULE,
'de',
true));
89 $this->assertSame([
'greeting' =>
'Hallo'], $this->
editable(
null));
90 $this->expectOutputString(
'');
95 file_put_contents($this->
shippedPo(),
"msgid \"kaputt\n");
97 $this->expectOutputRegex(
'/cannot be read/');
98 $this->expectException(\RuntimeException::class);
108 'module of no directory' => [
'unknown',
'de'],
109 'no shipped po for the language' => [
'stest',
'fr'],
110 'invalid language key' => [
'stest',
'../de'],
114 #[DataProvider('nothingToEdit')]
119 $this->assertNull($this->
editable(
'default', $module, $lang_key));
Reads the shipped .po of a migrated module and maintains its per-installation overlay: the ....
MigratedLanguageFileSync::loadEditableModuleTranslations(): the content the administration edits,...
testForWritingAReadableOverlayIsMergedAsForDisplay()
testWithoutClientDataDirectoryTheShippedPoAloneIsReturned()
testAnUnreadableShippedPoThrows()
testAnUnreadableOverlayThrowsForWritingAndIsNotReportedAsUsable()
For writing, the shipped values alone would drop the other local changes of the overlay: it throws in...
editable(?string $client_data_dir='default', string $module=self::MODULE, string $lang_key='de', bool $for_writing=false)
testAnUnreadableOverlayYieldsTheShippedPoAloneAndIsReported()
testTheShippedPoAndItsReadableOverlayAreMerged()
testWithoutDirectoryShippedPoOrValidKeyThereIsNothingToEdit(string $module, string $lang_key)
Fixtures of the MigratedLanguageFileSync tests.
seedOverlay(array $entries, string $lang_key='de')
seedShipped(array $entries, string $lang_key='de', string $module=self::MODULE)
overlayBase(string $lang_key='de')
shippedPo(string $lang_key='de', string $module=self::MODULE)
if(!isset($arguments[0])) if(count( $arguments) > 3) if(! $remove_from_lang &&isset($arguments[2]) &&!is_dir($arguments[2])) $module