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