ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
PanelListingTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21require_once(__DIR__ . "/../../../../../../vendor/composer/vendor/autoload.php");
22require_once(__DIR__ . "/../../Base.php");
23
26
31{
32 public function getFactory(): C\Panel\Listing\Factory
33 {
34 return new I\Component\Panel\Listing\Factory();
35 }
36
37 public function testImplementsFactoryInterface(): void
38 {
39 $f = $this->getFactory();
40
41 $std_list = $f->standard("List Title", array(
42 new I\Component\Item\Group("Subtitle 1", array(
43 new I\Component\Item\Standard("title1"),
44 new I\Component\Item\Standard("title2")
45 )),
46 new I\Component\Item\Group("Subtitle 2", array(
47 new I\Component\Item\Standard("title3")
48 ))
49 ));
50
51 $this->assertInstanceOf("ILIAS\\UI\\Component\\Panel\\Listing\\Standard", $std_list);
52 }
53
54 public function testGetTitleGetGroups(): void
55 {
56 $f = $this->getFactory();
57
58 $groups = array(
59 new I\Component\Item\Group("Subtitle 1", array(
60 new I\Component\Item\Standard("title1"),
61 new I\Component\Item\Standard("title2")
62 )),
63 new I\Component\Item\Group("Subtitle 2", array(
64 new I\Component\Item\Standard("title3")
65 ))
66 );
67
68 $c = $f->standard("title", $groups);
69
70 $this->assertEquals("title", $c->getTitle());
71 $this->assertEquals($groups, $c->getItemGroups());
72 }
73
74 public function testWithActions(): void
75 {
76 $f = $this->getFactory();
77
78 $actions = new I\Component\Dropdown\Standard(array(
79 new I\Component\Button\Shy("ILIAS", "https://www.ilias.de"),
80 new I\Component\Button\Shy("GitHub", "https://www.github.com")
81 ));
82
83 $groups = array();
84
85 $c = $f->standard("title", $groups)
86 ->withActions($actions);
87
88 $this->assertEquals($actions, $c->getActions());
89 }
90
91 public function testRenderBase(): void
92 {
93 $f = $this->getFactory();
94 $r = $this->getDefaultRenderer();
95
96 $groups = array(
97 new I\Component\Item\Group("Subtitle 1", array(
98 new I\Component\Item\Standard("title1"),
99 new I\Component\Item\Standard("title2")
100 )),
101 new I\Component\Item\Group("Subtitle 2", array(
102 new I\Component\Item\Standard("title3")
103 ))
104 );
105
106 $c = $f->standard("title", $groups);
107
108 $html = $r->render($c);
109
110 $expected = <<<EOT
111<div class="panel panel-flex il-panel-listing-std-container clearfix">
112<div class="panel-heading ilHeader">
113<div class="panel-title"><h2>title</h2></div><div class="panel-controls"></div></div>
114<div class="il-item-group">
115<h3>Subtitle 1</h3>
116<div class="il-item-group-items">
117 <ul>
118 <li class="il-std-item-container">
119 <div class="il-item il-std-item ">
120 <h4 class="il-item-title">title1</h4>
121 </div>
122 </li>
123 <li class="il-std-item-container">
124 <div class="il-item il-std-item ">
125 <h4 class="il-item-title">title2</h4>
126 </div>
127 </li>
128 </ul>
129</div>
130</div>
131<div class="il-item-group">
132<h3>Subtitle 2</h3>
133<div class="il-item-group-items">
134 <ul>
135 <li class="il-std-item-container">
136 <div class="il-item il-std-item ">
137 <h4 class="il-item-title">title3</h4>
138 </div>
139 </li>
140 </ul>
141</div>
142</div>
143</div>
144EOT;
145 $this->assertHTMLEquals(
146 $this->brutallyTrimHTML($expected),
147 $this->brutallyTrimHTML($html)
148 );
149 }
150
151 public function testRenderWithActions(): void
152 {
153 $f = $this->getFactory();
154 $r = $this->getDefaultRenderer();
155
156 $groups = array();
157
158 $actions = new I\Component\Dropdown\Standard(array(
159 new I\Component\Button\Shy("ILIAS", "https://www.ilias.de"),
160 new I\Component\Button\Shy("GitHub", "https://www.github.com")
161 ));
162
163 $c = $f->standard("title", $groups)
164 ->withActions($actions);
165
166 $html = $r->render($c);
167
168 $expected = <<<EOT
169<div class="panel panel-flex il-panel-listing-std-container clearfix">
170<div class="panel-heading ilHeader">
171<div class="panel-title"><h2>title</h2></div><div class="panel-controls"><div class="dropdown" id="id_3"><button class="btn btn-default dropdown-toggle" type="button" aria-label="actions" aria-haspopup="true" aria-expanded="false" aria-controls="id_3_menu"> <span class="caret"></span></button>
172<ul id="id_3_menu" class="dropdown-menu">
173 <li><button class="btn btn-link" data-action="https://www.ilias.de" id="id_1">ILIAS</button></li>
174 <li><button class="btn btn-link" data-action="https://www.github.com" id="id_2">GitHub</button></li>
175</ul>
176</div>
177</div>
178</div>
179</div>
180EOT;
181 $this->assertHTMLEquals($expected, $html);
182 }
183}
Provides common functionality for UI tests.
Definition: Base.php:337
Test listing panels.
$c
Definition: deliver.php:25
button(string $caption, string $cmd)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.