19declare(strict_types=1);
21use PHPUnit\Framework\MockObject\MockObject;
22use PHPUnit\Framework\TestCase;
33 protected function setUp(): void
39 $DIC[
'ilDB'] = $this->createMock(ilDBInterface::class);
40 $this->rbacreview_mock =
$DIC[
'rbacreview'] = $this->createMock(ilRbacReview::class);
52 $this->assertSame(0, $notification->getId());
54 $notification->setTitle(
'Title');
55 $notification->setActive(
true);
59 $this->assertTrue($notification->isActive());
60 $this->assertFalse($notification->isDuringEvent());
66 $user_mock = $this->createMock(ilObjUser::class);
67 $user_mock->expects($this->atLeast(1))
71 $notification->setPermanent(
true);
72 $this->assertTrue($notification->isVisibleForUser($user_mock));
74 $notification->setPermanent(
false);
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));
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));
92 $user_mock = $this->createMock(ilObjUser::class);
93 $user_mock->expects($this->atLeast(1))
97 $notification->setPermanent(
true);
98 $notification->setLimitToRoles(
true);
99 $notification->setLimitedToRoleIds([2, 22, 222]);
101 $this->rbacreview_mock->expects($this->once())
102 ->method(
'isAssignedToAtLeastOneGivenRole')
103 ->with(42, [2, 22, 222])
106 $this->assertTrue($notification->isVisibleForUser($user_mock));
112 $user_mock = $this->createMock(ilObjUser::class);
113 $user_mock->expects($this->atLeast(1))
117 $notification->setPermanent(
true);
118 $notification->setLimitToRoles(
true);
119 $notification->setLimitedToRoleIds([2, 22, 222]);
121 $this->rbacreview_mock->expects($this->once())
122 ->method(
'isAssignedToAtLeastOneGivenRole')
123 ->with(42, [2, 22, 222])
126 $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()
MockObject $rbacreview_mock