19declare(strict_types=1);
28trait AddLanguageEntryTestFixture
33 protected function spyReplaceLangEntry(array &$calls): \Closure
35 return static function (
42 ) use (&$calls):
bool {
43 $calls[
'replace'][] = [
$module, $identifier, $lang_key, $value, $local_change, $remarks];
51 protected function spyUpdateModuleCache(array &$calls): \Closure
53 return static function (
59 ) use (&$calls):
void {
60 $calls[
'cache'][] = [$lang_key,
$module, $identifier, $value];
74 array $installed_languages,
76 ?Language $language =
null,
77 ?InstalledLanguageRepository $installed_language_repository =
null,
78 int $language_folder_ref_id = 0,
79 ?\Closure $replace_lang_entry =
null,
80 ?\Closure $update_module_cache =
null,
81 ?\Closure $user_login =
null,
82 ?\Closure $languages_without_plural_form =
null,
83 ?\Closure $duplicates_of =
null,
84 ?\Closure $has_unreadable_content =
null,
87 $replace_lang_entry ??= static fn(
95 $update_module_cache ??=
static fn(
102 $user_login ??=
static fn(
int $usr_id): string =>
'default-login';
103 $languages_without_plural_form ??=
static fn(
string $module,
string $identifier, array $lang_keys): array => [];
104 $duplicates_of ??=
static fn(
string $module,
string $identifier): array => [];
105 $has_unreadable_content ??=
static fn(
string $lang_key,
string $module): bool => false;
106 $installed_language_repository ??=
new FakeInstalledLanguageRepository(
static fn(): array => $installed_languages);
108 $repository = $this->createStub(RepositoryProvider::class);
109 $repository->method(
'getInstalledLanguages')->willReturnCallback(
110 static fn(): array => $installed_language_repository->getInstalledLanguages()
112 $repository->method(
'replaceLangEntry')->willReturnCallback($replace_lang_entry);
113 $repository->method(
'updateModuleCache')->willReturnCallback(
120 ):
bool => $update_module_cache($lang_key,
$module, $identifier, $value, $remarks) ??
true
122 $repository->method(
'lookupLogin')->willReturnCallback($user_login);
123 $repository->method(
'hasUnreadableContent')->willReturnCallback($has_unreadable_content);
124 $repository->method(
'languagesWithoutPluralForm')->willReturnCallback($languages_without_plural_form);
125 $repository->method(
'findDuplicatesOf')->willReturnCallback($duplicates_of);
127 return new AddLanguageEntry(
128 $language ?? $this->createStub(Language::class),
129 $this->rbacOf($rbac ?? $this->createStub(\ilRbacSystem::class)),
130 $this->languageFolder($language_folder_ref_id),
Every legacy and repository access of the runtime language activities.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
if(!isset($arguments[0])) if(count( $arguments) > 3) if(! $remove_from_lang &&isset($arguments[2]) &&!is_dir($arguments[2])) $module
Read-only access to the installed languages (database) and the available or valid language files (fil...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
createActivity(\Closure $lng_objects, \Closure $obj_language_factory, ?\ilRbacSystem $rbac=null, int $language_folder_ref_id=0, ?RepositoryProvider $repository=null,)