19 declare(strict_types=1);
21 require_once(
"vendor/composer/vendor/autoload.php");
22 require_once(__DIR__ .
"/TableRendererTestBase.php");
36 return $this->getMultiActionHandler($signal);
41 return $this->getActionRegistration($action_id, $action);
49 return $this->buildMultiActionsDropdown($actions, $action_signal, $modal_signal);
54 return $this->getSingleActionsForRow($row_id, $actions);
63 $this->renderTableHeader($default_renderer, $component, $tpl, $sortation_signal, 1);
70 $this->renderActionsHeader($default_renderer, $component, $tpl, 1);
82 $this->getUIFactory(),
83 $this->getTemplateFactory(),
85 $this->getJavaScriptBinding(),
88 new \
ILIAS\
UI\Help\TextRetriever\Echoing(),
89 $this->getUploadLimitResolver()
96 $signal =
new I\Signal(
'signal_id');
97 $closure =
$renderer->p_getMultiActionHandler($signal);
98 $actual = $this->brutallyTrimHTML($closure(
'component_id'));
99 $expected = $this->brutallyTrimHTML(
100 "$(document).on('signal_id', function(event, signal_data) { 101 il.UI.table.data.get('component_id').doMultiAction(signal_data); 105 $this->assertEquals($expected, $actual);
111 $f = $this->getActionFactory();
114 list($builder,
$token) = $url_builder->acquireParameter([
'namespace'],
'param');
116 $action =
$f->standard(
'label', $builder,
$token);
117 $closure =
$renderer->p_getActionRegistration(
'action_id', $action);
119 $actual = $this->brutallyTrimHTML($closure(
'component_id'));
121 $expected = $this->brutallyTrimHTML(
122 'il.UI.table.data.get(\'component_id\').registerAction(\'action_id\', false, new il.UI.core.URLBuilder(new URL("http://wwww.ilias.de?ref_id=1&namespace_param="), new Map([["namespace_param",new il.UI.core.URLBuilderToken(["namespace"], "param",' 124 $this->assertStringStartsWith($expected, $actual);
130 $f = $this->getActionFactory();
131 $signal1 =
new I\Signal(
'signal_id');
132 $signal2 =
new I\Signal(
'signal_id2');
135 list($builder,
$token) = $url_builder->acquireParameter([
'namespace'],
'param');
137 $f->standard(
'label1', $builder,
$token),
138 $f->standard(
'label2', $builder,
$token)
141 $renderer->p_buildMultiActionsDropdown([], $signal1, $signal2)
145 count(
$renderer->p_buildMultiActionsDropdown($actions, $signal1, $signal2)->getItems())
151 $f = $this->getActionFactory();
154 list($builder,
$token) = $url_builder->acquireParameter([
'namespace'],
'param');
156 'a1' =>
$f->standard(
'label1', $builder,
$token)->withAsync(),
157 'a2' =>
$f->standard(
'label2', $builder,
$token)
161 count(
$renderer->p_getSingleActionsForRow(
'row_id-1', $actions)->getItems())
168 $data_factory = new \ILIAS\Data\Factory();
169 $tpl = $this->getTemplateFactory()->getTemplate(
"components/ILIAS/UI/src/templates/default/Table/tpl.datatable.html",
true,
true);
170 $f = $this->getColumnFactory();
172 public function getRows(
174 array $visible_column_ids,
178 ?array $additional_parameters
180 yield $row_builder->buldDataRow(
'', []);
182 public function getTotalRowCount(
184 ?array $additional_parameters
190 'f1' =>
$f->text(
"Field 1")->withIndex(1),
191 'f2' =>
$f->text(
"Field 2")->withIndex(2)->withIsSortable(
false),
192 'f3' =>
$f->number(
"Field 3")->withIndex(3)
194 $sortation_signal =
new I\Signal(
'sort_header_signal_id');
195 $sortation_signal->addOption(
'value',
'f1:ASC');
196 $table = $this->getUIFactory()->table()->data(
$data,
'', $columns)
197 ->withRequest($this->getDummyRequest());
198 $renderer->p_renderTableHeader($this->getDefaultRenderer(), $table, $tpl, $sortation_signal);
200 $actual = $this->brutallyTrimHTML($tpl->get());
202 <div
class=
"c-table-data" id=
"{ID}">
203 <div
class=
"viewcontrols">{VIEW_CONTROLS}</div>
204 <div
class=
"c-table-data__table-wrapper">
205 <table
class=
"c-table-data__table" aria-labelledby=
"{ID}_label" aria-colcount=
"{COL_COUNT}" role=
"grid">
207 <tr
class=
"c-table-data__header c-table-data__row">
208 <th
class=
"c-table-data__header c-table-data__cell c-table-data__cell--text" tabindex=
"-1" aria-colindex=
"1" aria-
sort=
"ascending">
209 <div
class=
"c-table-data__header__resize-wrapper">
210 <a tabindex=
"0" class=
"glyph" href=
"#" aria-label=
"sort_ascending" id=
"id_2"><span
class=
"glyphicon glyphicon-arrow-up" aria-hidden=
"true"></span></a>
211 <
button class=
"btn btn-link" id=
"id_1">Field 1</button>
214 <th
class=
"c-table-data__header c-table-data__cell c-table-data__cell--text" tabindex=
"-1" aria-colindex=
"2">
215 <div
class=
"c-table-data__header__resize-wrapper">Field 2</div>
217 <th
class=
"c-table-data__header c-table-data__cell c-table-data__cell--number" tabindex=
"-1" aria-colindex=
"3">
218 <div
class=
"c-table-data__header__resize-wrapper">
219 <button
class=
"btn btn-link" id=
"id_3">Field 3</button>
224 <tbody
class=
"c-table-data__body"></tbody>
227 <div
class=
"c-table-data__async_modal_container"></div>
228 <dialog
class=
"c-table-data__async_message c-modal" id=
"{ID}_msgmodal">
229 <div
class=
"modal-dialog" role=
"document">
230 <div
class=
"modal-content">
231 <div
class=
"modal-header">
233 <button formmethod=
"dialog" class=
"close" aria-label=
"close">
234 <span aria-hidden=
"true">×</span></button>
237 <div
class=
"c-table-data__async_messageresponse modal-body"></div>
243 $expected = $this->brutallyTrimHTML($expected);
244 $this->assertEquals($expected, $actual);
251 $data_factory = new \ILIAS\Data\Factory();
252 $tpl = $this->getTemplateFactory()->getTemplate(
"components/ILIAS/UI/src/templates/default/Table/tpl.datatable.html",
true,
true);
253 $f = $this->getColumnFactory();
255 public function getRows(
257 array $visible_column_ids,
261 ?array $additional_parameters
263 yield $row_builder->buldDataRow(
'', []);
265 public function getTotalRowCount(
267 ?array $additional_parameters
273 'f1' =>
$f->text(
"Field 1")->withIsSortable(
false),
274 'f2' =>
$f->text(
"Field 2")->withIsSortable(
false)
277 $sortation_signal =
null;
279 $table = $this->getUIFactory()->table()->data(
$data,
'', $columns)
280 ->withRequest($this->getDummyRequest());
281 $renderer->p_renderTableHeader($this->getDefaultRenderer(), $table, $tpl, $sortation_signal);
282 $actual = $this->brutallyTrimHTML($tpl->get());
284 <div
class=
"c-table-data" id=
"{ID}">
285 <div
class=
"viewcontrols">{VIEW_CONTROLS}</div>
286 <div
class=
"c-table-data__table-wrapper">
287 <table
class=
"c-table-data__table" aria-labelledby=
"{ID}_label" aria-colcount=
"{COL_COUNT}" role=
"grid">
289 <tr
class=
"c-table-data__header c-table-data__row">
290 <th
class=
"c-table-data__header c-table-data__cell c-table-data__cell--text" tabindex=
"-1" aria-colindex=
"1">
291 <div
class=
"c-table-data__header__resize-wrapper">Field 1</div>
293 <th
class=
"c-table-data__header c-table-data__cell c-table-data__cell--text" tabindex=
"-1" aria-colindex=
"2">
294 <div
class=
"c-table-data__header__resize-wrapper">Field 2</div>
298 <tbody
class=
"c-table-data__body"></tbody>
301 <div
class=
"c-table-data__async_modal_container"></div>
302 <dialog
class=
"c-table-data__async_message c-modal" id=
"{ID}_msgmodal">
303 <div
class=
"modal-dialog" role=
"document">
304 <div
class=
"modal-content">
305 <div
class=
"modal-header">
307 <
button formmethod=
"dialog" class=
"close" aria-label=
"close">
308 <span aria-hidden=
"true">×</span></
button>
311 <div
class=
"c-table-data__async_messageresponse modal-body"></div>
317 $expected = $this->brutallyTrimHTML($expected);
318 $this->assertEquals($expected, $actual);
324 $data_factory = new \ILIAS\Data\Factory();
325 $tpl = $this->getTemplateFactory()->getTemplate(
"components/ILIAS/UI/src/templates/default/Table/tpl.datatable.html",
true,
true);
326 $f = $this->getColumnFactory();
328 $url = $data_factory->uri(
'http://wwww.ilias.de?ref_id=1');
330 list($builder,
$token) = $url_builder->acquireParameter([
'namespace'],
'param');
332 'a2' => $this->getActionFactory()->standard(
'some action', $builder,
$token)
336 public function getRows(
338 array $visible_column_ids,
342 ?array $additional_parameters
344 yield $row_builder->buldDataRow(
'', []);
346 public function getTotalRowCount(
348 ?array $additional_parameters
354 'f1' =>
$f->text(
"Field 1")->withIsSortable(
false),
357 $sortation_signal =
null;
359 $table = $this->getUIFactory()->table()->data(
$data,
'', $columns)
360 ->withActions($actions)
361 ->withRequest($this->getDummyRequest());
362 $renderer->p_renderActionsHeader($this->getDefaultRenderer(), $table, $tpl);
363 $actual = $this->brutallyTrimHTML($tpl->get());
365 $expected =
'<th class="c-table-data__header c-table-data__cell c-table-data__header__rowaction" aria-colindex="2">actions</th>';
366 $this->assertStringContainsString($expected, $actual);
371 $f = $this->getColumnFactory();
373 'f1' =>
$f->text(
"Field 1")->withIndex(1),
374 'f2' =>
$f->text(
"Field 2")->withIndex(2),
375 'f3' =>
$f->number(
"Field 3")->withIndex(3)
377 $f = $this->getActionFactory();
380 list($builder,
$token) = $url_builder->acquireParameter([
'namespace'],
'param');
382 'a1' =>
$f->standard(
'label1', $builder,
$token)->withAsync(),
383 'a2' =>
$f->standard(
'label2', $builder,
$token)
386 $rb = (
new I\Table\DataRowBuilder())
387 ->withMultiActionsPresent(
true)
388 ->withSingleActions($actions)
389 ->withVisibleColumns($columns);
391 $row = $rb->buildDataRow(
'row_id-1', []);
394 return [$rb, $columns, $actions];
397 #[\PHPUnit\Framework\Attributes\Depends('testDataTableRowBuilder')] 400 list($rb, $columns, $actions) =
$params;
406 $row = $rb->buildDataRow(
'row_id-1', $record);
418 $row->getCellContent(
'f2')
424 #[\PHPUnit\Framework\Attributes\Depends('testDataTableDataRowFromBuilder')] 427 $actual = $this->brutallyTrimHTML($this->getDefaultRenderer()->render($row));
429 <td
class=
"c-table-data__cell c-table-data__rowselection" tabindex=
"-1">
430 <input type=
"checkbox" value=
"row_id-1" class=
"c-table-data__row-selector"></td>
431 <td
class=
"c-table-data__cell c-table-data__cell--text " tabindex=
"-1"><span
class=
"c-table-data__cell__col-title">Field 1:</span>v1
433 <td
class=
"c-table-data__cell c-table-data__cell--text " tabindex=
"-1"><span
class=
"c-table-data__cell__col-title">Field 2:</span>v2
435 <td
class=
"c-table-data__cell c-table-data__cell--number " tabindex=
"-1"><span
class=
"c-table-data__cell__col-title">Field 3:</span>3
437 <td
class=
"c-table-data__cell c-table-data__rowaction" tabindex=
"-1">
438 <div
class=
"dropdown" id=
"id_3">
439 <
button class=
"btn btn-default dropdown-toggle" type=
"button" aria-label=
"actions" aria-haspopup=
"true" aria-expanded=
"false" aria-controls=
"id_3_menu">
440 <span
class=
"caret"></span></
button>
441 <ul
id=
"id_3_menu" class=
"dropdown-menu">
443 <
button class=
"btn btn-link" data-action=
"http://wwww.ilias.de?ref_id=1&namespace_param%5B%5D=row_id-1" id=
"id_1">label1</button>
446 <button
class=
"btn btn-link" data-action=
"http://wwww.ilias.de?ref_id=1&namespace_param%5B%5D=row_id-1" id=
"id_2">label2</button>
453 $expected = $this->brutallyTrimHTML($expected);
454 $this->assertEquals($expected, $actual);
460 public function getRows(
462 array $visible_column_ids,
466 ?array $additional_parameters
471 public function getTotalRowCount(?array $filter_data, ?array $additional_parameters): ?
int 478 'f1' => $this->getUIFactory()->table()->column()->text(
'f1'),
479 'f2' => $this->getUIFactory()->table()->column()->text(
'f2'),
480 'f3' => $this->getUIFactory()->table()->column()->text(
'f3'),
481 'f4' => $this->getUIFactory()->table()->column()->text(
'f4'),
482 'f5' => $this->getUIFactory()->table()->column()->text(
'f5'),
485 $table = $this->getTableFactory()->data(
$data,
'', $columns)
486 ->withRequest($this->getDummyRequest());
488 $html = $this->getDefaultRenderer()->render($table);
490 $translation = $this->
getLanguage()->txt(
'ui_table_no_records');
491 $column_count = count($columns);
494 $this->assertTrue(str_contains($html,
"colspan=\"$column_count\""));
496 $this->assertTrue(str_contains($html, $translation));
testDataTableDataRowFromBuilder(array $params)
p_buildMultiActionsDropdown(array $actions, I\Signal $action_signal, I\Signal $modal_signal)
button(string $caption, string $cmd)
testDataTableMultiActionsDropdown()
testDataTableGetActionRegistration()
testRenderEmptyDataCell()
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Interface Observer Contains several chained tasks and infos about them.
Tests for the Renderer of DataTables.
testDataTableRenderStandardRow(I\Table\DataRow $row)
p_getSingleActionsForRow(string $row_id, array $actions)
p_renderTableHeader(TestDefaultRenderer $default_renderer, I\Table\Data $component, $tpl, ?I\Signal $sortation_signal)
sort()
description: > Example for rendering a Sort Glyph.
Both the subject and the direction need to be specified when expressing an order. ...
p_renderActionsHeader(TestDefaultRenderer $default_renderer, I\Table\Data $component, $tpl)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
testDataTableRenderTableHeader()
testDataTableRenderHeaderWithActions()
testDataTableRenderHeaderWithoutSortableColums()
Tests for the Renderer of DataTables.
wrapper around the renderer to expose protected functions
p_getActionRegistration(string $action_id, I\Table\Action\Action $action)
testDataTableRowBuilder()
testDataTableGetMultiActionHandler()
form( $class_path, string $cmd, string $submit_caption="")
p_getMultiActionHandler(I\Signal $signal)
testDataTableSingleActionsDropdown()
A simple class to express a naive range of whole positive numbers.