ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ($name, $value)
 
 assertException ($exception_class)
 

Detailed Description

Member Function Documentation

◆ createGroupNameAsValidatorMock()

ilMailAddressTypesTest::createGroupNameAsValidatorMock ( )
private
Returns
PHPUnit_Framework_MockObject_MockObject|\ilGroupNameAsMailValidator

Definition at line 25 of file ilMailAddressTypesTest.php.

26 {
27 return $this->getMockBuilder(\ilGroupNameAsMailValidator::class)
28 ->disableOriginalConstructor()
29 ->setMethods(array('validate'))
30 ->getMock();
31 }

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

Definition at line 37 of file ilMailAddressTypesTest.php.

38 {
39 $logger = $this->getMockBuilder(\ilLogger::class)->disableOriginalConstructor()->getMock();
40 $rbacsystem = $this->getMockBuilder(\ilRbacSystem::class)->disableOriginalConstructor()->getMock();
41 $rbacreview = $this->getMockBuilder(\ilRbacReview::class)->disableOriginalConstructor()->getMock();
42 $addressTypeHelper = $this->getMockBuilder(\ilMailAddressTypeHelper::class)->getMock();
43 $mailingLists = $this->getMockBuilder(\ilMailingLists::class)->disableOriginalConstructor()->getMock();
44 $roleMailboxSearch = $this->getMockBuilder(\ilRoleMailboxSearch::class)->disableOriginalConstructor()->getMock();
45
46 $mailAddressTypeFactory = new ilMailAddressTypeFactory(
47 $groupNameValidatorMock,
48 $logger,
49 $rbacsystem,
50 $rbacreview,
51 $addressTypeHelper,
52 $mailingLists,
53 $roleMailboxSearch
54 );
55
56 return $mailAddressTypeFactory;
57 }
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

Definition at line 63 of file ilMailAddressTypesTest.php.

64 {
65 if ($type instanceof \ilMailCachedAddressType) {
66 $refl = new \ReflectionObject($type);
67 $inner = $refl->getProperty('inner');
68 $inner->setAccessible(true);
69
70 return $inner->getValue($type);
71 }
72
73 return $type;
74 }
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 13 of file ilMailAddressTypesTest.php.

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

◆ testAddressCanBeValidatedFromLoginOrEmailAddressType()

ilMailAddressTypesTest::testAddressCanBeValidatedFromLoginOrEmailAddressType ( )

Definition at line 273 of file ilMailAddressTypesTest.php.

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

References $type.

◆ testAdminCourseNameIsAValidMailAddressType()

ilMailAddressTypesTest::testAdminCourseNameIsAValidMailAddressType ( )

Definition at line 169 of file ilMailAddressTypesTest.php.

170 {
171 $groupNameValidatorMock = $this->createGroupNameAsValidatorMock();
172 $groupNameValidatorMock->method('validate')->willReturn(false);
173
174 $mailAddressTypeFactory = $this->getAddressTypeFactory($groupNameValidatorMock);
175
176 $result = $mailAddressTypeFactory->getByPrefix(new \ilMailAddress('#il_crs_admin_98', ''), false);
177
178 $this->assertInstanceOf('ilMailRoleAddressType', $this->getWrappedAddressType($result));
179 }
$result
getAddressTypeFactory($groupNameValidatorMock)
getWrappedAddressType(\ilMailAddressType $type)

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

+ Here is the call graph for this function:

◆ testAdminGroupNameIsAValidMailAddressTypes()

ilMailAddressTypesTest::testAdminGroupNameIsAValidMailAddressTypes ( )

Definition at line 139 of file ilMailAddressTypesTest.php.

140 {
141 $groupNameValidatorMock = $this->createGroupNameAsValidatorMock();
142 $groupNameValidatorMock->method('validate')->willReturn(false);
143
144 $mailAddressTypeFactory = $this->getAddressTypeFactory($groupNameValidatorMock);
145
146 $result = $mailAddressTypeFactory->getByPrefix(new \ilMailAddress('#il_grp_admin_98', ''), false);
147
148 $this->assertInstanceOf('ilMailRoleAddressType', $this->getWrappedAddressType($result));
149 }

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

+ Here is the call graph for this function:

◆ testCacheOnlyResolvesAndValidatesRecipientsOnceIfCachingIsEnabled()

ilMailAddressTypesTest::testCacheOnlyResolvesAndValidatesRecipientsOnceIfCachingIsEnabled ( )

Definition at line 621 of file ilMailAddressTypesTest.php.

622 {
623 $origin = $this->getMockBuilder(\ilMailAddressType::class)->getMock();
624
625 $origin->expects($this->once())->method('resolve');
626 $origin->expects($this->once())->method('validate');
627
628 $type = new \ilMailCachedAddressType($origin, true);
629 $type->resolve();
630 $type->resolve();
631
632 $type->validate(6);
633 $type->validate(6);
634 }
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.

References $type, and Sabre\Event\once().

+ Here is the call graph for this function:

◆ testCacheResolvesAndValidatesRecipientsOnEveryCallIfCachingIsDisabled()

ilMailAddressTypesTest::testCacheResolvesAndValidatesRecipientsOnEveryCallIfCachingIsDisabled ( )

Definition at line 639 of file ilMailAddressTypesTest.php.

640 {
641 $origin = $this->getMockBuilder(\ilMailAddressType::class)->getMock();
642
643 $origin->expects($this->exactly(3))->method('resolve');
644 $origin->expects($this->exactly(3))->method('validate');
645
646 $type = new \ilMailCachedAddressType($origin, false);
647 $type->resolve();
648 $type->resolve();
649 $type->resolve();
650
651 $type->validate(6);
652 $type->validate(6);
653 $type->validate(6);
654 }

References $type.

◆ testFactoryWillReturnGroupAddressTypeForGroupName()

ilMailAddressTypesTest::testFactoryWillReturnGroupAddressTypeForGroupName ( )

Definition at line 94 of file ilMailAddressTypesTest.php.

95 {
96 $groupNameValidatorMock = $this->createGroupNameAsValidatorMock();
97 $groupNameValidatorMock->method('validate')->willReturn(true);
98
99 $mailAddressTypeFactory = $this->getAddressTypeFactory($groupNameValidatorMock);
100
101 $result = $mailAddressTypeFactory->getByPrefix(new \ilMailAddress('#MyGroup', ''), false);
102
103 $this->assertInstanceOf('ilMailGroupAddressType', $this->getWrappedAddressType($result));
104 }

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

+ Here is the call graph for this function:

◆ testFactoryWillReturnListAddressTypeForListName()

ilMailAddressTypesTest::testFactoryWillReturnListAddressTypeForListName ( )

Definition at line 79 of file ilMailAddressTypesTest.php.

80 {
81 $groupNameValidatorMock = $this->createGroupNameAsValidatorMock();
82 $groupNameValidatorMock->method('validate')->willReturn(true);
83
84 $mailAddressTypeFactory = $this->getAddressTypeFactory($groupNameValidatorMock);
85
86 $result = $mailAddressTypeFactory->getByPrefix(new \ilMailAddress('#il_ml_4711', ''), false);
87
88 $this->assertInstanceOf('ilMailMailingListAddressType', $this->getWrappedAddressType($result));
89 }

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

+ Here is the call graph for this function:

◆ testFactoryWillReturnLoginOrEmailAddressAddressType()

ilMailAddressTypesTest::testFactoryWillReturnLoginOrEmailAddressAddressType ( )

Definition at line 109 of file ilMailAddressTypesTest.php.

110 {
111 $groupNameValidatorMock = $this->createGroupNameAsValidatorMock();
112 $groupNameValidatorMock->method('validate')->willReturn(false);
113
114 $mailAddressTypeFactory = $this->getAddressTypeFactory($groupNameValidatorMock);
115
116 $result = $mailAddressTypeFactory->getByPrefix(new \ilMailAddress('phpunit', ''), false);
117
118 $this->assertInstanceOf('ilMailLoginOrEmailAddressAddressType', $this->getWrappedAddressType($result));
119 }

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

+ Here is the call graph for this function:

◆ testFactoryWillReturnRoleAddressType()

ilMailAddressTypesTest::testFactoryWillReturnRoleAddressType ( )

Definition at line 124 of file ilMailAddressTypesTest.php.

125 {
126 $groupNameValidatorMock = $this->createGroupNameAsValidatorMock();
127 $groupNameValidatorMock->method('validate')->willReturn(false);
128
129 $mailAddressTypeFactory = $this->getAddressTypeFactory($groupNameValidatorMock);
130
131 $result = $mailAddressTypeFactory->getByPrefix(new \ilMailAddress('#member', ''), false);
132
133 $this->assertInstanceOf('ilMailRoleAddressType', $this->getWrappedAddressType($result));
134 }

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

+ Here is the call graph for this function:

◆ testMailingListAddressCanBeValidated()

ilMailAddressTypesTest::testMailingListAddressCanBeValidated ( )

Definition at line 455 of file ilMailAddressTypesTest.php.

456 {
457 $lists = $this->getMockBuilder(\ilMailingLists::class)->disableOriginalConstructor()->setMethods([
458 'mailingListExists'
459 ])->getMock();
460 $lists->expects($this->exactly(2))->method('mailingListExists')->with('#il_ml_4711')->willReturnOnConsecutiveCalls(
461 true,
462 false
463 );
464 $logger = $this->getMockBuilder(\ilLogger::class)->disableOriginalConstructor()->getMock();
465 $addressTypeHelper = $this->getMockBuilder(\ilMailAddressTypeHelper::class)->getMock();
466
467 $type = new \ilMailMailingListAddressType(
468 $addressTypeHelper,
469 new \ilMailAddress('#il_ml_4711', ''),
470 $logger,
471 $lists
472 );
473
474 $this->assertTrue($type->validate(666));
475 $this->assertCount(0, $type->getErrors());
476
477 $this->assertFalse($type->validate(666));
478 $this->assertCount(1, $type->getErrors());
479 $this->assertArrayHasKey(0, $type->getErrors());
480 $this->assertEquals('mail_no_valid_mailing_list', $type->getErrors()[0]->getLanguageVariable());
481 }

References $type.

◆ testMemberCourseNameIsAValidMailAddressType()

ilMailAddressTypesTest::testMemberCourseNameIsAValidMailAddressType ( )

Definition at line 184 of file ilMailAddressTypesTest.php.

185 {
186 $groupNameValidatorMock = $this->createGroupNameAsValidatorMock();
187 $groupNameValidatorMock->method('validate')->willReturn(false);
188
189 $mailAddressTypeFactory = $this->getAddressTypeFactory($groupNameValidatorMock);
190
191 $result = $mailAddressTypeFactory->getByPrefix(new \ilMailAddress('#il_crs_member_98', ''), false);
192
193 $this->assertInstanceOf('ilMailRoleAddressType', $this->getWrappedAddressType($result));
194 }

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

+ Here is the call graph for this function:

◆ testMemberGroupNameIsAValidMailAddressType()

ilMailAddressTypesTest::testMemberGroupNameIsAValidMailAddressType ( )

Definition at line 154 of file ilMailAddressTypesTest.php.

155 {
156 $groupNameValidatorMock = $this->createGroupNameAsValidatorMock();
157 $groupNameValidatorMock->method('validate')->willReturn(false);
158
159 $mailAddressTypeFactory = $this->getAddressTypeFactory($groupNameValidatorMock);
160
161 $result = $mailAddressTypeFactory->getByPrefix(new \ilMailAddress('#il_grp_member_98', ''), false);
162
163 $this->assertInstanceOf('ilMailRoleAddressType', $this->getWrappedAddressType($result));
164 }

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

+ Here is the call graph for this function:

◆ testNoUserIdCanBeResolvedFromEmailAddress()

ilMailAddressTypesTest::testNoUserIdCanBeResolvedFromEmailAddress ( )

Definition at line 249 of file ilMailAddressTypesTest.php.

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

References $type, and Sabre\Event\once().

+ Here is the call graph for this function:

◆ testNoUserIdCanBeResolvedFromUnknownLoginAddress()

ilMailAddressTypesTest::testNoUserIdCanBeResolvedFromUnknownLoginAddress ( )

Definition at line 225 of file ilMailAddressTypesTest.php.

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

References $type, and Sabre\Event\once().

+ Here is the call graph for this function:

◆ testNoUserIdsCanBeResolvedFromInvalidRoleAddress()

ilMailAddressTypesTest::testNoUserIdsCanBeResolvedFromInvalidRoleAddress ( )

Definition at line 518 of file ilMailAddressTypesTest.php.

519 {
520 $logger = $this->getMockBuilder(\ilLogger::class)->disableOriginalConstructor()->getMock();
521 $rbacsystem = $this->getMockBuilder(\ilRbacSystem::class)->disableOriginalConstructor()->getMock();
522 $rbacreview = $this->getMockBuilder(\ilRbacReview::class)->disableOriginalConstructor()->setMethods(['assignedUsers'])->getMock();
523 $addressTypeHelper = $this->getMockBuilder(\ilMailAddressTypeHelper::class)->getMock();
524 $roleMailboxSearch = $this->getMockBuilder(\ilRoleMailboxSearch::class)->disableOriginalConstructor()->setMethods(['searchRoleIdsByAddressString'])->getMock();
525
526 $roleMailboxSearch->expects($this->once())->method('searchRoleIdsByAddressString')->willReturn([]);
527 $rbacreview->expects($this->never())->method('assignedUsers');
528
529 $type = new \ilMailRoleAddressType(
530 $addressTypeHelper,
531 new \ilMailAddress('phpunit', 'ilias'),
532 $roleMailboxSearch,
533 $logger,
534 $rbacsystem,
535 $rbacreview
536 );
537
538 $usrIds = $type->resolve();
539
540 $this->assertCount(0, $usrIds);
541 }

References $type, and Sabre\Event\once().

+ Here is the call graph for this function:

◆ testPermissionsAreCheckedForRegularUsersWhenValidatingGlobalRoleAddresses()

ilMailAddressTypesTest::testPermissionsAreCheckedForRegularUsersWhenValidatingGlobalRoleAddresses ( )

Definition at line 573 of file ilMailAddressTypesTest.php.

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

References $type, and Sabre\Event\once().

+ Here is the call graph for this function:

◆ testUserIdCanBeResolvedFromLoginAddress()

ilMailAddressTypesTest::testUserIdCanBeResolvedFromLoginAddress ( )

Definition at line 199 of file ilMailAddressTypesTest.php.

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

References $type, and Sabre\Event\once().

+ Here is the call graph for this function:

◆ testUserIdsCanBeResolvedFromGroupNameAddress()

ilMailAddressTypesTest::testUserIdsCanBeResolvedFromGroupNameAddress ( )

Definition at line 321 of file ilMailAddressTypesTest.php.

322 {
323 $logger = $this->getMockBuilder(\ilLogger::class)->disableOriginalConstructor()->getMock();
324 $addressTypeHelper = $this->getMockBuilder(\ilMailAddressTypeHelper::class)->getMock();
325
326 $group = $this->getMockBuilder(\ilObjGroup::class)->disableOriginalConstructor()->setMethods(['getGroupMemberIds'])->getMock();
327 $group->expects($this->once())->method('getGroupMemberIds')->willReturn([666, 777]);
328
329 $addressTypeHelper->expects($this->once())->method('getGroupObjIdByTitle')->willReturn(1);
330 $addressTypeHelper->expects($this->once())->method('getAllRefIdsForObjId')->with(1)->willReturn([2]);
331 $addressTypeHelper->expects($this->once())->method('getInstanceByRefId')->with(2)->willReturn($group);
332
333 $type = new \ilMailGroupAddressType(
334 $addressTypeHelper,
335 new \ilMailAddress('#PhpUnit', ''),
336 $logger
337 );
338
339 $usrIds = $type->resolve();
340
341 $this->assertCount(2, $usrIds);
342 }

References $type, and Sabre\Event\once().

+ Here is the call graph for this function:

◆ testUserIdsCanBeResolvedFromMailingListAddress()

ilMailAddressTypesTest::testUserIdsCanBeResolvedFromMailingListAddress ( )

Definition at line 409 of file ilMailAddressTypesTest.php.

410 {
411 $logger = $this->getMockBuilder(\ilLogger::class)->disableOriginalConstructor()->getMock();
412 $addressTypeHelper = $this->getMockBuilder(\ilMailAddressTypeHelper::class)->getMock();
413
414 $list = $this->getMockBuilder(\ilMailingList::class)->disableOriginalConstructor()->setMethods([
415 'getAssignedEntries'
416 ])->getMock();
417 $list->expects($this->exactly(2))->method('getAssignedEntries')->willReturnOnConsecutiveCalls(
418 [['usr_id' => 1], ['usr_id' => 2], ['usr_id' => 3]],
419 []
420 );
421
422 $lists = $this->getMockBuilder(\ilMailingLists::class)->disableOriginalConstructor()->setMethods([
423 'mailingListExists', 'getCurrentMailingList'
424 ])->getMock();
425 $lists->expects($this->exactly(3))->method('mailingListExists')->with('#il_ml_4711')->willReturnOnConsecutiveCalls(
426 true,
427 true,
428 false
429 );
430 $lists->expects($this->exactly(2))->method('getCurrentMailingList')->willReturn($list);
431
432 $type = new \ilMailMailingListAddressType(
433 $addressTypeHelper,
434 new \ilMailAddress('#il_ml_4711', ''),
435 $logger,
436 $lists
437 );
438
439 $usrIds = $type->resolve();
440
441 $this->assertCount(3, $usrIds);
442
443 $usrIds = $type->resolve();
444
445 $this->assertCount(0, $usrIds);
446
447 $usrIds = $type->resolve();
448
449 $this->assertCount(0, $usrIds);
450 }
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41

References $list, and $type.

◆ testUserIdsCanBeResolvedFromRoleAddress()

ilMailAddressTypesTest::testUserIdsCanBeResolvedFromRoleAddress ( )

Definition at line 486 of file ilMailAddressTypesTest.php.

487 {
488 $logger = $this->getMockBuilder(\ilLogger::class)->disableOriginalConstructor()->getMock();
489 $rbacsystem = $this->getMockBuilder(\ilRbacSystem::class)->disableOriginalConstructor()->getMock();
490 $rbacreview = $this->getMockBuilder(\ilRbacReview::class)->disableOriginalConstructor()->setMethods(['assignedUsers'])->getMock();
491 $addressTypeHelper = $this->getMockBuilder(\ilMailAddressTypeHelper::class)->getMock();
492 $roleMailboxSearch = $this->getMockBuilder(\ilRoleMailboxSearch::class)->disableOriginalConstructor()->setMethods(['searchRoleIdsByAddressString'])->getMock();
493
494 $roleMailboxSearch->expects($this->once())->method('searchRoleIdsByAddressString')->willReturn([1, 2, 3]);
495 $rbacreview->expects($this->exactly(3))->method('assignedUsers')->willReturnOnConsecutiveCalls(
496 [4, 5, 6],
497 [7, 8],
498 [9]
499 );
500
501 $type = new \ilMailRoleAddressType(
502 $addressTypeHelper,
503 new \ilMailAddress('phpunit', 'ilias'),
504 $roleMailboxSearch,
505 $logger,
506 $rbacsystem,
507 $rbacreview
508 );
509
510 $usrIds = $type->resolve();
511
512 $this->assertCount(6, $usrIds);
513 }

References $type, and Sabre\Event\once().

+ Here is the call graph for this function:

◆ testUserIdsCannotBeResolvedFromNonExistingGroupNameAddress()

ilMailAddressTypesTest::testUserIdsCannotBeResolvedFromNonExistingGroupNameAddress ( )

Definition at line 347 of file ilMailAddressTypesTest.php.

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

References $type, and Sabre\Event\once().

+ Here is the call graph for this function:

◆ testValidationFailsForNonExistingGroupNameAddress()

ilMailAddressTypesTest::testValidationFailsForNonExistingGroupNameAddress ( )

Definition at line 373 of file ilMailAddressTypesTest.php.

374 {
375 $logger = $this->getMockBuilder(\ilLogger::class)->disableOriginalConstructor()->getMock();
376 $addressTypeHelper = $this->getMockBuilder(\ilMailAddressTypeHelper::class)->getMock();
377
378 $addressTypeHelper->expects($this->once())->method('doesGroupNameExists')->with('PhpUnit')->willReturn(false);
379
380 $type = new \ilMailGroupAddressType(
381 $addressTypeHelper,
382 new \ilMailAddress('#PhpUnit', ''),
383 $logger
384 );
385 $this->assertFalse($type->validate(666));
386 }

References $type, and Sabre\Event\once().

+ Here is the call graph for this function:

◆ testValidationForAnonymousUserAsSystemActorSucceedsAlwaysForGlobalRoleAddresses()

ilMailAddressTypesTest::testValidationForAnonymousUserAsSystemActorSucceedsAlwaysForGlobalRoleAddresses ( )

Definition at line 546 of file ilMailAddressTypesTest.php.

547 {
548 $logger = $this->getMockBuilder(\ilLogger::class)->disableOriginalConstructor()->getMock();
549 $rbacsystem = $this->getMockBuilder(\ilRbacSystem::class)->disableOriginalConstructor()->getMock();
550 $rbacreview = $this->getMockBuilder(\ilRbacReview::class)->disableOriginalConstructor()->getMock();
551 $addressTypeHelper = $this->getMockBuilder(\ilMailAddressTypeHelper::class)->getMock();
552 $roleMailboxSearch = $this->getMockBuilder(\ilRoleMailboxSearch::class)->disableOriginalConstructor()->setMethods(['searchRoleIdsByAddressString'])->getMock();
553
554 $roleMailboxSearch->expects($this->once())->method('searchRoleIdsByAddressString')->willReturnOnConsecutiveCalls([1]);
555 $rbacsystem->expects($this->never())->method('checkAccessOfUser');
556
557 $type = new \ilMailRoleAddressType(
558 $addressTypeHelper,
559 new \ilMailAddress('phpunit', 'ilias'),
560 $roleMailboxSearch,
561 $logger,
562 $rbacsystem,
563 $rbacreview
564 );
565
566 $this->assertTrue($type->validate(ANONYMOUS_USER_ID));
567 $this->assertCount(0, $type->getErrors());
568 }

References $type, and Sabre\Event\once().

+ Here is the call graph for this function:

◆ testValidationSucceedsForExistingGroupName()

ilMailAddressTypesTest::testValidationSucceedsForExistingGroupName ( )

Definition at line 391 of file ilMailAddressTypesTest.php.

392 {
393 $logger = $this->getMockBuilder(\ilLogger::class)->disableOriginalConstructor()->getMock();
394 $addressTypeHelper = $this->getMockBuilder(\ilMailAddressTypeHelper::class)->getMock();
395
396 $addressTypeHelper->expects($this->once())->method('doesGroupNameExists')->with('PhpUnit')->willReturn(true);
397
398 $type = new \ilMailGroupAddressType(
399 $addressTypeHelper,
400 new \ilMailAddress('#PhpUnit', ''),
401 $logger
402 );
403 $this->assertTrue($type->validate(666));
404 }

References $type, and Sabre\Event\once().

+ Here is the call graph for this function:

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