ILIAS  trunk Revision v12.0_alpha-1329-g1094ddb0c33
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 <button class="btn btn-link" aria-label="expand_content" id="id_5"><span class="glyph" aria-hidden="true"><span class="glyphicon glyphicon-triangle-right" aria-hidden="true"></span></span></button>
167 </div>
168 <div class="il-table-presentation-row-controls-collapser">
169 <button class="btn btn-link" aria-label="collapse_content" id="id_6"><span class="glyph" aria-hidden="true"><span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span></span></button>
170 </div>
171 </div>
172
173 <div class="il-table-presentation-row-contents col-lg col-sm-12">
174 <div class="row">
175 <div class="il-table-presentation-row-header col-lg col-sm-12">
176 <h4 class="il-table-presentation-row-header-headline" onClick="$(document).trigger('il_signal...');">some title<br /><small>some type</small>
177 </h4>
178 <div class="il-table-presentation-row-header-fields">
179 <dl>
180 <div class="l-bar__space-keeper">
181 <div class="l-bar__group">
182 <dd class="il-table-presentation-row-header-fields-value l-bar__element">important-1</dd>
183 </div>
184 </div>
185 <div class="l-bar__space-keeper">
186 <div class="l-bar__group">
187 <dd class="il-table-presentation-row-header-fields-value l-bar__element">important-2</dd>
188 </div>
189 </div>
190 </dl>
191 <button class="btn btn-link" id="id_7">presentation_table_more</button>
192 </div>
193 </div>
194 <div class="il-table-presentation-actions col-lg-auto col-sm-12">
195 <button class="btn btn-default" data-action="#" id="id_8">do</button><br />
196 </div>
197 <div class="il-table-presentation-row-expanded col-lg-12 col-sm-12">
198 <div class="row">
199 <div class="il-table-presentation-desclist col-lg col-sm-12 desclist-column">
200 <dl>
201 <dt>1st</dt>
202 <dd>first content</dd>
203 <dt>2nd</dt>
204 <dd>second content</dd>
205 </dl>
206 </div>
207 <div class="il-table-presentation-details col-lg-5 col-sm-12">
208 <div class="il-table-presentation-fields">
209 <h5>further fields</h5>
210 <span class="il-item-property-name">f-1</span>
211 <span class="il-item-property-value">further</span>
212 <br />
213 <span class="il-item-property-name">f-2</span>
214 <span class="il-item-property-value">way further</span>
215 <br />
216 </div>
217 </div>
218 </div>
219 </div>
220 </div>
221 </div>
222 </div>
223 </div>
224</div>
225EXP;
226
227 $r = $this->getDefaultRenderer();
228 $f = $this->getTableFactory();
229 $pt = $f->presentation('title', [], $mapping);
230 $actual = $r->render($pt->withData($this->getDummyData()));
231 $this->assertEquals(
232 $this->brutallyTrimHTML($expected),
233 $this->brutallyTrimHTML($this->brutallyTrimSignals($actual))
234 );
235 }

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 238 of file PresentationTest.php.

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

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

+ Here is the call graph for this function:

◆ testRenderEmptyTableEntry()

PresentationTest::testRenderEmptyTableEntry ( )

Definition at line 313 of file PresentationTest.php.

313 : void
314 {
315 $mapping = fn(PresentationRow $row, mixed $record, \ILIAS\UI\Factory $ui_factory, mixed $environment) => $row;
316
317 $table = $this->getTableFactory()->presentation('', [], $mapping);
318
319 $html = $this->getDefaultRenderer()->render($table);
320
321 $translation = $this->getLanguage()->txt('ui_table_no_records');
322
323 $this->assertTrue(str_contains($html, $translation));
324 }
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: