ILIAS  release_7 Revision v7.30-3-g800a261c036
MainNotificationCollectorTest.php
Go to the documentation of this file.
1<?php
2
20
21require_once(__DIR__ . "/../BaseNotificationSetUp.php");
22
27{
28 public function testConstruct() : void
29 {
31 $collector = new MainNotificationCollector([$povider]);
32 $this->assertInstanceOf(MainNotificationCollector::class, $collector);
33 }
34
35
36 public function testHasNotifications() : void
37 {
39 $collector = new MainNotificationCollector([$povider]);
40 $this->assertFalse($collector->hasItems());
41
42 $group_notification = $this->factory->standardGroup($this->id);
43 $povider = $this->getDummyNotificationsProviderWithNotifications([$group_notification]);
44 $collector = new MainNotificationCollector([$povider]);
45 $this->assertTrue($collector->hasItems());
46 }
47
48
49 public function testGetNotifications() : void
50 {
52 $collector = new MainNotificationCollector([$povider]);
53 $this->assertEquals([], $collector->getNotifications());
54
55 $group_notification = $this->factory->standardGroup($this->id);
56 $povider = $this->getDummyNotificationsProviderWithNotifications([$group_notification]);
57 $collector = new MainNotificationCollector([$povider]);
58 $this->assertEquals([$group_notification], $collector->getNotifications());
59
60 $group_notification = $this->factory->standardGroup($this->id);
61 $povider = $this->getDummyNotificationsProviderWithNotifications([$group_notification, $group_notification]);
62 $collector = new MainNotificationCollector([$povider]);
63 $this->assertEquals([$group_notification, $group_notification], $collector->getNotifications());
64 }
65
66
67 public function testGetAmountOfNewNotifications() : void
68 {
70 $collector = new MainNotificationCollector([$povider]);
71 $this->assertEquals(0, $collector->getAmountOfNewNotifications());
72
73 $group_notification = $this->factory->standardGroup($this->id);
74 $povider = $this->getDummyNotificationsProviderWithNotifications([$group_notification]);
75 $collector = new MainNotificationCollector([$povider]);
76 $this->assertEquals(0, $collector->getAmountOfNewNotifications());
77
78 $group_notification = $this->factory->standardGroup($this->id);
79 $standard_notification = $this->factory->standard($this->id)->withNewAmount(3);
80 $group_notification->addNotification($standard_notification);
81 $group_notification->addNotification($standard_notification);
82
83 $povider = $this->getDummyNotificationsProviderWithNotifications([$group_notification, $group_notification]);
84 $collector = new MainNotificationCollector([$povider]);
85 $this->assertEquals(4, $collector->getAmountOfNewNotifications());
86 }
87
88
89 public function testGetAmountOfOldNotifications() : void
90 {
92 $collector = new MainNotificationCollector([$povider]);
93 $this->assertEquals(0, $collector->getAmountOfOldNotifications());
94
95 $group_notification = $this->factory->standardGroup($this->id);
96 $povider = $this->getDummyNotificationsProviderWithNotifications([$group_notification]);
97 $collector = new MainNotificationCollector([$povider]);
98 $this->assertEquals(0, $collector->getAmountOfOldNotifications());
99
100 $group_notification = $this->factory->standardGroup($this->id);
101 $standard_notification = $this->factory->standard($this->id)->withOldAmount(3);
102 $group_notification->addNotification($standard_notification);
103 $group_notification->addNotification($standard_notification);
104
105 $povider = $this->getDummyNotificationsProviderWithNotifications([$group_notification, $group_notification]);
106 $collector = new MainNotificationCollector([$povider]);
107 $this->assertEquals(4, $collector->getAmountOfOldNotifications());
108 }
109
110
112 {
114 $collector = new MainNotificationCollector([$provider]);
115
116 $this->assertEquals([], $collector->getNotificationsIdentifiersAsArray());
117
118 $group_notification = $this->factory->standardGroup($this->id);
119 $provider = $this->getDummyNotificationsProviderWithNotifications([$group_notification]);
120 $collector = new MainNotificationCollector([$provider]);
121
122 $this->assertEquals([$this->id->serialize()], $collector->getNotificationsIdentifiersAsArray());
123
124 $group_notification = $this->factory->standardGroup($this->id);
125 $provider = $this->getDummyNotificationsProviderWithNotifications([$group_notification, $group_notification]);
126 $collector = new MainNotificationCollector([$provider]);
127
128 $this->assertEquals([$this->id->serialize(), $this->id->serialize()], $collector->getNotificationsIdentifiersAsArray());
129 }
130}
Class BaseNotificationSetUp.
getDummyNotificationsProviderWithNotifications($notifications)
An exception for terminatinating execution or to throw for unit testing.
Class MainNotificationCollectorTest.