19declare(strict_types=1);
21require_once(
"vendor/composer/vendor/autoload.php");
22require_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);
83 $this->getTemplateFactory(),
85 $this->getJavaScriptBinding(),
89 $this->getUploadLimitResolver()
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);
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);
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())
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);
172 public function getRows(
174 array $visible_column_ids,
177 mixed $additional_viewcontrol_data,
179 mixed $additional_parameters
181 yield $row_builder->buldDataRow(
'', []);
183 public function getTotalRowCount(
184 mixed $additional_viewcontrol_data,
186 mixed $additional_parameters
192 'f1' =>
$f->text(
"Field 1")->withIndex(1),
193 'f2' =>
$f->text(
"Field 2")->withIndex(2)->withIsSortable(
false),
194 'f3' =>
$f->number(
"Field 3")->withIndex(3)
196 $sortation_signal =
new I\Signal(
'sort_header_signal_id');
197 $sortation_signal->addOption(
'value',
'f1:ASC');
200 $renderer->p_renderTableHeader($this->getDefaultRenderer(), $table, $tpl, $sortation_signal);
202 $actual = $this->brutallyTrimHTML($tpl->get());
204<div
class=
"c-table-data" id=
"{ID}">
205 <div
class=
"viewcontrols">{VIEW_CONTROLS}</div>
206 <div
class=
"c-table-data__table-wrapper">
207 <table
class=
"c-table-data__table" aria-labelledby=
"{ID}_label" aria-colcount=
"{COL_COUNT}" role=
"grid">
209 <tr
class=
"c-table-data__header c-table-data__row">
210 <th
class=
"c-table-data__header c-table-data__cell c-table-data__cell--text" tabindex=
"-1" aria-colindex=
"1" aria-
sort=
"ascending">
211 <div
class=
"c-table-data__header__resize-wrapper">
212 <a tabindex=
"0" class=
"glyph" href=
"#" aria-label=
"sort_ascending" id=
"id_2"><span
class=
"glyphicon glyphicon-arrow-up" aria-hidden=
"true"></span></a>
216 <th
class=
"c-table-data__header c-table-data__cell c-table-data__cell--text" tabindex=
"-1" aria-colindex=
"2">
217 <div
class=
"c-table-data__header__resize-wrapper">Field 2</div>
219 <th
class=
"c-table-data__header c-table-data__cell c-table-data__cell--number" tabindex=
"-1" aria-colindex=
"3">
220 <div
class=
"c-table-data__header__resize-wrapper">
226 <tbody
class=
"c-table-data__body"></tbody>
229 <div
class=
"c-table-data__async_modal_container"></div>
230 <dialog
class=
"c-table-data__async_message c-modal" id=
"{ID}_msgmodal">
231 <div
class=
"modal-dialog" role=
"document">
232 <div
class=
"modal-content">
233 <div
class=
"modal-header">
235 <
button formmethod=
"dialog" class=
"close" aria-label=
"close">
236 <span aria-hidden=
"true">×</span></
button>
239 <div
class=
"c-table-data__async_messageresponse modal-body"></div>
245 $expected = $this->brutallyTrimHTML($expected);
246 $this->assertEquals($expected, $actual);
253 $data_factory = new \ILIAS\Data\Factory();
254 $tpl = $this->getTemplateFactory()->getTemplate(
"components/ILIAS/UI/src/templates/default/Table/tpl.datatable.html",
true,
true);
257 public function getRows(
259 array $visible_column_ids,
262 mixed $additional_viewcontrol_data,
264 mixed $additional_parameters
266 yield $row_builder->buldDataRow(
'', []);
268 public function getTotalRowCount(
269 mixed $additional_viewcontrol_data,
271 mixed $additional_parameters
277 'f1' =>
$f->text(
"Field 1")->withIsSortable(
false),
278 'f2' =>
$f->text(
"Field 2")->withIsSortable(
false)
281 $sortation_signal =
null;
285 $renderer->p_renderTableHeader($this->getDefaultRenderer(), $table, $tpl, $sortation_signal);
286 $actual = $this->brutallyTrimHTML($tpl->get());
288<div
class=
"c-table-data" id=
"{ID}">
289 <div
class=
"viewcontrols">{VIEW_CONTROLS}</div>
290 <div
class=
"c-table-data__table-wrapper">
291 <table
class=
"c-table-data__table" aria-labelledby=
"{ID}_label" aria-colcount=
"{COL_COUNT}" role=
"grid">
293 <tr
class=
"c-table-data__header c-table-data__row">
294 <th
class=
"c-table-data__header c-table-data__cell c-table-data__cell--text" tabindex=
"-1" aria-colindex=
"1">
295 <div
class=
"c-table-data__header__resize-wrapper">Field 1</div>
297 <th
class=
"c-table-data__header c-table-data__cell c-table-data__cell--text" tabindex=
"-1" aria-colindex=
"2">
298 <div
class=
"c-table-data__header__resize-wrapper">Field 2</div>
302 <tbody
class=
"c-table-data__body"></tbody>
305 <div
class=
"c-table-data__async_modal_container"></div>
306 <dialog
class=
"c-table-data__async_message c-modal" id=
"{ID}_msgmodal">
307 <div
class=
"modal-dialog" role=
"document">
308 <div
class=
"modal-content">
309 <div
class=
"modal-header">
311 <
button formmethod=
"dialog" class=
"close" aria-label=
"close">
312 <span aria-hidden=
"true">×</span></
button>
315 <div
class=
"c-table-data__async_messageresponse modal-body"></div>
321 $expected = $this->brutallyTrimHTML($expected);
322 $this->assertEquals($expected, $actual);
328 $data_factory = new \ILIAS\Data\Factory();
329 $tpl = $this->getTemplateFactory()->getTemplate(
"components/ILIAS/UI/src/templates/default/Table/tpl.datatable.html",
true,
true);
332 $url = $data_factory->uri(
'http://wwww.ilias.de?ref_id=1');
334 list($builder,
$token) = $url_builder->acquireParameter([
'namespace'],
'param');
340 public function getRows(
342 array $visible_column_ids,
345 mixed $additional_viewcontrol_data,
347 mixed $additional_parameters
349 yield $row_builder->buldDataRow(
'', []);
351 public function getTotalRowCount(
352 mixed $additional_viewcontrol_data,
354 mixed $additional_parameters
360 'f1' =>
$f->text(
"Field 1")->withIsSortable(
false),
363 $sortation_signal =
null;
366 ->withActions($actions)
368 $renderer->p_renderActionsHeader($this->getDefaultRenderer(), $table, $tpl);
369 $actual = $this->brutallyTrimHTML($tpl->get());
371 $expected =
'<th class="c-table-data__header c-table-data__cell c-table-data__header__rowaction" aria-colindex="2">actions</th>';
372 $this->assertStringContainsString($expected, $actual);
379 'f1' =>
$f->text(
"Field 1")->withIndex(1),
380 'f2' =>
$f->text(
"Field 2")->withIndex(2),
381 'f3' =>
$f->number(
"Field 3")->withIndex(3)
386 list($builder,
$token) = $url_builder->acquireParameter([
'namespace'],
'param');
388 'a1' =>
$f->standard(
'label1', $builder,
$token)->withAsync(),
389 'a2' =>
$f->standard(
'label2', $builder,
$token)
392 $rb = (
new I\Table\DataRowBuilder())
393 ->withMultiActionsPresent(
true)
394 ->withSingleActions($actions)
395 ->withVisibleColumns($columns);
397 $row = $rb->buildDataRow(
'row_id-1', []);
400 return [$rb, $columns, $actions];
403 #[\PHPUnit\Framework\Attributes\Depends('testDataTableRowBuilder')]
406 list($rb, $columns, $actions) =
$params;
412 $row = $rb->buildDataRow(
'row_id-1', $record);
424 $row->getCellContent(
'f2')
430 #[\PHPUnit\Framework\Attributes\Depends('testDataTableDataRowFromBuilder')]
433 $actual = $this->brutallyTrimHTML($this->getDefaultRenderer()->render($row));
435<td
class=
"c-table-data__cell c-table-data__rowselection" tabindex=
"-1">
436 <input type=
"checkbox" value=
"row_id-1" class=
"c-table-data__row-selector"></td>
437<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
439<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
441<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
443<td
class=
"c-table-data__cell c-table-data__rowaction" tabindex=
"-1">
444 <div
class=
"dropdown" id=
"id_3">
445 <
button class=
"btn btn-default dropdown-toggle" type=
"button" aria-label=
"actions" aria-haspopup=
"true" aria-expanded=
"false" aria-controls=
"id_3_menu">
446 <span
class=
"caret"></span></
button>
447 <ul
id=
"id_3_menu" class=
"dropdown-menu">
449 <
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>
452 <
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>
459 $expected = $this->brutallyTrimHTML($expected);
460 $this->assertEquals($expected, $actual);
466 public function getRows(
468 array $visible_column_ids,
471 mixed $additional_viewcontrol_data,
473 mixed $additional_parameters
478 public function getTotalRowCount(
479 mixed $additional_viewcontrol_data,
481 mixed $additional_parameters
488 'f1' => $this->
getUIFactory()->table()->column()->text(
'f1'),
489 'f2' => $this->
getUIFactory()->table()->column()->text(
'f2'),
490 'f3' => $this->
getUIFactory()->table()->column()->text(
'f3'),
491 'f4' => $this->
getUIFactory()->table()->column()->text(
'f4'),
492 'f5' => $this->
getUIFactory()->table()->column()->text(
'f5'),
498 $html = $this->getDefaultRenderer()->render($table);
500 $translation = $this->
getLanguage()->txt(
'ui_table_no_records');
501 $column_count = count($columns);
504 $this->assertTrue(str_contains($html,
"colspan=\"$column_count\""));
506 $this->assertTrue(str_contains($html, $translation));
wrapper around the renderer to expose protected functions
p_renderTableHeader(TestDefaultRenderer $default_renderer, I\Table\Data $component, $tpl, ?I\Signal $sortation_signal)
p_renderActionsHeader(TestDefaultRenderer $default_renderer, I\Table\Data $component, $tpl)
p_getMultiActionHandler(I\Signal $signal)
p_getSingleActionsForRow(string $row_id, array $actions)
p_getActionRegistration(string $action_id, I\Table\Action\Action $action)
p_buildMultiActionsDropdown(array $actions, I\Signal $action_signal, I\Signal $modal_signal)
Tests for the Renderer of DataTables.
testDataTableMultiActionsDropdown()
testDataTableGetMultiActionHandler()
testRenderEmptyDataCell()
testDataTableSingleActionsDropdown()
testDataTableRenderHeaderWithActions()
testDataTableDataRowFromBuilder(array $params)
testDataTableRenderTableHeader()
testDataTableRenderStandardRow(I\Table\DataRow $row)
testDataTableRenderHeaderWithoutSortableColums()
testDataTableGetActionRegistration()
testDataTableRowBuilder()
Both the subject and the direction need to be specified when expressing an order.
A simple class to express a naive range of whole positive numbers.
Tests for the Renderer of DataTables.
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
button(string $caption, string $cmd)
form(?array $class_path, string $cmd, string $submit_caption="")
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.