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,
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');
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>
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">
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);
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;
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);
328 $url = $data_factory->uri(
'http://wwww.ilias.de?ref_id=1');
330 list($builder,
$token) = $url_builder->acquireParameter([
'namespace'],
'param');
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;
360 ->withActions($actions)
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);
373 'f1' =>
$f->text(
"Field 1")->withIndex(1),
374 'f2' =>
$f->text(
"Field 2")->withIndex(2),
375 'f3' =>
$f->number(
"Field 3")->withIndex(3)
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'),
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));
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
form( $class_path, string $cmd, string $submit_caption="")
button(string $caption, string $cmd)
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.