ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
NotificationSlateTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21require_once("vendor/composer/vendor/autoload.php");
22require_once(__DIR__ . "/../../../Base.php");
23
27
32{
33 protected I\SignalGenerator $sig_gen;
34
35 public function setUp(): void
36 {
37 $this->sig_gen = new I\SignalGenerator();
38 }
39
40 public function getIcon(): C\Symbol\Icon\Standard
41 {
42 return $this->getUIFactory()->symbol()->icon()->standard("name", "aria_label", "small", false);
43 }
44
45 public function getUIFactory(): NoUIFactory
46 {
47 $factory = new class () extends NoUIFactory {
48 public I\SignalGenerator $sig_gen;
49
50 public function button(): I\Button\Factory
51 {
52 return new I\Button\Factory();
53 }
54 public function symbol(): I\Symbol\Factory
55 {
56 return new I\Symbol\Factory(
57 new I\Symbol\Icon\Factory(),
58 new I\Symbol\Glyph\Factory(),
59 new I\Symbol\Avatar\Factory()
60 );
61 }
62 public function item(): I\Item\Factory
63 {
64 return new I\Item\Factory();
65 }
66 public function mainControls(): I\MainControls\Factory
67 {
68 return new I\MainControls\Factory(
69 $this->sig_gen,
70 new I\MainControls\Slate\Factory(
71 $this->sig_gen,
72 new Factory(),
73 $this->symbol()
74 )
75 );
76 }
77 public function icon(): C\Symbol\Icon\Factory
78 {
79 return new I\Symbol\Icon\Factory();
80 }
81 };
82 $factory->sig_gen = $this->sig_gen;
83
84 return $factory;
85 }
86
87 public function testImplementsFactoryInterface(): void
88 {
89 $notificatino_slate = $this->getUIFactory()->mainControls()->slate()->notification("title", []);
90
91 $this->assertInstanceOf("ILIAS\\UI\\Component\\MainControls\\Slate\\Notification", $notificatino_slate);
92 }
93
94 public function testGenerationByFactory(): void
95 {
96 $item = $this->getUIFactory()->item()->notification("title", $this->getIcon())
97 ->withDescription("description");
98
99 $notification_slate = $this->getUIFactory()->mainControls()->slate()->notification("title", [$item,$item]);
100 $this->assertEquals("title", $notification_slate->getName());
101 $this->assertEquals($notification_slate->getContents(), [$item,$item]);
102 }
103
104
105 public function testWithAdditionalEntry(): void
106 {
108 $item = $this->getUIFactory()->item()->notification("title", $this->getIcon())
109 ->withDescription("description");
110 $notification_slate = $this->getUIFactory()->mainControls()->slate()->notification("title", [$item,$item]);
111 $this->assertEquals($notification_slate->getContents(), [$item,$item]);
112 $notification_slate = $notification_slate->withAdditionalEntry($item);
113 $this->assertEquals($notification_slate->getContents(), [$item,$item,$item]);
114 }
115
117 {
118 $item = $this->getUIFactory()->item()->notification("item title", $this->getIcon());
119 $notification_slate = $this->getUIFactory()->mainControls()->slate()->notification("slate title", [$item]);
120
121
122 $r = $this->getDefaultRenderer();
123 $html = $r->render($notification_slate);
124
125 $expected = <<<EOT
126<div class="il-maincontrols-slate il-maincontrols-slate-notification">
127 <div class="il-maincontrols-slate-notification-title">slate title</div>
128 <div class="il-maincontrols-slate-content">
129 <div class="il-item-notification-replacement-container">
130 <div class="il-item il-notification-item" id="id_1">
131 <div class="media">
132 <div class="media-left">
133 <img class="icon name small" src="./assets/images/standard/icon_default.svg" alt="aria_label"/>
134 </div>
135 <div class="media-body">
136 <h4 class="il-item-notification-title">item title</h4>
137 <div class="il-aggregate-notifications" data-aggregatedby="id_1">
138 <div class="il-maincontrols-slate il-maincontrols-slate-notification">
139 <div class="il-maincontrols-slate-notification-title">
140 <button class="btn btn-bulky" data-action="">
141 <span class="glyph" role="img">
142 <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
143 </span>
144 <span class="bulky-label">back</span>
145 </button>
146 </div>
147 <div class="il-maincontrols-slate-content"></div>
148 </div>
149 </div>
150 </div>
151 </div>
152 </div>
153 </div>
154 </div>
155</div>
156EOT;
157 $this->assertEquals(
158 $this->brutallyTrimHTML($expected),
159 $this->brutallyTrimHTML($html)
160 );
161 }
162}
Provides common functionality for UI tests.
Definition: Base.php:337
button(string $caption, string $cmd)