20declare(strict_types=1);
24use PHPUnit\Framework\Attributes\DataProvider;
29 private function touch(
string $relative): void
31 $file = $this->client_data_dir .
'/lang/' . $relative;
32 if (!is_dir(dirname($file))) {
33 mkdir(dirname($file), 0775,
true);
35 file_put_contents($file,
'x');
44 'current' => [
'current',
true],
45 'po' => [
'zmod_de.po',
true],
46 'only the lock' => [
'zmod_de.lock',
false],
47 'only the mo' => [
'zmod_de.mo',
false],
51 #[DataProvider('overlayMarkers')]
54 $this->
touch(
'zmod/de/' . $file);
56 $this->assertSame($is_overlay ? [
'zmod'] : [], MigratedLanguageFileSync::findModulesWithOverlay($this->client_data_dir,
'de'));
61 $this->
touch(
'zmod/de/current');
62 $this->
touch(
'amod/de/amod_de.po');
63 $this->
touch(
'fmod/fr/current');
65 $this->assertSame([
'amod',
'zmod'], MigratedLanguageFileSync::findModulesWithOverlay($this->client_data_dir,
'de'));
66 $this->assertSame([
'fmod'], MigratedLanguageFileSync::findModulesWithOverlay($this->client_data_dir,
'fr'));
72 MigratedLanguageFileSync::markLocalChangesTakenOver($this->client_data_dir,
'de', [
'zmod']);
73 $this->
touch(
'.locks/de/current');
74 $this->
touch(
'.locks/de/x.po');
76 $this->assertFileExists(MigratedLanguageFilePaths::takenOverFile($this->client_data_dir,
'de'));
77 $this->assertSame([], MigratedLanguageFileSync::findModulesWithOverlay($this->client_data_dir,
'de'));
82 $outside = sys_get_temp_dir() .
'/ilias_find_overlay_outside_' . bin2hex(random_bytes(4));
83 mkdir($outside .
'/de', 0775,
true);
84 file_put_contents($outside .
'/de/current',
'x');
86 mkdir($this->client_data_dir .
'/lang/linkedmod', 0775,
true);
87 symlink($outside .
'/de', $this->client_data_dir .
'/lang/linkedmod/de');
88 symlink($outside, $this->client_data_dir .
'/lang/linkedmodule');
89 mkdir($this->client_data_dir .
'/lang/linkedcurrent/de', 0775,
true);
90 symlink($outside .
'/missing', $this->client_data_dir .
'/lang/linkedcurrent/de/current');
92 $this->assertSame([
'linkedcurrent'], MigratedLanguageFileSync::findModulesWithOverlay($this->client_data_dir,
'de'));
100 $this->
touch(
'zmod/de/current');
102 $this->assertSame([], MigratedLanguageFileSync::findModulesWithOverlay(
null,
'de'));
103 $this->assertSame([], MigratedLanguageFileSync::findModulesWithOverlay($this->client_data_dir,
'../de'));
104 $this->assertSame([], MigratedLanguageFileSync::findModulesWithOverlay($this->client_data_dir .
'/missing',
'de'));
110 $this->
touch(
'amod/de/current');
111 mkdir($this->client_data_dir .
'/lang/zmod/de', 0775,
true);
112 chmod($this->client_data_dir .
'/lang/zmod/de', 0000);
114 if (is_readable($this->client_data_dir .
'/lang/zmod/de')) {
115 $this->markTestSkipped(
'permissions are not enforced (root)');
117 $this->assertSame([
'amod',
'zmod'], MigratedLanguageFileSync::findModulesWithOverlay($this->client_data_dir,
'de'));
119 chmod($this->client_data_dir .
'/lang', 0000);
120 $this->assertSame([], MigratedLanguageFileSync::findModulesWithOverlay($this->client_data_dir,
'de'));
122 chmod($this->client_data_dir .
'/lang', 0775);
123 chmod($this->client_data_dir .
'/lang/zmod/de', 0775);
The single place that knows where the files of a module migrated to PO/MO live:
Reads the shipped .po of a migrated module and maintains its per-installation overlay: the ....
findModulesWithOverlay(): only current or a .po in lang/<module>/<lang>/ counts, nothing else below l...
testAModuleIsFoundPerLanguageAndTheResultIsSorted()
testNoClientDataDirectoryAnInvalidLanguageKeyOrNoLangDirectoryFindNothing()
testOnlyCurrentOrAPoMakesAnOverlay(string $file, bool $is_overlay)
testLocksAndTheTakenOverRecordAreNoModules()
The lock directory and the record sit next to the module directories and are no modules.
testSymbolicLinksAreNotFollowed()
testUnreadableDirectoriesCountAsOverlayOrFindNothing()
An unreadable module directory counts as overlay, an unreadable overlay root finds nothing.
Fixtures of the MigratedLanguageFileSync tests.
static removeDirectory(string $directory)