ILIAS  release_7 Revision v7.30-3-g800a261c036
StandardNotificationTest.php
Go to the documentation of this file.
1<?php
2
21
22require_once(__DIR__ . "/../BaseNotificationSetUp.php");
23
28{
29 public function testConstructByFactory() : void
30 {
31 $standard_notification = $this->factory->standard($this->id);
32
33 $this->assertInstanceOf(StandardNotification::class, $standard_notification);
34 $this->assertEquals($this->id, $standard_notification->getProviderIdentification());
35 }
36
37 public function testWithNotificationItem() : void
38 {
39 $icon = $this->getUIFactory()->symbol()->icon()->standard("mail", "mail");
40 $item = $this->getUIFactory()->item()->notification("hello", $icon);
41
42 $standard_notification = $this->factory->standard($this->id)->withNotificationItem($item);
43 $this->assertEquals($item, $standard_notification->getNotificationItem());
44 }
45
46 public function testWithNewAmout() : void
47 {
48 $standard_notification = $this->factory->standard($this->id);
49
50 $this->assertEquals(1, $standard_notification->getNewAmount());
51 $standard_notification = $standard_notification->withNewAmount(13);
52 $this->assertEquals(13, $standard_notification->getNewAmount());
53 }
54
55 public function testWithOldAmout() : void
56 {
57 $standard_notification = $this->factory->standard($this->id);
58
59 $this->assertEquals(0, $standard_notification->getOldAmount());
60 $standard_notification = $standard_notification->withOldAmount(13);
61 $this->assertEquals(13, $standard_notification->getOldAmount());
62 }
63
67 public function testGetProviderIdentification() : void
68 {
69 $standard_notification = $this->factory->standard($this->id);
70 $this->assertEquals($this->id, $standard_notification->getProviderIdentification());
71 }
72
73 public function testGetRenderer() : void
74 {
75 $standard_notification = $this->factory->standard($this->id);
76 $this->assertInstanceOf(
77 StandardNotificationRenderer::class,
78 $standard_notification->getRenderer($this->getUIFactory())
79 );
80 }
81
82 public function testWithOpenedCallable() : void
83 {
84 $callable = function () : string {
85 return "something";
86 };
87 $standard_notification = $this->factory->standard($this->id);
88 $this->assertEquals(function () : void {
89 }, $standard_notification->getOpenedCallable());
90 $standard_notification = $standard_notification->withOpenedCallable($callable);
91 $this->assertEquals($callable, $standard_notification->getOpenedCallable());
92 }
93 public function testWithClosedCallable() : void
94 {
95 $callable = function () : string {
96 return "something";
97 };
98 $standard_notification = $this->factory->standard($this->id);
99 $this->assertNull($standard_notification->getClosedCallable());
100 $standard_notification = $standard_notification->withClosedCallable($callable);
101 $this->assertEquals($callable, $standard_notification->getClosedCallable());
102 }
103 public function testHasClosedCallable() : void
104 {
105 $callable = function () : string {
106 return "something";
107 };
108 $standard_notification = $this->factory->standard($this->id);
109 $this->assertFalse($standard_notification->hasClosedCallable());
110 $standard_notification = $standard_notification->withClosedCallable($callable);
111 $this->assertTrue($standard_notification->hasClosedCallable());
112 }
113}
Class BaseNotificationSetUp.
An exception for terminatinating execution or to throw for unit testing.
Class Notification The default Notification mapping currently to one UI Notification Item component.
Class StandardNotificationTest.
testGetProviderIdentification()
Tests on AbstractBaseNotification.