ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
MainNotificationCollectorTest.php
Go to the documentation of this file.
1 <?php
2 
4 
5 require_once(__DIR__ . "/../BaseNotificationSetUp.php");
6 
11 {
12  public function testConstruct(): void
13  {
15  $collector = new MainNotificationCollector([$povider]);
16  $this->assertInstanceOf(MainNotificationCollector::class, $collector);
17  }
18 
19 
20  public function testHasNotifications(): void
21  {
23  $collector = new MainNotificationCollector([$povider]);
24  $this->assertFalse($collector->hasItems());
25 
26  $group_notification = $this->factory->standardGroup($this->id);
27  $povider = $this->getDummyNotificationsProviderWithNotifications([$group_notification]);
28  $collector = new MainNotificationCollector([$povider]);
29  $this->assertTrue($collector->hasItems());
30  }
31 
32 
33  public function testGetNotifications(): void
34  {
36  $collector = new MainNotificationCollector([$povider]);
37  $this->assertEquals([], $collector->getNotifications());
38 
39  $group_notification = $this->factory->standardGroup($this->id);
40  $povider = $this->getDummyNotificationsProviderWithNotifications([$group_notification]);
41  $collector = new MainNotificationCollector([$povider]);
42  $this->assertEquals([$group_notification], $collector->getNotifications());
43 
44  $group_notification = $this->factory->standardGroup($this->id);
45  $povider = $this->getDummyNotificationsProviderWithNotifications([$group_notification, $group_notification]);
46  $collector = new MainNotificationCollector([$povider]);
47  $this->assertEquals([$group_notification, $group_notification], $collector->getNotifications());
48  }
49 
50 
51  public function testGetAmountOfNewNotifications(): void
52  {
54  $collector = new MainNotificationCollector([$povider]);
55  $this->assertEquals(0, $collector->getAmountOfNewNotifications());
56 
57  $group_notification = $this->factory->standardGroup($this->id);
58  $povider = $this->getDummyNotificationsProviderWithNotifications([$group_notification]);
59  $collector = new MainNotificationCollector([$povider]);
60  $this->assertEquals(0, $collector->getAmountOfNewNotifications());
61 
62  $group_notification = $this->factory->standardGroup($this->id);
63  $standard_notification = $this->factory->standard($this->id)->withNewAmount(3);
64  $group_notification->addNotification($standard_notification);
65  $group_notification->addNotification($standard_notification);
66 
67  $povider = $this->getDummyNotificationsProviderWithNotifications([$group_notification, $group_notification]);
68  $collector = new MainNotificationCollector([$povider]);
69  $this->assertEquals(4, $collector->getAmountOfNewNotifications());
70  }
71 
72 
73  public function testGetAmountOfOldNotifications(): void
74  {
76  $collector = new MainNotificationCollector([$povider]);
77  $this->assertEquals(0, $collector->getAmountOfOldNotifications());
78 
79  $group_notification = $this->factory->standardGroup($this->id);
80  $povider = $this->getDummyNotificationsProviderWithNotifications([$group_notification]);
81  $collector = new MainNotificationCollector([$povider]);
82  $this->assertEquals(0, $collector->getAmountOfOldNotifications());
83 
84  $group_notification = $this->factory->standardGroup($this->id);
85  $standard_notification = $this->factory->standard($this->id)->withOldAmount(3);
86  $group_notification->addNotification($standard_notification);
87  $group_notification->addNotification($standard_notification);
88 
89  $povider = $this->getDummyNotificationsProviderWithNotifications([$group_notification, $group_notification]);
90  $collector = new MainNotificationCollector([$povider]);
91  $this->assertEquals(4, $collector->getAmountOfOldNotifications());
92  }
93 
94 
96  {
98  $collector = new MainNotificationCollector([$provider]);
99 
100  $this->assertEquals([], $collector->getNotificationsIdentifiersAsArray());
101 
102  $group_notification = $this->factory->standardGroup($this->id);
103  $provider = $this->getDummyNotificationsProviderWithNotifications([$group_notification]);
104  $collector = new MainNotificationCollector([$provider]);
105 
106  $this->assertEquals([$this->id->serialize()], $collector->getNotificationsIdentifiersAsArray());
107 
108  $group_notification = $this->factory->standardGroup($this->id);
109  $provider = $this->getDummyNotificationsProviderWithNotifications([$group_notification, $group_notification]);
110  $collector = new MainNotificationCollector([$provider]);
111 
112  $this->assertEquals([$this->id->serialize(), $this->id->serialize()], $collector->getNotificationsIdentifiersAsArray());
113  }
114 }
Class BaseNotificationSetUp.
Class MainNotificationCollectorTest.
getDummyNotificationsProviderWithNotifications($notifications)