ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables 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

 $rbacreview_mock
 

Private Attributes

ILIAS DI Container $dic_backup
 

Detailed Description

Definition at line 24 of file ilServicesAdministrativeNotificationTest.php.

Member Function Documentation

◆ setUp()

ilServicesAdministrativeNotificationTest::setUp ( )
protected

Definition at line 32 of file ilServicesAdministrativeNotificationTest.php.

References $DIC.

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

◆ tearDown()

ilServicesAdministrativeNotificationTest::tearDown ( )
protected

Definition at line 42 of file ilServicesAdministrativeNotificationTest.php.

References $DIC, and $dic_backup.

42  : void
43  {
44  global $DIC;
45  $DIC = $this->dic_backup;
46  }
global $DIC
Definition: feed.php:28

◆ testBasisc()

ilServicesAdministrativeNotificationTest::testBasisc ( )

Definition at line 48 of file ilServicesAdministrativeNotificationTest.php.

References ilADNNotification\TYPE_ERROR, and ilADNNotification\TYPE_WARNING.

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

◆ testVisibilityByDate()

ilServicesAdministrativeNotificationTest::testVisibilityByDate ( )

Definition at line 62 of file ilServicesAdministrativeNotificationTest.php.

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

◆ testVisibilityByRole()

ilServicesAdministrativeNotificationTest::testVisibilityByRole ( )

Definition at line 88 of file ilServicesAdministrativeNotificationTest.php.

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

◆ testVisibilityByRoleNotGranted()

ilServicesAdministrativeNotificationTest::testVisibilityByRoleNotGranted ( )

Definition at line 108 of file ilServicesAdministrativeNotificationTest.php.

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

Field Documentation

◆ $dic_backup

ILIAS DI Container ilServicesAdministrativeNotificationTest::$dic_backup
private

Definition at line 26 of file ilServicesAdministrativeNotificationTest.php.

Referenced by tearDown().

◆ $rbacreview_mock

ilServicesAdministrativeNotificationTest::$rbacreview_mock
protected

Definition at line 30 of file ilServicesAdministrativeNotificationTest.php.


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