19 declare(strict_types=1);
21 require_once(
"vendor/composer/vendor/autoload.php");
22 require_once(__DIR__ .
"/TableTestBase.php");
41 protected int $total_count
44 public function getRows(
45 I\
Table\DataRowBuilder $row_builder,
46 array $visible_column_ids,
50 ?array $additional_parameters
52 yield $row_builder->buildStandardRow(
'', []);
54 public function getTotalRowCount(
56 ?array $additional_parameters
58 return $this->total_count;
63 protected function getTable(
int $total_count, array $columns): array
66 $table = $factory->data($this->
getDataRetrieval($total_count),
'Table', $columns);
67 return $table->applyViewControls([], []);
74 'f1' => $factory->column()->text(
'f1'),
75 'f2' => $factory->column()->text(
'f2')->withIsOptional(
true),
78 list($table, $view_controls) = $this->
getTable($total_count, $columns);
80 $this->assertInstanceOf(
I\Input\Container\
ViewControl\ViewControl::class, $view_controls);
83 C\
Table\Data::VIEWCONTROL_KEY_PAGINATION,
84 C\
Table\Data::VIEWCONTROL_KEY_ORDERING,
85 C\
Table\Data::VIEWCONTROL_KEY_FIELDSELECTION,
87 array_keys($view_controls->getInputs())
89 foreach (array_values($view_controls->getInputs()) as $vc) {
90 $this->assertInstanceOf(
I\Input\Container\
ViewControl\ViewControlInput::class, $vc);
98 'f1' => $factory->column()->text(
'f1'),
99 'f2' => $factory->column()->text(
'f2')->withIsOptional(
true),
101 $total_count = current(
C\Input\
ViewControl\Pagination::DEFAULT_LIMITS) - 1;
102 list($table, $view_controls) = $this->
getTable($total_count, $columns);
106 C\
Table\Data::VIEWCONTROL_KEY_PAGINATION,
107 C\
Table\Data::VIEWCONTROL_KEY_ORDERING,
108 C\
Table\Data::VIEWCONTROL_KEY_FIELDSELECTION,
110 array_keys($view_controls->getInputs())
112 $this->assertInstanceOf(
114 $view_controls->getInputs()[C\Table\Data::VIEWCONTROL_KEY_PAGINATION]
117 $group_contents = $view_controls->getInputs()[C\Table\Data::VIEWCONTROL_KEY_PAGINATION]->getInputs();
120 fn($vc) => $this->assertInstanceOf(
I\Input\
ViewControl\NullControl::class, $vc)
128 'f1' => $factory->column()->text(
'f1')
129 ->withIsSortable(
false),
130 'f2' => $factory->column()->text(
'f2')
131 ->withIsSortable(
false)
132 ->withIsOptional(
true),
135 list($table, $view_controls) = $this->
getTable($total_count, $columns);
138 $inputs = $view_controls->getInputs();
141 C\
Table\Data::VIEWCONTROL_KEY_PAGINATION,
142 C\
Table\Data::VIEWCONTROL_KEY_ORDERING,
143 C\
Table\Data::VIEWCONTROL_KEY_FIELDSELECTION,
147 $this->assertInstanceOf(
157 'f1' => $factory->column()->text(
'f1')
158 ->withIsSortable(
true),
159 'f2' => $factory->column()->text(
'f2')
160 ->withIsSortable(
true)
161 ->withIsOptional(
true),
164 list($table, $view_controls) = $this->
getTable($total_count, $columns);
166 $inputs = $view_controls->getInputs();
169 C\
Table\Data::VIEWCONTROL_KEY_PAGINATION,
170 C\
Table\Data::VIEWCONTROL_KEY_ORDERING,
171 C\
Table\Data::VIEWCONTROL_KEY_FIELDSELECTION,
175 $this->assertInstanceOf(
185 'f1' => $factory->column()->text(
'f1'),
186 'f2' => $factory->column()->text(
'f2'),
189 list($table, $view_controls) = $this->
getTable($total_count, $columns);
193 C\
Table\Data::VIEWCONTROL_KEY_PAGINATION,
194 C\
Table\Data::VIEWCONTROL_KEY_ORDERING,
196 array_keys($view_controls->getInputs())
203 $request = $this->createMock(ServerRequestInterface::class);
206 ->willReturn(
new \
GuzzleHttp\Psr7\Uri(
'http://localhost:80'));
208 ->method(
"getQueryParams")
209 ->willReturn($returns);
217 'f1' => $factory->column()->text(
'f1')->withIsOptional(
true),
218 'f2' => $factory->column()->text(
'f2')->withIsOptional(
true),
219 'f3' => $factory->column()->text(
'f3')->withIsOptional(
true),
222 list($base_table, $view_controls) = $this->
getTable($total_count, $columns);
224 $table_id =
'testing_data_table';
229 'view_control/input_0/input_1' => 0,
230 'view_control/input_0/input_2' => 10,
231 'view_control/input_3/input_4' =>
'f2',
232 'view_control/input_3/input_5' =>
'DESC',
233 'view_control/input_6' => [
'f2']
236 list($table, $view_controls) = $table->applyViewControls([], []);
238 $this->assertEquals(
new Range(0, 10), $table->getRange());
239 $this->assertEquals(
new Order(
'f2', Order::DESC), $table->getOrder());
240 $this->assertEquals(1, count($table->getSelectedOptionalColumns()));
246 list($table, $view_controls) = $table->applyViewControls([], []);
247 $this->assertEquals(
new Range(0, 12), $table->getRange());
248 $this->assertEquals(
new Order(
'f1', Order::ASC), $table->getOrder());
249 $this->assertEquals(3, count($table->getSelectedOptionalColumns()));
255 list($table, $view_controls) = $table->applyViewControls([], []);
256 $this->assertEquals(
new Range(0, 10), $table->getRange());
257 $this->assertEquals(
new Order(
'f2', Order::DESC), $table->getOrder());
258 $this->assertEquals(1, count($table->getSelectedOptionalColumns()));
testDataTableHasNoOrderingViewControlDueToRecordCount()
testDataTableHasNoFieldSelectionViewControl()
getDataRetrieval(int $total_count)
Tests for the Data Table.
testDataTableHasNoOrderingViewControl()
Both the subject and the direction need to be specified when expressing an order. ...
testDataTableViewControlStorage()
testDataTableHasNoPaginationViewControl()
testDataTableHasViewControls()
__construct(Container $dic, ilPlugin $plugin)
getRequestMock(array $returns)
A simple class to express a naive range of whole positive numbers.
Basic Tests for all Tables.
getTable(int $total_count, array $columns)