ILIAS  release_7 Revision v7.30-3-g800a261c036
ilMailAddressTypesTest Class Reference

Class ilMailAddressTypesTest. More...

+ Inheritance diagram for ilMailAddressTypesTest:
+ Collaboration diagram for ilMailAddressTypesTest:

Public Member Functions

 setUp ()
 
 testFactoryWillReturnListAddressTypeForListName ()
 
 testFactoryWillReturnGroupAddressTypeForGroupName ()
 
 testFactoryWillReturnLoginOrEmailAddressAddressType ()
 
 testFactoryWillReturnRoleAddressType ()
 
 testAdminGroupNameIsAValidMailAddressTypes ()
 
 testMemberGroupNameIsAValidMailAddressType ()
 
 testAdminCourseNameIsAValidMailAddressType ()
 
 testMemberCourseNameIsAValidMailAddressType ()
 
 testUserIdCanBeResolvedFromLoginAddress ()
 
 testNoUserIdCanBeResolvedFromUnknownLoginAddress ()
 
 testNoUserIdCanBeResolvedFromEmailAddress ()
 
 testAddressCanBeValidatedFromLoginOrEmailAddressType ()
 
 testUserIdsCanBeResolvedFromGroupNameAddress ()
 
 testUserIdsCannotBeResolvedFromNonExistingGroupNameAddress ()
 
 testValidationFailsForNonExistingGroupNameAddress ()
 
 testValidationSucceedsForExistingGroupName ()
 
 testUserIdsCanBeResolvedFromMailingListAddress ()
 
 testMailingListAddressCanBeValidated ()
 
 testUserIdsCanBeResolvedFromRoleAddress ()
 
 testNoUserIdsCanBeResolvedFromInvalidRoleAddress ()
 
 testValidationForAnonymousUserAsSystemActorSucceedsAlwaysForGlobalRoleAddresses ()
 
 testPermissionsAreCheckedForRegularUsersWhenValidatingGlobalRoleAddresses ()
 
 testCacheOnlyResolvesAndValidatesRecipientsOnceIfCachingIsEnabled ()
 
 testCacheResolvesAndValidatesRecipientsOnEveryCallIfCachingIsDisabled ()
 

Private Member Functions

 createGroupNameAsValidatorMock ()
 
 getAddressTypeFactory ($groupNameValidatorMock)
 
 getWrappedAddressType (ilMailAddressType $type)
 

Additional Inherited Members

- Protected Member Functions inherited from ilMailBaseTest
 setUp ()
 
 setGlobalVariable (string $name, $value)
 

Detailed Description

Member Function Documentation

◆ createGroupNameAsValidatorMock()

ilMailAddressTypesTest::createGroupNameAsValidatorMock ( )
private
Returns
PHPUnit\Framework\MockObject\MockObject|ilGroupNameAsMailValidator
Exceptions
ReflectionException

Definition at line 27 of file ilMailAddressTypesTest.php.

28 {
29 return $this->getMockBuilder(ilGroupNameAsMailValidator::class)
30 ->disableOriginalConstructor()
31 ->onlyMethods(['validate'])
32 ->getMock();
33 }
Class ilGroupNameAsMailValidator.

Referenced by testAdminCourseNameIsAValidMailAddressType(), testAdminGroupNameIsAValidMailAddressTypes(), testFactoryWillReturnGroupAddressTypeForGroupName(), testFactoryWillReturnListAddressTypeForListName(), testFactoryWillReturnLoginOrEmailAddressAddressType(), testFactoryWillReturnRoleAddressType(), testMemberCourseNameIsAValidMailAddressType(), and testMemberGroupNameIsAValidMailAddressType().

+ Here is the caller graph for this function:

◆ getAddressTypeFactory()

ilMailAddressTypesTest::getAddressTypeFactory (   $groupNameValidatorMock)
private
Parameters
$groupNameValidatorMock
Returns
ilMailAddressTypeFactory
Exceptions
ReflectionException

Definition at line 40 of file ilMailAddressTypesTest.php.

41 {
42 $logger = $this->getMockBuilder(ilLogger::class)->disableOriginalConstructor()->getMock();
43 $rbacsystem = $this->getMockBuilder(ilRbacSystem::class)->disableOriginalConstructor()->getMock();
44 $rbacreview = $this->getMockBuilder(ilRbacReview::class)->disableOriginalConstructor()->getMock();
45 $addressTypeHelper = $this->getMockBuilder(ilMailAddressTypeHelper::class)->getMock();
46 $mailingLists = $this->getMockBuilder(ilMailingLists::class)->disableOriginalConstructor()->getMock();
47 $roleMailboxSearch = $this->getMockBuilder(ilRoleMailboxSearch::class)->disableOriginalConstructor()->getMock();
48
49 $mailAddressTypeFactory = new ilMailAddressTypeFactory(
50 $groupNameValidatorMock,
51 $logger,
52 $rbacsystem,
53 $rbacreview,
54 $addressTypeHelper,
55 $mailingLists,
56 $roleMailboxSearch
57 );
58
59 return $mailAddressTypeFactory;
60 }
Class ilMailAddressTypeFactory.

Referenced by testAdminCourseNameIsAValidMailAddressType(), testAdminGroupNameIsAValidMailAddressTypes(), testFactoryWillReturnGroupAddressTypeForGroupName(), testFactoryWillReturnListAddressTypeForListName(), testFactoryWillReturnLoginOrEmailAddressAddressType(), testFactoryWillReturnRoleAddressType(), testMemberCourseNameIsAValidMailAddressType(), and testMemberGroupNameIsAValidMailAddressType().

+ Here is the caller graph for this function:

◆ getWrappedAddressType()

ilMailAddressTypesTest::getWrappedAddressType ( ilMailAddressType  $type)
private
Parameters
ilMailAddressType$type
Returns
ilMailAddressType
Exceptions
ReflectionException

Definition at line 67 of file ilMailAddressTypesTest.php.

68 {
69 if ($type instanceof ilMailCachedAddressType) {
70 $refl = new ReflectionObject($type);
71 $inner = $refl->getProperty('inner');
72 $inner->setAccessible(true);
73
74 return $inner->getValue($type);
75 }
76
77 return $type;
78 }
Class ilMailCachedAddressType.
Interface ilMailAddressType.
$type

References $type.

Referenced by testAdminCourseNameIsAValidMailAddressType(), testAdminGroupNameIsAValidMailAddressTypes(), testFactoryWillReturnGroupAddressTypeForGroupName(), testFactoryWillReturnListAddressTypeForListName(), testFactoryWillReturnLoginOrEmailAddressAddressType(), testFactoryWillReturnRoleAddressType(), testMemberCourseNameIsAValidMailAddressType(), and testMemberGroupNameIsAValidMailAddressType().

+ Here is the caller graph for this function:

◆ setUp()

ilMailAddressTypesTest::setUp ( )

Reimplemented from ilMailBaseTest.

Definition at line 14 of file ilMailAddressTypesTest.php.

14 : void
15 {
16 if (!defined('ANONYMOUS_USER_ID')) {
17 define('ANONYMOUS_USER_ID', 13);
18 }
19
20 parent::setUp();
21 }

◆ testAddressCanBeValidatedFromLoginOrEmailAddressType()

ilMailAddressTypesTest::testAddressCanBeValidatedFromLoginOrEmailAddressType ( )
Exceptions
ReflectionException

Definition at line 278 of file ilMailAddressTypesTest.php.

278 : void
279 {
280 $logger = $this->getMockBuilder(ilLogger::class)->disableOriginalConstructor()->getMock();
281 $addressTypeHelper = $this->getMockBuilder(ilMailAddressTypeHelper::class)->getMock();
282
283 $addressTypeHelper->expects($this->atLeast(3))->method('getInstallationHost')->willReturn('ilias');
284 $addressTypeHelper->expects($this->exactly(2))->method('getUserIdByLogin')->willReturnOnConsecutiveCalls(
285 4711,
286 4711,
287 0
288 );
289
290 $addressTypeHelper->expects($this->any())->method('receivesInternalMailsOnly')->willReturnOnConsecutiveCalls(
291 true
292 );
293
294 $rbacsystem = $this->getMockBuilder(ilRbacSystem::class)->disableOriginalConstructor()->getMock();
295 $rbacsystem->expects($this->exactly(2))->method('checkAccessOfUser')->willReturnOnConsecutiveCalls(
296 true,
297 false
298 );
299
301 $addressTypeHelper,
302 new ilMailAddress('phpunit', 'ilias'),
303 $logger,
304 $rbacsystem
305 );
306 $this->assertTrue($type->validate(666));
307 $this->assertCount(0, $type->getErrors());
308
309 $this->assertFalse($type->validate(666));
310 $this->assertArrayHasKey(0, $type->getErrors());
311 $this->assertEquals('user_cant_receive_mail', $type->getErrors()[0]->getLanguageVariable());
312
314 $addressTypeHelper,
315 new ilMailAddress('mjansen', 'databay.de'),
316 $logger,
317 $rbacsystem
318 );
319 $this->assertTrue($type->validate(666));
320 $this->assertCount(0, $type->getErrors());
321 }
Class ilMailAddress.

References $type.

◆ testAdminCourseNameIsAValidMailAddressType()

ilMailAddressTypesTest::testAdminCourseNameIsAValidMailAddressType ( )
Exceptions
ReflectionException

Definition at line 174 of file ilMailAddressTypesTest.php.

174 : void
175 {
176 $groupNameValidatorMock = $this->createGroupNameAsValidatorMock();
177 $groupNameValidatorMock->method('validate')->willReturn(false);
178
179 $mailAddressTypeFactory = $this->getAddressTypeFactory($groupNameValidatorMock);
180
181 $result = $mailAddressTypeFactory->getByPrefix(new ilMailAddress('#il_crs_admin_98', ''), false);
182
183 $this->assertInstanceOf('ilMailRoleAddressType', $this->getWrappedAddressType($result));
184 }
$result
getAddressTypeFactory($groupNameValidatorMock)
getWrappedAddressType(ilMailAddressType $type)

References $result, createGroupNameAsValidatorMock(), getAddressTypeFactory(), and getWrappedAddressType().

+ Here is the call graph for this function:

◆ testAdminGroupNameIsAValidMailAddressTypes()

ilMailAddressTypesTest::testAdminGroupNameIsAValidMailAddressTypes ( )
Exceptions
ReflectionException

Definition at line 144 of file ilMailAddressTypesTest.php.

144 : void
145 {
146 $groupNameValidatorMock = $this->createGroupNameAsValidatorMock();
147 $groupNameValidatorMock->method('validate')->willReturn(false);
148
149 $mailAddressTypeFactory = $this->getAddressTypeFactory($groupNameValidatorMock);
150
151 $result = $mailAddressTypeFactory->getByPrefix(new ilMailAddress('#il_grp_admin_98', ''), false);
152
153 $this->assertInstanceOf('ilMailRoleAddressType', $this->getWrappedAddressType($result));
154 }

References $result, createGroupNameAsValidatorMock(), getAddressTypeFactory(), and getWrappedAddressType().

+ Here is the call graph for this function:

◆ testCacheOnlyResolvesAndValidatesRecipientsOnceIfCachingIsEnabled()

ilMailAddressTypesTest::testCacheOnlyResolvesAndValidatesRecipientsOnceIfCachingIsEnabled ( )
Exceptions
ReflectionException

Definition at line 633 of file ilMailAddressTypesTest.php.

633 : void
634 {
635 $origin = $this->getMockBuilder(ilMailAddressType::class)->getMock();
636
637 $origin->expects($this->once())->method('resolve');
638 $origin->expects($this->once())->method('validate');
639
640 $type = new ilMailCachedAddressType($origin, true);
641 $type->resolve();
642 $type->resolve();
643
644 $type->validate(6);
645 $type->validate(6);
646 }

References $type.

◆ testCacheResolvesAndValidatesRecipientsOnEveryCallIfCachingIsDisabled()

ilMailAddressTypesTest::testCacheResolvesAndValidatesRecipientsOnEveryCallIfCachingIsDisabled ( )
Exceptions
ReflectionException

Definition at line 651 of file ilMailAddressTypesTest.php.

651 : void
652 {
653 $origin = $this->getMockBuilder(ilMailAddressType::class)->getMock();
654
655 $origin->expects($this->exactly(3))->method('resolve');
656 $origin->expects($this->exactly(3))->method('validate');
657
658 $type = new ilMailCachedAddressType($origin, false);
659 $type->resolve();
660 $type->resolve();
661 $type->resolve();
662
663 $type->validate(6);
664 $type->validate(6);
665 $type->validate(6);
666 }

References $type.

◆ testFactoryWillReturnGroupAddressTypeForGroupName()

ilMailAddressTypesTest::testFactoryWillReturnGroupAddressTypeForGroupName ( )
Exceptions
ReflectionException

Definition at line 98 of file ilMailAddressTypesTest.php.

98 : void
99 {
100 $groupNameValidatorMock = $this->createGroupNameAsValidatorMock();
101 $groupNameValidatorMock->method('validate')->willReturn(true);
102
103 $mailAddressTypeFactory = $this->getAddressTypeFactory($groupNameValidatorMock);
104
105 $result = $mailAddressTypeFactory->getByPrefix(new ilMailAddress('#MyGroup', ''), false);
106
107 $this->assertInstanceOf('ilMailGroupAddressType', $this->getWrappedAddressType($result));
108 }

References $result, createGroupNameAsValidatorMock(), getAddressTypeFactory(), and getWrappedAddressType().

+ Here is the call graph for this function:

◆ testFactoryWillReturnListAddressTypeForListName()

ilMailAddressTypesTest::testFactoryWillReturnListAddressTypeForListName ( )
Exceptions
ReflectionException

Definition at line 83 of file ilMailAddressTypesTest.php.

83 : void
84 {
85 $groupNameValidatorMock = $this->createGroupNameAsValidatorMock();
86 $groupNameValidatorMock->method('validate')->willReturn(true);
87
88 $mailAddressTypeFactory = $this->getAddressTypeFactory($groupNameValidatorMock);
89
90 $result = $mailAddressTypeFactory->getByPrefix(new ilMailAddress('#il_ml_4711', ''), false);
91
92 $this->assertInstanceOf('ilMailMailingListAddressType', $this->getWrappedAddressType($result));
93 }

References $result, createGroupNameAsValidatorMock(), getAddressTypeFactory(), and getWrappedAddressType().

+ Here is the call graph for this function:

◆ testFactoryWillReturnLoginOrEmailAddressAddressType()

ilMailAddressTypesTest::testFactoryWillReturnLoginOrEmailAddressAddressType ( )
Exceptions
ReflectionException

Definition at line 113 of file ilMailAddressTypesTest.php.

113 : void
114 {
115 $groupNameValidatorMock = $this->createGroupNameAsValidatorMock();
116 $groupNameValidatorMock->method('validate')->willReturn(false);
117
118 $mailAddressTypeFactory = $this->getAddressTypeFactory($groupNameValidatorMock);
119
120 $result = $mailAddressTypeFactory->getByPrefix(new ilMailAddress('phpunit', ''), false);
121
122 $this->assertInstanceOf('ilMailLoginOrEmailAddressAddressType', $this->getWrappedAddressType($result));
123 }

References $result, createGroupNameAsValidatorMock(), getAddressTypeFactory(), and getWrappedAddressType().

+ Here is the call graph for this function:

◆ testFactoryWillReturnRoleAddressType()

ilMailAddressTypesTest::testFactoryWillReturnRoleAddressType ( )
Exceptions
ReflectionException

Definition at line 128 of file ilMailAddressTypesTest.php.

128 : void
129 {
130 $groupNameValidatorMock = $this->createGroupNameAsValidatorMock();
131 $groupNameValidatorMock->method('validate')->willReturn(false);
132
133 $mailAddressTypeFactory = $this->getAddressTypeFactory($groupNameValidatorMock);
134
135 $result = $mailAddressTypeFactory->getByPrefix(new ilMailAddress('#member', ''), false);
136
137 $this->assertInstanceOf('ilMailRoleAddressType', $this->getWrappedAddressType($result));
138 }

References $result, createGroupNameAsValidatorMock(), getAddressTypeFactory(), and getWrappedAddressType().

+ Here is the call graph for this function:

◆ testMailingListAddressCanBeValidated()

ilMailAddressTypesTest::testMailingListAddressCanBeValidated ( )
Exceptions
ReflectionException

Definition at line 462 of file ilMailAddressTypesTest.php.

462 : void
463 {
464 $lists = $this->getMockBuilder(ilMailingLists::class)->disableOriginalConstructor()->onlyMethods([
465 'mailingListExists'
466 ])->getMock();
467 $lists->expects($this->exactly(2))->method('mailingListExists')->with('#il_ml_4711')->willReturnOnConsecutiveCalls(
468 true,
469 false
470 );
471 $logger = $this->getMockBuilder(ilLogger::class)->disableOriginalConstructor()->getMock();
472 $addressTypeHelper = $this->getMockBuilder(ilMailAddressTypeHelper::class)->getMock();
473
475 $addressTypeHelper,
476 new ilMailAddress('#il_ml_4711', ''),
477 $logger,
478 $lists
479 );
480
481 $this->assertTrue($type->validate(666));
482 $this->assertCount(0, $type->getErrors());
483
484 $this->assertFalse($type->validate(666));
485 $this->assertCount(1, $type->getErrors());
486 $this->assertArrayHasKey(0, $type->getErrors());
487 $this->assertEquals('mail_no_valid_mailing_list', $type->getErrors()[0]->getLanguageVariable());
488 }
Class ilMailMailingListAddressType.

References $type.

◆ testMemberCourseNameIsAValidMailAddressType()

ilMailAddressTypesTest::testMemberCourseNameIsAValidMailAddressType ( )
Exceptions
ReflectionException

Definition at line 189 of file ilMailAddressTypesTest.php.

189 : void
190 {
191 $groupNameValidatorMock = $this->createGroupNameAsValidatorMock();
192 $groupNameValidatorMock->method('validate')->willReturn(false);
193
194 $mailAddressTypeFactory = $this->getAddressTypeFactory($groupNameValidatorMock);
195
196 $result = $mailAddressTypeFactory->getByPrefix(new ilMailAddress('#il_crs_member_98', ''), false);
197
198 $this->assertInstanceOf('ilMailRoleAddressType', $this->getWrappedAddressType($result));
199 }

References $result, createGroupNameAsValidatorMock(), getAddressTypeFactory(), and getWrappedAddressType().

+ Here is the call graph for this function:

◆ testMemberGroupNameIsAValidMailAddressType()

ilMailAddressTypesTest::testMemberGroupNameIsAValidMailAddressType ( )
Exceptions
ReflectionException

Definition at line 159 of file ilMailAddressTypesTest.php.

159 : void
160 {
161 $groupNameValidatorMock = $this->createGroupNameAsValidatorMock();
162 $groupNameValidatorMock->method('validate')->willReturn(false);
163
164 $mailAddressTypeFactory = $this->getAddressTypeFactory($groupNameValidatorMock);
165
166 $result = $mailAddressTypeFactory->getByPrefix(new ilMailAddress('#il_grp_member_98', ''), false);
167
168 $this->assertInstanceOf('ilMailRoleAddressType', $this->getWrappedAddressType($result));
169 }

References $result, createGroupNameAsValidatorMock(), getAddressTypeFactory(), and getWrappedAddressType().

+ Here is the call graph for this function:

◆ testNoUserIdCanBeResolvedFromEmailAddress()

ilMailAddressTypesTest::testNoUserIdCanBeResolvedFromEmailAddress ( )
Exceptions
ReflectionException

Definition at line 254 of file ilMailAddressTypesTest.php.

254 : void
255 {
256 $logger = $this->getMockBuilder(ilLogger::class)->disableOriginalConstructor()->getMock();
257 $rbacsystem = $this->getMockBuilder(ilRbacSystem::class)->disableOriginalConstructor()->getMock();
258 $addressTypeHelper = $this->getMockBuilder(ilMailAddressTypeHelper::class)->getMock();
259
260 $addressTypeHelper->expects($this->once())->method('getInstallationHost')->willReturn('ilias');
261 $addressTypeHelper->expects($this->once())->method('getUserIdByLogin')->willReturn(0);
262
264 $addressTypeHelper,
265 new ilMailAddress('mjansen', 'databay.de'),
266 $logger,
267 $rbacsystem
268 );
269
270 $usrIds = $type->resolve();
271
272 $this->assertCount(0, $usrIds);
273 }

References $type.

◆ testNoUserIdCanBeResolvedFromUnknownLoginAddress()

ilMailAddressTypesTest::testNoUserIdCanBeResolvedFromUnknownLoginAddress ( )
Exceptions
ReflectionException

Definition at line 230 of file ilMailAddressTypesTest.php.

230 : void
231 {
232 $logger = $this->getMockBuilder(ilLogger::class)->disableOriginalConstructor()->getMock();
233 $rbacsystem = $this->getMockBuilder(ilRbacSystem::class)->disableOriginalConstructor()->getMock();
234 $addressTypeHelper = $this->getMockBuilder(ilMailAddressTypeHelper::class)->getMock();
235
236 $addressTypeHelper->expects($this->once())->method('getInstallationHost')->willReturn('ilias');
237 $addressTypeHelper->expects($this->once())->method('getUserIdByLogin')->willReturn(0);
238
240 $addressTypeHelper,
241 new ilMailAddress('phpunit', 'ilias'),
242 $logger,
243 $rbacsystem
244 );
245
246 $usrIds = $type->resolve();
247
248 $this->assertCount(0, $usrIds);
249 }

References $type.

◆ testNoUserIdsCanBeResolvedFromInvalidRoleAddress()

ilMailAddressTypesTest::testNoUserIdsCanBeResolvedFromInvalidRoleAddress ( )
Exceptions
ReflectionException

Definition at line 525 of file ilMailAddressTypesTest.php.

525 : void
526 {
527 $logger = $this->getMockBuilder(ilLogger::class)->disableOriginalConstructor()->getMock();
528 $rbacsystem = $this->getMockBuilder(ilRbacSystem::class)->disableOriginalConstructor()->getMock();
529 $rbacreview = $this->getMockBuilder(ilRbacReview::class)->disableOriginalConstructor()->onlyMethods(['assignedUsers'])->getMock();
530 $addressTypeHelper = $this->getMockBuilder(ilMailAddressTypeHelper::class)->getMock();
531 $roleMailboxSearch = $this->getMockBuilder(ilRoleMailboxSearch::class)->disableOriginalConstructor()->onlyMethods(['searchRoleIdsByAddressString'])->getMock();
532
533 $roleMailboxSearch->expects($this->once())->method('searchRoleIdsByAddressString')->willReturn([]);
534 $rbacreview->expects($this->never())->method('assignedUsers');
535
537 $addressTypeHelper,
538 new ilMailAddress('phpunit', 'ilias'),
539 $roleMailboxSearch,
540 $logger,
541 $rbacsystem,
542 $rbacreview
543 );
544
545 $usrIds = $type->resolve();
546
547 $this->assertCount(0, $usrIds);
548 }
Class ilMailRoleAddressType.

References $type.

◆ testPermissionsAreCheckedForRegularUsersWhenValidatingGlobalRoleAddresses()

ilMailAddressTypesTest::testPermissionsAreCheckedForRegularUsersWhenValidatingGlobalRoleAddresses ( )
Exceptions
ReflectionException

Definition at line 580 of file ilMailAddressTypesTest.php.

580 : void
581 {
582 $logger = $this->getMockBuilder(ilLogger::class)->disableOriginalConstructor()->getMock();
583 $rbacsystem = $this->getMockBuilder(ilRbacSystem::class)->disableOriginalConstructor()->onlyMethods(['checkAccessOfUser'])->getMock();
584 $rbacreview = $this->getMockBuilder(ilRbacReview::class)->disableOriginalConstructor()->onlyMethods(['isGlobalRole'])->getMock();
585 $addressTypeHelper = $this->getMockBuilder(ilMailAddressTypeHelper::class)->getMock();
586 $roleMailboxSearch = $this->getMockBuilder(ilRoleMailboxSearch::class)->disableOriginalConstructor()->onlyMethods(['searchRoleIdsByAddressString'])->getMock();
587
588 $roleMailboxSearch->expects($this->exactly(4))->method('searchRoleIdsByAddressString')->willReturnOnConsecutiveCalls(
589 [1],
590 [],
591 [1, 2],
592 [1]
593 );
594 $rbacsystem->expects($this->exactly(4))->method('checkAccessOfUser')->willReturnOnConsecutiveCalls(
595 false,
596 true,
597 true,
598 true
599 );
600 $rbacreview->expects($this->once())->method('isGlobalRole')->with(1)->willReturn(true);
601
603 $addressTypeHelper,
604 new ilMailAddress('phpunit', 'ilias'),
605 $roleMailboxSearch,
606 $logger,
607 $rbacsystem,
608 $rbacreview
609 );
610
611 $this->assertFalse($type->validate(4711));
612 $this->assertCount(1, $type->getErrors());
613 $this->assertArrayHasKey(0, $type->getErrors());
614 $this->assertEquals('mail_to_global_roles_not_allowed', $type->getErrors()[0]->getLanguageVariable());
615
616 $this->assertFalse($type->validate(4711));
617 $this->assertCount(1, $type->getErrors());
618 $this->assertArrayHasKey(0, $type->getErrors());
619 $this->assertEquals('mail_recipient_not_found', $type->getErrors()[0]->getLanguageVariable());
620
621 $this->assertFalse($type->validate(4711));
622 $this->assertCount(1, $type->getErrors());
623 $this->assertArrayHasKey(0, $type->getErrors());
624 $this->assertEquals('mail_multiple_role_recipients_found', $type->getErrors()[0]->getLanguageVariable());
625
626 $this->assertTrue($type->validate(4711));
627 $this->assertCount(0, $type->getErrors());
628 }

References $type.

◆ testUserIdCanBeResolvedFromLoginAddress()

ilMailAddressTypesTest::testUserIdCanBeResolvedFromLoginAddress ( )
Exceptions
ReflectionException

Definition at line 204 of file ilMailAddressTypesTest.php.

204 : void
205 {
206 $logger = $this->getMockBuilder(ilLogger::class)->disableOriginalConstructor()->getMock();
207 $rbacsystem = $this->getMockBuilder(ilRbacSystem::class)->disableOriginalConstructor()->getMock();
208 $addressTypeHelper = $this->getMockBuilder(ilMailAddressTypeHelper::class)->getMock();
209
210 $addressTypeHelper->expects($this->once())->method('getInstallationHost')->willReturn('ilias');
211 $addressTypeHelper->expects($this->once())->method('getUserIdByLogin')->willReturn(4711);
212
214 $addressTypeHelper,
215 new ilMailAddress('phpunit', 'ilias'),
216 $logger,
217 $rbacsystem
218 );
219
220 $usrIds = $type->resolve();
221
222 $this->assertCount(1, $usrIds);
223 $this->assertArrayHasKey(0, $usrIds);
224 $this->assertEquals(4711, $usrIds[0]);
225 }

References $type.

◆ testUserIdsCanBeResolvedFromGroupNameAddress()

ilMailAddressTypesTest::testUserIdsCanBeResolvedFromGroupNameAddress ( )
Exceptions
ReflectionException

Definition at line 326 of file ilMailAddressTypesTest.php.

326 : void
327 {
328 $logger = $this->getMockBuilder(ilLogger::class)->disableOriginalConstructor()->getMock();
329 $addressTypeHelper = $this->getMockBuilder(ilMailAddressTypeHelper::class)->getMock();
330
331 $group = $this->getMockBuilder(ilObjGroup::class)->disableOriginalConstructor()->onlyMethods(['getGroupMemberIds'])->getMock();
332 $group->expects($this->once())->method('getGroupMemberIds')->willReturn([666, 777]);
333
334 $addressTypeHelper->expects($this->once())->method('getGroupObjIdByTitle')->willReturn(1);
335 $addressTypeHelper->expects($this->once())->method('getAllRefIdsForObjId')->with(1)->willReturn([2]);
336 $addressTypeHelper->expects($this->once())->method('getInstanceByRefId')->with(2)->willReturn($group);
337
339 $addressTypeHelper,
340 new ilMailAddress('#PhpUnit', ''),
341 $logger
342 );
343
344 $usrIds = $type->resolve();
345
346 $this->assertCount(2, $usrIds);
347 }
Class ilMailGroupAddressType.

References $type.

◆ testUserIdsCanBeResolvedFromMailingListAddress()

ilMailAddressTypesTest::testUserIdsCanBeResolvedFromMailingListAddress ( )
Exceptions
ReflectionException

Definition at line 415 of file ilMailAddressTypesTest.php.

415 : void
416 {
417 $logger = $this->getMockBuilder(ilLogger::class)->disableOriginalConstructor()->getMock();
418 $addressTypeHelper = $this->getMockBuilder(ilMailAddressTypeHelper::class)->getMock();
419
420 $list = $this->getMockBuilder(ilMailingList::class)->disableOriginalConstructor()->onlyMethods([
421 'getAssignedEntries'
422 ])->getMock();
423 $list->expects($this->exactly(2))->method('getAssignedEntries')->willReturnOnConsecutiveCalls(
424 [['usr_id' => 1], ['usr_id' => 2], ['usr_id' => 3]],
425 []
426 );
427
428 $lists = $this->getMockBuilder(ilMailingLists::class)->disableOriginalConstructor()->onlyMethods([
429 'mailingListExists',
430 'getCurrentMailingList'
431 ])->getMock();
432 $lists->expects($this->exactly(3))->method('mailingListExists')->with('#il_ml_4711')->willReturnOnConsecutiveCalls(
433 true,
434 true,
435 false
436 );
437 $lists->expects($this->exactly(2))->method('getCurrentMailingList')->willReturn($list);
438
440 $addressTypeHelper,
441 new ilMailAddress('#il_ml_4711', ''),
442 $logger,
443 $lists
444 );
445
446 $usrIds = $type->resolve();
447
448 $this->assertCount(3, $usrIds);
449
450 $usrIds = $type->resolve();
451
452 $this->assertCount(0, $usrIds);
453
454 $usrIds = $type->resolve();
455
456 $this->assertCount(0, $usrIds);
457 }

References $type.

◆ testUserIdsCanBeResolvedFromRoleAddress()

ilMailAddressTypesTest::testUserIdsCanBeResolvedFromRoleAddress ( )
Exceptions
ReflectionException

Definition at line 493 of file ilMailAddressTypesTest.php.

493 : void
494 {
495 $logger = $this->getMockBuilder(ilLogger::class)->disableOriginalConstructor()->getMock();
496 $rbacsystem = $this->getMockBuilder(ilRbacSystem::class)->disableOriginalConstructor()->getMock();
497 $rbacreview = $this->getMockBuilder(ilRbacReview::class)->disableOriginalConstructor()->onlyMethods(['assignedUsers'])->getMock();
498 $addressTypeHelper = $this->getMockBuilder(ilMailAddressTypeHelper::class)->getMock();
499 $roleMailboxSearch = $this->getMockBuilder(ilRoleMailboxSearch::class)->disableOriginalConstructor()->onlyMethods(['searchRoleIdsByAddressString'])->getMock();
500
501 $roleMailboxSearch->expects($this->once())->method('searchRoleIdsByAddressString')->willReturn([1, 2, 3]);
502 $rbacreview->expects($this->exactly(3))->method('assignedUsers')->willReturnOnConsecutiveCalls(
503 [4, 5, 6],
504 [7, 8],
505 [9]
506 );
507
509 $addressTypeHelper,
510 new ilMailAddress('phpunit', 'ilias'),
511 $roleMailboxSearch,
512 $logger,
513 $rbacsystem,
514 $rbacreview
515 );
516
517 $usrIds = $type->resolve();
518
519 $this->assertCount(6, $usrIds);
520 }

References $type.

◆ testUserIdsCannotBeResolvedFromNonExistingGroupNameAddress()

ilMailAddressTypesTest::testUserIdsCannotBeResolvedFromNonExistingGroupNameAddress ( )
Exceptions
ReflectionException

Definition at line 352 of file ilMailAddressTypesTest.php.

352 : void
353 {
354 $logger = $this->getMockBuilder(ilLogger::class)->disableOriginalConstructor()->getMock();
355 $addressTypeHelper = $this->getMockBuilder(ilMailAddressTypeHelper::class)->getMock();
356
357 $group = $this->getMockBuilder(ilObjGroup::class)->disableOriginalConstructor()->onlyMethods(['getGroupMemberIds'])->getMock();
358 $group->expects($this->never())->method('getGroupMemberIds');
359
360 $addressTypeHelper->expects($this->once())->method('getGroupObjIdByTitle')->willReturn(0);
361 $addressTypeHelper->expects($this->once())->method('getAllRefIdsForObjId')->with(0)->willReturn([]);
362 $addressTypeHelper->expects($this->never())->method('getInstanceByRefId');
363
365 $addressTypeHelper,
366 new ilMailAddress('#PhpUnit', ''),
367 $logger
368 );
369
370 $usrIds = $type->resolve();
371
372 $this->assertCount(0, $usrIds);
373 }

References $type.

◆ testValidationFailsForNonExistingGroupNameAddress()

ilMailAddressTypesTest::testValidationFailsForNonExistingGroupNameAddress ( )
Exceptions
ReflectionException

Definition at line 378 of file ilMailAddressTypesTest.php.

378 : void
379 {
380 $logger = $this->getMockBuilder(ilLogger::class)->disableOriginalConstructor()->getMock();
381 $addressTypeHelper = $this->getMockBuilder(ilMailAddressTypeHelper::class)->getMock();
382
383 $addressTypeHelper->expects($this->once())->method('doesGroupNameExists')->with('PhpUnit')->willReturn(false);
384
386 $addressTypeHelper,
387 new ilMailAddress('#PhpUnit', ''),
388 $logger
389 );
390 $this->assertFalse($type->validate(666));
391 }

References $type.

◆ testValidationForAnonymousUserAsSystemActorSucceedsAlwaysForGlobalRoleAddresses()

ilMailAddressTypesTest::testValidationForAnonymousUserAsSystemActorSucceedsAlwaysForGlobalRoleAddresses ( )
Exceptions
ReflectionException

Definition at line 553 of file ilMailAddressTypesTest.php.

553 : void
554 {
555 $logger = $this->getMockBuilder(ilLogger::class)->disableOriginalConstructor()->getMock();
556 $rbacsystem = $this->getMockBuilder(ilRbacSystem::class)->disableOriginalConstructor()->getMock();
557 $rbacreview = $this->getMockBuilder(ilRbacReview::class)->disableOriginalConstructor()->getMock();
558 $addressTypeHelper = $this->getMockBuilder(ilMailAddressTypeHelper::class)->getMock();
559 $roleMailboxSearch = $this->getMockBuilder(ilRoleMailboxSearch::class)->disableOriginalConstructor()->onlyMethods(['searchRoleIdsByAddressString'])->getMock();
560
561 $roleMailboxSearch->expects($this->once())->method('searchRoleIdsByAddressString')->willReturnOnConsecutiveCalls([1]);
562 $rbacsystem->expects($this->never())->method('checkAccessOfUser');
563
565 $addressTypeHelper,
566 new ilMailAddress('phpunit', 'ilias'),
567 $roleMailboxSearch,
568 $logger,
569 $rbacsystem,
570 $rbacreview
571 );
572
573 $this->assertTrue($type->validate(ANONYMOUS_USER_ID));
574 $this->assertCount(0, $type->getErrors());
575 }
const ANONYMOUS_USER_ID
Definition: constants.php:25

References $type, and ANONYMOUS_USER_ID.

◆ testValidationSucceedsForExistingGroupName()

ilMailAddressTypesTest::testValidationSucceedsForExistingGroupName ( )
Exceptions
ReflectionException

Definition at line 396 of file ilMailAddressTypesTest.php.

396 : void
397 {
398 $logger = $this->getMockBuilder(ilLogger::class)->disableOriginalConstructor()->getMock();
399 $addressTypeHelper = $this->getMockBuilder(ilMailAddressTypeHelper::class)->getMock();
400
401 $addressTypeHelper->expects($this->once())->method('doesGroupNameExists')->with('PhpUnit')->willReturn(true);
402
404 $addressTypeHelper,
405 new ilMailAddress('#PhpUnit', ''),
406 $logger
407 );
408 $this->assertTrue($type->validate(666));
409 }

References $type.


The documentation for this class was generated from the following file: