ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
PresentationTest Class Reference

Tests for Presentation Table. More...

+ Inheritance diagram for PresentationTest:
+ Collaboration diagram for PresentationTest:

Public Member Functions

 testTableConstruction ()
 
 testRowConstruction ()
 
 getUIFactory ()
 
 testFullRendering ()
 
 testMinimalRendering ()
 
 testRenderEmptyTableEntry ()
 

Protected Member Functions

 getDummyData ()
 
- Protected Member Functions inherited from TableTestBase
 buildFieldFactory ()
 
 buildRefinery ()
 
 getViewControlFactory ()
 
 getViewControlContainerFactory ()
 
 getTableFactory ()
 
 getMockStorage ()
 

Private Member Functions

 getFactory ()
 

Detailed Description

Tests for Presentation Table.

Definition at line 31 of file PresentationTest.php.

Member Function Documentation

◆ getDummyData()

PresentationTest::getDummyData ( )
protected

Definition at line 121 of file PresentationTest.php.

121 : array
122 {
123 return [[
124 'headline' => 'some title',
125 'subhead' => 'some type',
126 'important_fields' => ['important-1','important-2'],
127 'content' => ['1st' => 'first content', '2nd' => 'second content'],
128 'further_headline' => 'further fields',
129 'further_fields' => ['f-1' => 'further', 'f-2' => 'way further'],
130 'action' => 'do'
131 ]];
132 }

◆ getFactory()

PresentationTest::getFactory ( )
private

Definition at line 33 of file PresentationTest.php.

33 : I\Component\Table\Factory
34 {
35 return new I\Component\Table\Factory(
36 new I\Component\SignalGenerator(),
37 new \ILIAS\Data\Factory(),
38 new I\Component\Table\Column\Factory(),
39 new I\Component\Table\Action\Factory(),
40 new I\Component\Table\DataRowBuilder(),
41 new I\Component\Table\OrderingRowBuilder()
42 );
43 }
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

◆ getUIFactory()

PresentationTest::getUIFactory ( )

Definition at line 99 of file PresentationTest.php.

100 {
101 $factory = new class () extends NoUIFactory {
102 public I\Component\SignalGenerator $sig_gen;
103
104 public function button(): I\Component\Button\Factory
105 {
106 return new I\Component\Button\Factory();
107 }
108 public function symbol(): I\Component\Symbol\Factory
109 {
110 return new I\Component\Symbol\Factory(
111 new I\Component\Symbol\Icon\Factory(),
112 new I\Component\Symbol\Glyph\Factory(),
113 new I\Component\Symbol\Avatar\Factory()
114 );
115 }
116 };
117 $factory->sig_gen = new I\Component\SignalGenerator();
118 return $factory;
119 }
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

References ILIAS\Repository\button(), and ILIAS\Repository\symbol().

+ Here is the call graph for this function:

◆ testFullRendering()

PresentationTest::testFullRendering ( )

Definition at line 134 of file PresentationTest.php.

134 : void
135 {
136 $mapping = function ($row, $record, $ui_factory, $environment) {
137 return $row
138 ->withHeadline($record['headline'])
139 ->withSubheadline($record['subhead'])
140 ->withImportantFields($record['important_fields'])
141 ->withContent((new I\Component\Listing\Descriptive($record['content'])))
142 ->withFurtherFieldsHeadline($record['further_headline'])
143 ->withFurtherFields($record['further_fields'])
144 ->withAction((new I\Component\Button\Standard($record['action'], '#')));
145 };
146
147 $expected = <<<EXP
148<div class="il-table-presentation" id="id_3">
149 <h3 class="ilHeader">title</h3>
150 <div class="il-table-presentation-viewcontrols">
151 <div class="l-bar__space-keeper l-bar__space-keeper--space-between">
152 <div class="l-bar__group">
153 <div class="l-bar__element">
154 <button class="btn btn-default" id="id_1">presentation_table_expand</button>
155 <button class="btn btn-default" id="id_2">presentation_table_collapse</button>
156 </div>
157 </div>
158 <div class="l-bar__group"></div>
159 </div>
160 </div>
161 <div class="il-table-presentation-data">
162 <div class="il-table-presentation-row row collapsed" id="id_4">
163
164 <div class="il-table-presentation-row-controls col-lg-auto col-sm-12">
165 <div class="il-table-presentation-row-controls-expander inline">
166 <a tabindex="0" class="glyph" href="#" aria-label="expand_content" id="id_5">
167 <span class="glyphicon glyphicon-triangle-right" aria-hidden="true"></span>
168 </a>
169 </div>
170 <div class="il-table-presentation-row-controls-collapser">
171 <a tabindex="0" class="glyph" href="#" aria-label="collapse_content" id="id_6">
172 <span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span>
173 </a>
174 </div>
175 </div>
176
177 <div class="il-table-presentation-row-contents col-lg col-sm-12">
178 <div class="row">
179 <div class="il-table-presentation-row-header col-lg col-sm-12">
180 <h4 class="il-table-presentation-row-header-headline" onClick="$(document).trigger('il_signal...');">some title<br /><small>some type</small>
181 </h4>
182 <div class="il-table-presentation-row-header-fields">
183 <dl>
184 <div class="l-bar__space-keeper">
185 <div class="l-bar__group">
186 <dd class="il-table-presentation-row-header-fields-value l-bar__element">important-1</dd>
187 </div>
188 </div>
189 <div class="l-bar__space-keeper">
190 <div class="l-bar__group">
191 <dd class="il-table-presentation-row-header-fields-value l-bar__element">important-2</dd>
192 </div>
193 </div>
194 </dl>
195 <button class="btn btn-link" id="id_7">presentation_table_more</button>
196 </div>
197 </div>
198 <div class="il-table-presentation-actions col-lg-auto col-sm-12">
199 <button class="btn btn-default" data-action="#" id="id_8">do</button><br />
200 </div>
201 <div class="il-table-presentation-row-expanded col-lg-12 col-sm-12">
202 <div class="row">
203 <div class="il-table-presentation-desclist col-lg col-sm-12 desclist-column">
204 <dl>
205 <dt>1st</dt>
206 <dd>first content</dd>
207 <dt>2nd</dt>
208 <dd>second content</dd>
209 </dl>
210 </div>
211 <div class="il-table-presentation-details col-lg-5 col-sm-12">
212 <div class="il-table-presentation-fields">
213 <h5>further fields</h5>
214 <span class="il-item-property-name">f-1</span>
215 <span class="il-item-property-value">further</span>
216 <br />
217 <span class="il-item-property-name">f-2</span>
218 <span class="il-item-property-value">way further</span>
219 <br />
220 </div>
221 </div>
222 </div>
223 </div>
224 </div>
225 </div>
226 </div>
227 </div>
228</div>
229EXP;
230
231 $r = $this->getDefaultRenderer();
232 $f = $this->getTableFactory();
233 $pt = $f->presentation('title', [], $mapping);
234 $actual = $r->render($pt->withData($this->getDummyData()));
235 $this->assertEquals(
236 $this->brutallyTrimHTML($expected),
237 $this->brutallyTrimHTML($this->brutallyTrimSignals($actual))
238 );
239 }

References Vendor\Package\$f, ILIAS\Repository\button(), TableTestBase\getTableFactory(), and ILIAS\UI\examples\ViewControl\Sortation\small().

+ Here is the call graph for this function:

◆ testMinimalRendering()

PresentationTest::testMinimalRendering ( )

Definition at line 242 of file PresentationTest.php.

242 : void
243 {
244 $mapping = function ($row, $record, $ui_factory, $environment) {
245 return $row
246 ->withHeadline($record['headline'])
247 ->withContent((new I\Component\Listing\Descriptive($record['content'])));
248 };
249
250 $expected = <<<EXP
251<div class="il-table-presentation" id="id_3">
252 <h3 class="ilHeader">title</h3>
253 <div class="il-table-presentation-viewcontrols">
254
255 <div class="l-bar__space-keeper l-bar__space-keeper--space-between">
256 <div class="l-bar__group">
257 <div class="l-bar__element">
258
259 <button class="btn btn-default" id="id_1">presentation_table_expand</button>
260 <button class="btn btn-default" id="id_2">presentation_table_collapse</button>
261 </div>
262 </div>
263 <div class="l-bar__group"></div>
264 </div>
265 </div>
266 <div class="il-table-presentation-data">
267 <div class="il-table-presentation-row row collapsed" id="id_4">
268
269 <div class="il-table-presentation-row-controls col-lg-auto col-sm-12">
270 <div class="il-table-presentation-row-controls-expander inline">
271 <a tabindex="0" class="glyph" href="#" aria-label="expand_content" id="id_5">
272 <span class="glyphicon glyphicon-triangle-right" aria-hidden="true"></span>
273 </a>
274 </div>
275 <div class="il-table-presentation-row-controls-collapser">
276 <a tabindex="0" class="glyph" href="#" aria-label="collapse_content" id="id_6">
277 <span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span>
278 </a>
279 </div>
280 </div>
281
282 <div class="il-table-presentation-row-contents col-lg col-sm-12">
283 <div class="row">
284 <div class="il-table-presentation-row-header col-lg col-sm-12">
285 <h4 class="il-table-presentation-row-header-headline" onClick="$(document).trigger('il_signal...');">some title</h4>
286 <div class="il-table-presentation-row-header-fields">
287 <dl></dl>
288 <button class="btn btn-link" id="id_7">presentation_table_more</button>
289 </div>
290 </div>
291 <div class="il-table-presentation-actions col-lg-auto col-sm-12"></div>
292 <div class="il-table-presentation-row-expanded col-lg-12 col-sm-12">
293 <div class="row">
294 <div class="il-table-presentation-desclist col-lg col-sm-12">
295 <dl>
296 <dt>1st</dt>
297 <dd>first content</dd>
298 <dt>2nd</dt>
299 <dd>second content</dd>
300 </dl>
301 </div>
302 </div>
303 </div>
304 </div>
305 </div>
306
307 </div>
308 </div>
309</div>
310EXP;
311 $r = $this->getDefaultRenderer();
312 $f = $this->getTableFactory();
313 $pt = $f->presentation('title', [], $mapping);
314 $actual = $r->render($pt->withData($this->getDummyData()));
315 $this->assertEquals(
316 $this->brutallyTrimHTML($expected),
317 $this->brutallyTrimHTML($this->brutallyTrimSignals($actual))
318 );
319 }

References Vendor\Package\$f, ILIAS\Repository\button(), and TableTestBase\getTableFactory().

+ Here is the call graph for this function:

◆ testRenderEmptyTableEntry()

PresentationTest::testRenderEmptyTableEntry ( )

Definition at line 321 of file PresentationTest.php.

321 : void
322 {
323 $mapping = fn(PresentationRow $row, mixed $record, \ILIAS\UI\Factory $ui_factory, mixed $environment) => $row;
324
325 $table = $this->getTableFactory()->presentation('', [], $mapping);
326
327 $html = $this->getDefaultRenderer()->render($table);
328
329 $translation = $this->getLanguage()->txt('ui_table_no_records');
330
331 $this->assertTrue(str_contains($html, $translation));
332 }
getLanguage()

References getLanguage(), and TableTestBase\getTableFactory().

+ Here is the call graph for this function:

◆ testRowConstruction()

PresentationTest::testRowConstruction ( )

Definition at line 65 of file PresentationTest.php.

65 : void
66 {
67 $f = $this->getTableFactory();
68 $pt = $f->presentation('title', [], function (): void {
69 });
70 $row = new PresentationRow($pt->getSignalGenerator(), 'table_id');
71
72 $this->assertInstanceOf("ILIAS\\UI\\Component\\Table\\PresentationRow", $row);
73 $this->assertInstanceOf("ILIAS\\UI\\Component\\Signal", $row->getShowSignal());
74 $this->assertInstanceOf("ILIAS\\UI\\Component\\Signal", $row->getCloseSignal());
75 $this->assertInstanceOf("ILIAS\\UI\\Component\\Signal", $row->getToggleSignal());
76
77 $this->assertEquals(
78 "headline",
79 $row->withHeadline("headline")->getHeadline()
80 );
81 $this->assertEquals(
82 "subheadline",
83 $row->withSubheadline("subheadline")->getSubheadline()
84 );
85 $this->assertEquals(
86 array("f1" => "v1"),
87 $row->withImportantFields(array("f1" => "v1"))->getImportantFields()
88 );
89 $this->assertEquals(
90 "field_headline",
91 $row->withFurtherFieldsHeadline("field_headline")->getFurtherFieldsHeadline()
92 );
93 $this->assertEquals(
94 array("ff1" => "fv1"),
95 $row->withFurtherFields(array("ff1" => "fv1"))->getFurtherFields()
96 );
97 }

References Vendor\Package\$f, and TableTestBase\getTableFactory().

+ Here is the call graph for this function:

◆ testTableConstruction()

PresentationTest::testTableConstruction ( )

Definition at line 45 of file PresentationTest.php.

45 : void
46 {
47 $f = $this->getTableFactory();
48 $this->assertInstanceOf("ILIAS\\UI\\Component\\Table\\Factory", $f);
49
50 $pt = $f->presentation('title', [], function (): void {
51 });
52 $this->assertInstanceOf("ILIAS\\UI\\Component\\Table\\Presentation", $pt);
53
54 $this->assertEquals("title", $pt->getTitle());
55 $this->assertEquals([], $pt->getViewControls());
56 $this->assertInstanceOf(Closure::class, $pt->getRowMapping());
57
58 $pt = $pt
59 ->withEnvironment(array('k' => 'v'))
60 ->withData(array('dk' => 'dv'));
61 $this->assertEquals(array('k' => 'v'), $pt->getEnvironment());
62 $this->assertEquals(array('dk' => 'dv'), $pt->getData());
63 }

References Vendor\Package\$f, and TableTestBase\getTableFactory().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: