ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
MainNotificationCollectorTestTBD.php
Go to the documentation of this file.
1 <?php
2 
20 
25 {
26  public function testConstruct(): void
27  {
29  $collector = new MainNotificationCollector([$povider]);
30  $this->assertInstanceOf(MainNotificationCollector::class, $collector);
31  }
32 
33 
34  public function testHasNotifications(): void
35  {
37  $collector = new MainNotificationCollector([$povider]);
38  $this->assertFalse($collector->hasItems());
39 
40  $group_notification = $this->factory->standardGroup($this->id);
41  $povider = $this->getDummyNotificationsProviderWithNotifications([$group_notification]);
42  $collector = new MainNotificationCollector([$povider]);
43  $this->assertTrue($collector->hasItems());
44  }
45 
46 
47  public function testGetNotifications(): void
48  {
50  $collector = new MainNotificationCollector([$povider]);
51  $this->assertEquals([], $collector->getNotifications());
52 
53  $group_notification = $this->factory->standardGroup($this->id);
54  $povider = $this->getDummyNotificationsProviderWithNotifications([$group_notification]);
55  $collector = new MainNotificationCollector([$povider]);
56  $this->assertEquals([$group_notification], $collector->getNotifications());
57 
58  $group_notification = $this->factory->standardGroup($this->id);
59  $povider = $this->getDummyNotificationsProviderWithNotifications([$group_notification, $group_notification]);
60  $collector = new MainNotificationCollector([$povider]);
61  $this->assertEquals([$group_notification, $group_notification], $collector->getNotifications());
62  }
63 
64 
65  public function testGetAmountOfNewNotifications(): void
66  {
68  $collector = new MainNotificationCollector([$povider]);
69  $this->assertEquals(0, $collector->getAmountOfNewNotifications());
70 
71  $group_notification = $this->factory->standardGroup($this->id);
72  $povider = $this->getDummyNotificationsProviderWithNotifications([$group_notification]);
73  $collector = new MainNotificationCollector([$povider]);
74  $this->assertEquals(0, $collector->getAmountOfNewNotifications());
75 
76  $group_notification = $this->factory->standardGroup($this->id);
77  $standard_notification = $this->factory->standard($this->id)->withNewAmount(3);
78  $group_notification->addNotification($standard_notification);
79  $group_notification->addNotification($standard_notification);
80 
81  $povider = $this->getDummyNotificationsProviderWithNotifications([$group_notification, $group_notification]);
82  $collector = new MainNotificationCollector([$povider]);
83  $this->assertEquals(4, $collector->getAmountOfNewNotifications());
84  }
85 
86 
87  public function testGetAmountOfOldNotifications(): void
88  {
90  $collector = new MainNotificationCollector([$povider]);
91  $this->assertEquals(0, $collector->getAmountOfOldNotifications());
92 
93  $group_notification = $this->factory->standardGroup($this->id);
94  $povider = $this->getDummyNotificationsProviderWithNotifications([$group_notification]);
95  $collector = new MainNotificationCollector([$povider]);
96  $this->assertEquals(0, $collector->getAmountOfOldNotifications());
97 
98  $group_notification = $this->factory->standardGroup($this->id);
99  $standard_notification = $this->factory->standard($this->id)->withOldAmount(3);
100  $group_notification->addNotification($standard_notification);
101  $group_notification->addNotification($standard_notification);
102 
103  $povider = $this->getDummyNotificationsProviderWithNotifications([$group_notification, $group_notification]);
104  $collector = new MainNotificationCollector([$povider]);
105  $this->assertEquals(4, $collector->getAmountOfOldNotifications());
106  }
107 
108 
110  {
112  $collector = new MainNotificationCollector([$provider]);
113 
114  $this->assertEquals([], $collector->getNotificationsIdentifiersAsArray());
115 
116  $group_notification = $this->factory->standardGroup($this->id);
117  $provider = $this->getDummyNotificationsProviderWithNotifications([$group_notification]);
118  $collector = new MainNotificationCollector([$provider]);
119 
120  $this->assertEquals([$this->id->serialize()], $collector->getNotificationsIdentifiersAsArray());
121 
122  $group_notification = $this->factory->standardGroup($this->id);
123  $provider = $this->getDummyNotificationsProviderWithNotifications([$group_notification, $group_notification]);
124  $collector = new MainNotificationCollector([$provider]);
125 
126  $this->assertEquals([$this->id->serialize(), $this->id->serialize()], $collector->getNotificationsIdentifiersAsArray());
127  }
128 }
Class BaseNotificationSetUp.
factory()
Class MainNotificationCollectorTest.
getDummyNotificationsProviderWithNotifications($notifications)