19declare(strict_types=1);
28use PHPUnit\Framework\Attributes\DataProvider;
29use PHPUnit\Framework\TestCase;
50 file_put_contents($this->client_data_dir .
'/lang',
'not a directory');
59 #[DataProvider('danglingSymlinkPositions')]
63 $link = $link_path($this);
64 if (!is_dir(dirname($link))) {
65 mkdir(dirname($link), 0775,
true);
67 symlink($this->client_data_dir .
'/does-not-exist', $link);
78 'the overlay directory' => [
static fn(
self $test):
string => $test->overlayDirectory()],
79 'a parent ("lang")' => [
static fn(
self $test):
string => $test->client_data_dir .
'/lang'],
87 mkdir($this->client_data_dir .
'/elsewhere');
88 symlink($this->client_data_dir .
'/elsewhere', $this->client_data_dir .
'/lang');
98 $this->assertDirectoryDoesNotExist($this->client_data_dir .
'/lang');
100 $this->assertDirectoryDoesNotExist($this->client_data_dir .
'/lang',
'the check itself creates nothing');
107 $this->assertSame([], $this->
findUnwritable([
'de'], $this->client_data_dir .
'/not-yet-created'));
121 file_put_contents($this->client_data_dir .
'/lang',
'not a directory');
133 file_put_contents($this->client_data_dir .
'/lang',
'not a directory');
136 $this->assertSame([$this->client_data_dir .
'/lang/' . self::MODULE .
'/en'], $this->
findUnwritable([
'de',
'en']));
144 $second =
MigratedPoFixture::directory(
'stwo',
'components/ILIAS/Language/tests/ComponentTranslation/' . basename($this->fixture_directory) .
'/sub/');
149 $this->fixture_directory .
'/sub/stwo_de.po',
152 file_put_contents($this->client_data_dir .
'/lang',
'not a directory');
156 $this->client_data_dir .
'/lang/' . self::MODULE .
'/de',
157 $this->client_data_dir .
'/lang/stwo/de',
158 $this->client_data_dir .
'/lang/' . self::MODULE .
'/en',
An in-memory gettext catalog (header block plus messages) and the only place of the component that re...
Reads the shipped .po of a migrated module and maintains its per-installation overlay: the ....
Fixtures of the MigratedLanguageFileSync tests.
seedShipped(array $entries, string $lang_key='de', string $module=self::MODULE)
findUnwritable(array $lang_keys=['de'], ?string $client_data_dir='default', ?LanguageFileDirectoryManager $manager=null)
LanguageFileDirectoryManager $manager
MigratedLanguageFileSync::findUnwritableOverlayDirectories().
static danglingSymlinkPositions()
testASymlinkToAWritableDirectoryIsNotReported()
A symlink to an existing writable directory is fine (e.g.
testWithoutClientDataDirNothingIsReported()
testAnExistingWritableOverlayDirectoryIsNotReported()
testAFileInPlaceOfAParentOfTheOverlayDirectoryIsReported()
A file further up (where "<client data dir>/lang" is created) blocks the path just as well.
testAFileInPlaceOfTheOverlayDirectoryIsReported()
Root-proof: a regular file in place of the overlay directory - no user can create it,...
testAMissingClientDataDirWithACreatableParentIsNotReported()
testADanglingSymlinkInTheOverlayPathIsReported(\Closure $link_path)
A dangling symlink does not "exist" for file_exists(), but mkdir() cannot create anything in its plac...
testAModuleThatIsNotMigratedForTheLanguageIsIgnored()
Only modules migrated for a given language count: without a shipped .po no overlay is written,...
testEachUnwritableOverlayDirectoryIsReportedOnceAcrossLanguagesAndModules()
Each module has an overlay directory per language (lang/<module>/<lang>); each blocked one is reporte...
testAMissingButCreatableOverlayDirectoryIsNotReported()
A missing directory is fine if the closest existing parent is writable: sync() creates it.
static directory(string $prefix, string $path, bool $local=false)
static catalog(string $module, array $entries)
static writePo(string $file, TranslationCatalog $catalog)
A directory of language files with a path and a prefix for them.