166 $mock_builder_user_callable = fn(): MockBuilder => $this->getMockBuilder(
ilObjUser::class);
167 $mock_builder_ou_user_callable = fn(): MockBuilder => $this->getMockBuilder(
ilOrgUnitUser::class);
169 $user_callable = Closure::bind($user_callable, $this, self::class);
170 $ou_user_callable = Closure::bind($ou_user_callable, $this, self::class);
172 $user = $user_callable($mock_builder_user_callable);
173 [$ou_user, $ou_superiors] = $ou_user_callable($mock_builder_ou_user_callable);
175 $ou_service = $this->getMockBuilder(OrgUnitUserService::class)
176 ->disableOriginalConstructor()
177 ->onlyMethods([
'getUsers',])
180 $lng = $this->getMockBuilder(ilLanguage::class)
181 ->disableOriginalConstructor()
182 ->onlyMethods([
'txt',
'loadLanguageModule',])
185 $env_helper = $this->getMockBuilder(ilMailEnvironmentHelper::class)
186 ->disableOriginalConstructor()
187 ->onlyMethods([
'getClientId',
'getHttpPath',])
190 $lng_helper = $this->getMockBuilder(ilMailLanguageHelper::class)
191 ->disableOriginalConstructor()
192 ->onlyMethods([
'getLanguageByIsoCode',
'getCurrentLanguage',])
195 $user_helper = $this->getMockBuilder(ilMailUserHelper::class)
196 ->disableOriginalConstructor()
197 ->onlyMethods([
'getUsernameMapForIds',])
200 $ou_service->expects($this->atLeastOnce())->method(
'getUsers')->willReturn([$ou_user,]);
201 $lng->expects($this->atLeastOnce())->method(
'txt')->willReturnArgument(0);
202 $env_helper->expects($this->atLeastOnce())->method(
'getClientId')->willReturn(
'###phpunit_client###');
203 $env_helper->expects($this->atLeastOnce())->method(
'getHttpPath')->willReturn(
'###http_ilias###');
204 $lng_helper->expects($this->atLeastOnce())->method(
'getLanguageByIsoCode')->willReturn(
$lng);
205 $lng_helper->expects($this->atLeastOnce())->method(
'getCurrentLanguage')->willReturn(
$lng);
207 $expected_ids_constraint = [];
208 if ($ou_superiors !== []) {
209 $expected_ids_constraint = self::logicalAnd(
212 return self::containsEqual($user->
getUserId());
220 return "PhpSup$key UnitSup$key";
221 }, $ou_superiors, array_keys($ou_superiors));
223 $user_helper->expects($this->atLeastOnce())->method(
'getUsernameMapForIds')
224 ->with($expected_ids_constraint)
225 ->willReturn($first_and_last_names);
234 $mustache =
new Mustache_Engine();
238 '{{MAIL_SALUTATION}}',
243 '{{FIRSTNAME_LASTNAME_SUPERIOR}}',
245 '{{INSTALLATION_NAME}}',
247 $replace_message = $placeholder_resolver->resolve(
$context,
$message, $user);
249 $this->assertStringContainsString(
'###Dr. Ing###', $replace_message);
250 $this->assertStringContainsString(
'###phpunit###', $replace_message);
251 $this->assertStringContainsString(
'###Unit###', $replace_message);
252 $this->assertStringContainsString(
'###PHP###', $replace_message);
253 $this->assertStringContainsString(
'###phpunit_client###', $replace_message);
254 $this->assertStringContainsString(
'###http_ilias###', $replace_message);
255 $this->assertStringContainsString(
'mail_salutation_' . $user->getGender(), $replace_message);
257 foreach ($first_and_last_names as $first_and_lastname) {
258 $this->assertStringContainsString($first_and_lastname, $replace_message);
getAnonymousTemplateContext(OrgUnitUserService $org_unit_user_service, ilMailEnvironmentHelper $il_mail_environment_helper, ilMailUserHelper $mail_user_helper, ilMailLanguageHelper $language_helper)