3declare(strict_types=1);
21use PHPUnit\Framework\TestCase;
32 protected function setUp(): void
38 $DIC[
'ilDB'] = $this->createMock(ilDBInterface::class);
39 $this->rbacreview_mock =
$DIC[
'rbacreview'] = $this->createMock(ilRbacReview::class);
51 $this->assertEquals(0, $notification->getId());
53 $notification->setTitle(
'Title');
54 $notification->setActive(
true);
58 $this->assertTrue($notification->isActive());
59 $this->assertFalse($notification->isDuringEvent());
65 $user_mock = $this->createMock(ilObjUser::class);
66 $user_mock->expects($this->atLeast(1))
70 $notification->setPermanent(
true);
71 $this->assertTrue($notification->isVisibleForUser($user_mock));
73 $notification->setPermanent(
false);
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));
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));
91 $user_mock = $this->createMock(ilObjUser::class);
92 $user_mock->expects($this->atLeast(1))
96 $notification->setPermanent(
true);
97 $notification->setLimitToRoles(
true);
98 $notification->setLimitedToRoleIds([2, 22, 222]);
100 $this->rbacreview_mock->expects($this->once())
101 ->method(
'isAssignedToAtLeastOneGivenRole')
102 ->with(42, [2, 22, 222])
105 $this->assertTrue($notification->isVisibleForUser($user_mock));
111 $user_mock = $this->createMock(ilObjUser::class);
112 $user_mock->expects($this->atLeast(1))
116 $notification->setPermanent(
true);
117 $notification->setLimitToRoles(
true);
118 $notification->setLimitedToRoleIds([2, 22, 222]);
120 $this->rbacreview_mock->expects($this->once())
121 ->method(
'isAssignedToAtLeastOneGivenRole')
122 ->with(42, [2, 22, 222])
125 $this->assertFalse($notification->isVisibleForUser($user_mock));
Customizing of pimple-DIC for ILIAS.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testVisibilityByRoleNotGranted()
ILIAS DI Container $dic_backup