169         $mock_builder_user_callable = 
function (): MockBuilder {
   170             return $this->getMockBuilder(ilObjUser::class);
   172         $mock_builder_ou_user_callable = 
function (): MockBuilder {
   173             return $this->getMockBuilder(ilOrgUnitUser::class);
   176         $user = $user_callable($mock_builder_user_callable);
   177         [$ou_user, $ou_superiors] = $ou_user_callable($mock_builder_ou_user_callable);
   179         $ou_service = $this->getMockBuilder(OrgUnitUserService::class)
   180                            ->disableOriginalConstructor()
   181                            ->onlyMethods([
'getUsers',])
   184         $lng = $this->getMockBuilder(ilLanguage::class)
   185                     ->disableOriginalConstructor()
   186                     ->onlyMethods([
'txt', 
'loadLanguageModule',])
   189         $env_helper = $this->getMockBuilder(ilMailEnvironmentHelper::class)
   190                            ->disableOriginalConstructor()
   191                            ->onlyMethods([
'getClientId', 
'getHttpPath',])
   194         $lng_helper = $this->getMockBuilder(ilMailLanguageHelper::class)
   195                            ->disableOriginalConstructor()
   196                            ->onlyMethods([
'getLanguageByIsoCode', 
'getCurrentLanguage',])
   199         $user_helper = $this->getMockBuilder(ilMailUserHelper::class)
   200                             ->disableOriginalConstructor()
   201                             ->onlyMethods([
'getUsernameMapForIds',])
   204         $ou_service->expects($this->atLeastOnce())->method(
'getUsers')->willReturn([$ou_user,]);
   205         $lng->expects($this->atLeastOnce())->method(
'txt')->will($this->returnArgument(0));
   206         $env_helper->expects($this->atLeastOnce())->method(
'getClientId')->willReturn(
'###phpunit_client###');
   207         $env_helper->expects($this->atLeastOnce())->method(
'getHttpPath')->willReturn(
'###http_ilias###');
   208         $lng_helper->expects($this->atLeastOnce())->method(
'getLanguageByIsoCode')->willReturn(
$lng);
   209         $lng_helper->expects($this->atLeastOnce())->method(
'getCurrentLanguage')->willReturn(
$lng);
   211         $expected_ids_constraint = [];
   212         if ($ou_superiors !== []) {
   213             $expected_ids_constraint = self::logicalAnd(
   215                     static function (
ilOrgUnitUser $user): \PHPUnit\Framework\Constraint\TraversableContainsEqual {
   216                         return self::containsEqual($user->
getUserId());
   224             return "PhpSup$key UnitSup$key";
   225         }, $ou_superiors, array_keys($ou_superiors));
   227         $user_helper->expects($this->atLeastOnce())->method(
'getUsernameMapForIds')
   228                     ->with($expected_ids_constraint)
   229                     ->willReturn($first_and_last_names);
   238         $mustache = 
new Mustache_Engine();
   241         $message = implode(
'', [
   242             '{{MAIL_SALUTATION}}',
   247             '{{FIRSTNAME_LASTNAME_SUPERIOR}}',
   249             '{{INSTALLATION_NAME}}',
   251         $replace_message = $placeholder_resolver->resolve(
$context, $message, $user);
   253         $this->assertStringContainsString(
'###Dr. Ing###', $replace_message);
   254         $this->assertStringContainsString(
'###phpunit###', $replace_message);
   255         $this->assertStringContainsString(
'###Unit###', $replace_message);
   256         $this->assertStringContainsString(
'###PHP###', $replace_message);
   257         $this->assertStringContainsString(
'###phpunit_client###', $replace_message);
   258         $this->assertStringContainsString(
'###http_ilias###', $replace_message);
   259         $this->assertStringContainsString(
'mail_salutation_' . $user->getGender(), $replace_message);
   261         foreach ($first_and_last_names as $firstAndLastname) {
   262             $this->assertStringContainsString($firstAndLastname, $replace_message);
 
Class ilMailTemplatePlaceholderResolver. 
 
getAnonymousTemplateContext(OrgUnitUserService $orgUnitUserService, ilMailEnvironmentHelper $envHelper, ilMailUserHelper $usernameHelper, ilMailLanguageHelper $languageHelper)