ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
GroupNotificationTest.php
Go to the documentation of this file.
1 <?php
4 
5 require_once(__DIR__ . "/../BaseNotificationSetUp.php");
6 
11 {
12  public function testConstructByFactory()
13  {
14  $group_notification = $this->factory->standardGroup($this->id);
15 
16  $this->assertInstanceOf(StandardNotificationGroup::class, $group_notification);
17  $this->assertEquals($this->id, $group_notification->getProviderIdentification());
18  }
19 
20  public function testWitTitle()
21  {
22  $group_notification = $this->factory->standardGroup($this->id)->withTitle("test");
23  $this->assertEquals("test", $group_notification->getTitle());
24  }
25 
26  public function testAddNotification()
27  {
28  $group_notification = $this->factory->standardGroup($this->id);
29  $this->assertEquals([], $group_notification->getNotifications());
30  $standard_notification = $this->factory->standard($this->id);
31  $group_notification->addNotification($standard_notification);
32  $this->assertEquals([$standard_notification], $group_notification->getNotifications());
33  $group_notification->addNotification($standard_notification);
34  $this->assertEquals([$standard_notification,$standard_notification], $group_notification->getNotifications());
35  }
36 
37  public function testNotificationCount()
38  {
39  $group_notification = $this->factory->standardGroup($this->id);
40  $this->assertEquals(0, $group_notification->getNotificationsCount());
41  $standard_notification = $this->factory->standard($this->id);
42  $group_notification->addNotification($standard_notification);
43  $this->assertEquals(1, $group_notification->getNotificationsCount());
44  $group_notification->addNotification($standard_notification);
45  $this->assertEquals(2, $group_notification->getNotificationsCount());
46  }
47 
48  public function testNewNotificationCount()
49  {
50  $group_notification = $this->factory->standardGroup($this->id);
51  $this->assertEquals(0, $group_notification->getNewNotificationsCount());
52  $standard_notification = $this->factory->standard($this->id)->withNewAmount(3);
53  $group_notification->addNotification($standard_notification);
54  $this->assertEquals(3, $group_notification->getNewNotificationsCount());
55  $group_notification->addNotification($standard_notification);
56  $this->assertEquals(6, $group_notification->getNewNotificationsCount());
57  }
58 
59  public function testOldNotificationCount()
60  {
61  $group_notification = $this->factory->standardGroup($this->id);
62  $this->assertEquals(0, $group_notification->getOldNotificationsCount());
63  $standard_notification = $this->factory->standard($this->id)->withOldAmount(3);
64  $group_notification->addNotification($standard_notification);
65  $this->assertEquals(3, $group_notification->getOldNotificationsCount());
66  $group_notification->addNotification($standard_notification);
67  $this->assertEquals(6, $group_notification->getOldNotificationsCount());
68  }
69 
74  {
75  $standard_notification = $this->factory->standard($this->id);
76  $this->assertEquals($this->id, $standard_notification->getProviderIdentification());
77  }
78 
79  public function testGetRenderer()
80  {
81  $group_notification = $this->factory->standardGroup($this->id);
82  $this->assertInstanceOf(
83  StandardNotificationGroupRenderer::class,
84  $group_notification->getRenderer($this->getUIFactory())
85  );
86  }
87 
88  public function testWithOpenedCallable()
89  {
90  $callable = function () {
91  return "something";
92  };
93  $standard_notification = $this->factory->standard($this->id);
94  $this->assertEquals(function () {
95  }, $standard_notification->getOpenedCallable());
96  $standard_notification = $standard_notification->withOpenedCallable($callable);
97  $this->assertEquals($callable, $standard_notification->getOpenedCallable());
98  }
99 }
Class BaseNotificationSetUp.
testGetProviderIdentification()
Tests on AbstractBaseNotification.
Class StandardNotificationTest.