19 declare(strict_types=1);
    34         return new class ($orgUnitUserService, $envHelper, $usernameHelper, $languageHelper) extends
    36             public function getId(): 
string    46             public function getDescription(): 
string    51             public function getSpecificPlaceholders(): array
    56             public function resolveSpecificPlaceholder(
    57                 string $placeholder_id,
    58                 array $context_parameters,
    75         for ($i = 1; $i <= $amount; $i++) {
    76             $user = $mock_builder()
    77                 ->disableOriginalConstructor()
    78                 ->onlyMethods([
'getUserId',])
    80             $user->expects(self::atLeastOnce())->method(
'getUserId')->willReturn($i);
    98                 [
'gender' => 
'm', 
'num_superiors' => 2,],
    99                 [
'gender' => 
'n', 
'num_superiors' => 1,],
   100                 [
'gender' => 
'f', 
'num_superiors' => 0,],
   101                 [
'gender' => 
'', 
'num_superiors' => 3,],
   107             $user_callable = 
static function (
Closure $mock_builder) use ($definition): 
ilObjUser&MockObject {
   108                 $user = $mock_builder()
   109                     ->disableOriginalConstructor()
   121                 $user->expects(self::atLeastOnce())->method(
'getLanguage')->willReturn(
'de');
   122                 $user->expects(self::atLeastOnce())->method(
'getUTitle')->willReturn(
'###Dr. Ing###');
   123                 $user->expects(self::atLeastOnce())->method(
'getLogin')->willReturn(
'###phpunit###');
   124                 $user->expects(self::atLeastOnce())->method(
'getLastname')->willReturn(
'###Unit###');
   125                 $user->expects(self::atLeastOnce())->method(
'getFirstname')->willReturn(
'###PHP###');
   126                 $user->expects(self::atLeastOnce())->method(
'getGender')->willReturn($definition[
'gender']);
   127                 $user->expects(self::atLeastOnce())->method(
'getId')->willReturn(4711);
   137             $ou_user_callable = 
static function (
Closure $mock_builder) use ($definition): array {
   138                 $ou_user = $mock_builder()
   139                     ->disableOriginalConstructor()
   140                     ->onlyMethods([
'getSuperiors',])
   143                 $superiors = self::generateOrgUnitUsers($mock_builder, $definition[
'num_superiors']);
   144                 $ou_user->expects(self::atLeastOnce())->method(
'getSuperiors')->willReturn($superiors);
   146                 return [$ou_user, $superiors];
   150                 'User with gender "%s" and %s superiors',
   151                 $definition[
'gender'],
   152                 $definition[
'num_superiors']
   153             )] = [$user_callable, $ou_user_callable];
   166         callable $user_callable,
   167         callable $ou_user_callable
   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 ilMailEnvironmentHelper. 
 
static generateOrgUnitUsers(Closure $mock_builder, int $amount)
 
Class ilMailLanguageHelper. 
 
Class ilMailTemplatePlaceholderResolver. 
 
testGlobalPlaceholdersCanBeResolvedWithCorrespondingValues(callable $user_callable, callable $ou_user_callable)
userProvider 
 
getAnonymousTemplateContext(OrgUnitUserService $orgUnitUserService, ilMailEnvironmentHelper $envHelper, ilMailUserHelper $usernameHelper, ilMailLanguageHelper $languageHelper)