ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilServicesAdministrativeNotificationTest Class Reference
+ Inheritance diagram for ilServicesAdministrativeNotificationTest:
+ Collaboration diagram for ilServicesAdministrativeNotificationTest:

Public Member Functions

 testBasisc ()
 
 testVisibilityByDate ()
 
 testVisibilityByRole ()
 
 testVisibilityByRoleNotGranted ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 

Protected Attributes

MockObject $rbacreview_mock
 

Private Attributes

Container $dic_backup
 

Detailed Description

Definition at line 25 of file ilServicesAdministrativeNotificationTest.php.

Member Function Documentation

◆ setUp()

ilServicesAdministrativeNotificationTest::setUp ( )
protected

Definition at line 33 of file ilServicesAdministrativeNotificationTest.php.

References $DIC.

33  : void
34  {
35  global $DIC;
36  $this->dic_backup = is_object($DIC) ? clone $DIC : $DIC;
37 
38  $DIC = new Container();
39  $DIC['ilDB'] = $this->createMock(ilDBInterface::class);
40  $this->rbacreview_mock = $DIC['rbacreview'] = $this->createMock(ilRbacReview::class);
41  }
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
global $DIC
Definition: shib_login.php:22

◆ tearDown()

ilServicesAdministrativeNotificationTest::tearDown ( )
protected

Definition at line 43 of file ilServicesAdministrativeNotificationTest.php.

References $DIC, and $dic_backup.

43  : void
44  {
45  global $DIC;
46  $DIC = $this->dic_backup;
47  }
global $DIC
Definition: shib_login.php:22

◆ testBasisc()

ilServicesAdministrativeNotificationTest::testBasisc ( )

Definition at line 49 of file ilServicesAdministrativeNotificationTest.php.

References ilADNNotification\TYPE_ERROR, and ilADNNotification\TYPE_WARNING.

49  : void
50  {
51  $notification = new ilADNNotification();
52  $this->assertEquals(0, $notification->getId());
53 
54  $notification->setTitle('Title');
55  $notification->setActive(true);
56  $notification->setType(ilADNNotification::TYPE_WARNING);
57  $notification->setTypeDuringEvent(ilADNNotification::TYPE_ERROR);
58 
59  $this->assertTrue($notification->isActive());
60  $this->assertFalse($notification->isDuringEvent());
61  }

◆ testVisibilityByDate()

ilServicesAdministrativeNotificationTest::testVisibilityByDate ( )

Definition at line 63 of file ilServicesAdministrativeNotificationTest.php.

63  : void
64  {
65  $notification = new ilADNNotification();
66  $user_mock = $this->createMock(ilObjUser::class);
67  $user_mock->expects($this->atLeast(1))
68  ->method('getId')
69  ->willReturn(42);
70 
71  $notification->setPermanent(true);
72  $this->assertTrue($notification->isVisibleForUser($user_mock));
73 
74  $notification->setPermanent(false);
75 
76  $notification->setDisplayStart(new DateTimeImmutable("-2 hours"));
77  $notification->setEventStart(new DateTimeImmutable("-1 hours"));
78  $notification->setDisplayEnd(new DateTimeImmutable("+2 hours"));
79  $notification->setEventEnd(new DateTimeImmutable("+1 hours"));
80  $this->assertTrue($notification->isVisibleForUser($user_mock));
81 
82  $notification->setDisplayStart(new DateTimeImmutable("+1 hours"));
83  $notification->setEventStart(new DateTimeImmutable("+2 hours"));
84  $notification->setDisplayEnd(new DateTimeImmutable("+4 hours"));
85  $notification->setEventEnd(new DateTimeImmutable("+3 hours"));
86  $this->assertFalse($notification->isVisibleForUser($user_mock));
87  }

◆ testVisibilityByRole()

ilServicesAdministrativeNotificationTest::testVisibilityByRole ( )

Definition at line 89 of file ilServicesAdministrativeNotificationTest.php.

89  : void
90  {
91  $notification = new ilADNNotification();
92  $user_mock = $this->createMock(ilObjUser::class);
93  $user_mock->expects($this->atLeast(1))
94  ->method('getId')
95  ->willReturn(42);
96 
97  $notification->setPermanent(true);
98  $notification->setLimitToRoles(true);
99  $notification->setLimitedToRoleIds([2, 22, 222]);
100 
101  $this->rbacreview_mock->expects($this->once())
102  ->method('isAssignedToAtLeastOneGivenRole')
103  ->with(42, [2, 22, 222])
104  ->willReturn(true);
105 
106  $this->assertTrue($notification->isVisibleForUser($user_mock));
107  }

◆ testVisibilityByRoleNotGranted()

ilServicesAdministrativeNotificationTest::testVisibilityByRoleNotGranted ( )

Definition at line 109 of file ilServicesAdministrativeNotificationTest.php.

109  : void
110  {
111  $notification = new ilADNNotification();
112  $user_mock = $this->createMock(ilObjUser::class);
113  $user_mock->expects($this->atLeast(1))
114  ->method('getId')
115  ->willReturn(42);
116 
117  $notification->setPermanent(true);
118  $notification->setLimitToRoles(true);
119  $notification->setLimitedToRoleIds([2, 22, 222]);
120 
121  $this->rbacreview_mock->expects($this->once())
122  ->method('isAssignedToAtLeastOneGivenRole')
123  ->with(42, [2, 22, 222])
124  ->willReturn(false);
125 
126  $this->assertFalse($notification->isVisibleForUser($user_mock));
127  }

Field Documentation

◆ $dic_backup

Container ilServicesAdministrativeNotificationTest::$dic_backup
private

Definition at line 27 of file ilServicesAdministrativeNotificationTest.php.

Referenced by tearDown().

◆ $rbacreview_mock

MockObject ilServicesAdministrativeNotificationTest::$rbacreview_mock
protected

Definition at line 31 of file ilServicesAdministrativeNotificationTest.php.


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