ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
DataViewControlsTest Class Reference

Tests for the Data Table. More...

+ Inheritance diagram for DataViewControlsTest:
+ Collaboration diagram for DataViewControlsTest:

Public Member Functions

 testDataTableHasViewControls ()
 
 testDataTableHasNoPaginationViewControl ()
 
 testDataTableHasNoOrderingViewControl ()
 
 testDataTableHasNoFieldSelectionViewControl ()
 
 testDataTableViewControlStorage ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML (string $html)
 
 assertHTMLEquals (string $expected_html_as_string, string $html_as_string)
 

Protected Member Functions

 getDataRetrieval (int $total_count)
 
 getTable (int $total_count, array $columns)
 
- Protected Member Functions inherited from TableTestBase
 buildFieldFactory ()
 
 buildRefinery ()
 
 getViewControlFactory ()
 
 getViewControlContainerFactory ()
 
 getTableFactory ()
 
 getMockStorage ()
 
- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML (string $html)
 A more radical version of normalizeHTML. More...
 
 brutallyTrimSignals (string $html)
 A naive replacement of all il_signal-ids with dots to ease comparisons of rendered output. More...
 

Private Member Functions

 getRequestMock (array $returns)
 

Detailed Description

Tests for the Data Table.

Definition at line 35 of file DataViewControlsTest.php.

Member Function Documentation

◆ getDataRetrieval()

DataViewControlsTest::getDataRetrieval ( int  $total_count)
protected

Definition at line 37 of file DataViewControlsTest.php.

References ILIAS\GlobalScreen\Provider\__construct().

Referenced by getTable().

37  : I\Table\DataRetrieval
38  {
39  return new class ($total_count) implements I\Table\DataRetrieval {
40  protected int $total_count;
41  public function __construct(
42  int $total_count
43  ) {
44  $this->total_count = $total_count;
45  }
46  public function getRows(
47  I\Table\DataRowBuilder $row_builder,
48  array $visible_column_ids,
49  Range $range,
50  Order $order,
51  ?array $filter_data,
52  ?array $additional_parameters
53  ): \Generator {
54  yield $row_builder->buildStandardRow('', []);
55  }
56  public function getTotalRowCount(
57  ?array $filter_data,
58  ?array $additional_parameters
59  ): ?int {
60  return $this->total_count;
61  }
62  };
63  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Both the subject and the direction need to be specified when expressing an order. ...
Definition: Order.php:12
__construct(Container $dic, ilPlugin $plugin)
A simple class to express a range of whole positive numbers.
Definition: Range.php:30
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRequestMock()

DataViewControlsTest::getRequestMock ( array  $returns)
private

Definition at line 168 of file DataViewControlsTest.php.

Referenced by testDataTableViewControlStorage().

168  : ServerRequestInterface
169  {
170  $request = $this->createMock(ServerRequestInterface::class);
171  $request
172  ->method("getUri")
173  ->willReturn(new class () {
174  public function __toString()
175  {
176  return 'http://localhost:80';
177  }
178  });
179  $request
180  ->method("getQueryParams")
181  ->willReturn($returns);
182  return $request;
183  }
+ Here is the caller graph for this function:

◆ getTable()

DataViewControlsTest::getTable ( int  $total_count,
array  $columns 
)
protected

Definition at line 65 of file DataViewControlsTest.php.

References $factory, getDataRetrieval(), and TableTestBase\getTableFactory().

Referenced by testDataTableHasNoFieldSelectionViewControl(), testDataTableHasNoOrderingViewControl(), testDataTableHasNoPaginationViewControl(), testDataTableHasViewControls(), and testDataTableViewControlStorage().

65  : array
66  {
67  $factory = $this->getTableFactory();
68  $table = $factory->data('Table', $columns, $this->getDataRetrieval($total_count));
69  return $table->applyViewControls([], []);
70  }
getDataRetrieval(int $total_count)
$factory
Definition: metadata.php:75
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testDataTableHasNoFieldSelectionViewControl()

DataViewControlsTest::testDataTableHasNoFieldSelectionViewControl ( )

Definition at line 148 of file DataViewControlsTest.php.

References $factory, getTable(), and TableTestBase\getTableFactory().

148  : void
149  {
150  $factory = $this->getTableFactory();
151  $columns = [
152  'f1' => $factory->column()->text('f1'),
153  'f2' => $factory->column()->text('f2'),
154  ];
155  $total_count = 200;
156  list($table, $view_controls) = $this->getTable($total_count, $columns);
157 
158  $this->assertEquals(
159  [
160  C\Table\Data::VIEWCONTROL_KEY_PAGINATION,
161  C\Table\Data::VIEWCONTROL_KEY_ORDERING,
162  ],
163  array_keys($view_controls->getInputs())
164  );
165  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$factory
Definition: metadata.php:75
getTable(int $total_count, array $columns)
+ Here is the call graph for this function:

◆ testDataTableHasNoOrderingViewControl()

DataViewControlsTest::testDataTableHasNoOrderingViewControl ( )

Definition at line 126 of file DataViewControlsTest.php.

References $factory, getTable(), and TableTestBase\getTableFactory().

126  : void
127  {
128  $factory = $this->getTableFactory();
129  $columns = [
130  'f1' => $factory->column()->text('f1')
131  ->withIsSortable(false),
132  'f2' => $factory->column()->text('f2')
133  ->withIsSortable(false)
134  ->withIsOptional(true),
135  ];
136  $total_count = 200;
137  list($table, $view_controls) = $this->getTable($total_count, $columns);
138 
139  $this->assertEquals(
140  [
141  C\Table\Data::VIEWCONTROL_KEY_PAGINATION,
142  C\Table\Data::VIEWCONTROL_KEY_FIELDSELECTION,
143  ],
144  array_keys($view_controls->getInputs())
145  );
146  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$factory
Definition: metadata.php:75
getTable(int $total_count, array $columns)
+ Here is the call graph for this function:

◆ testDataTableHasNoPaginationViewControl()

DataViewControlsTest::testDataTableHasNoPaginationViewControl ( )

Definition at line 96 of file DataViewControlsTest.php.

References $factory, getTable(), and TableTestBase\getTableFactory().

96  : void
97  {
98  $factory = $this->getTableFactory();
99  $columns = [
100  'f1' => $factory->column()->text('f1'),
101  'f2' => $factory->column()->text('f2')->withIsOptional(true),
102  ];
103  $total_count = current(C\Input\ViewControl\Pagination::DEFAULT_LIMITS) - 1;
104  list($table, $view_controls) = $this->getTable($total_count, $columns);
105 
106  $this->assertEquals(
107  [
108  C\Table\Data::VIEWCONTROL_KEY_PAGINATION,
109  C\Table\Data::VIEWCONTROL_KEY_ORDERING,
110  C\Table\Data::VIEWCONTROL_KEY_FIELDSELECTION,
111  ],
112  array_keys($view_controls->getInputs())
113  );
114  $this->assertInstanceOf(
115  I\Input\ViewControl\Group::class,
116  $view_controls->getInputs()[C\Table\Data::VIEWCONTROL_KEY_PAGINATION]
117  );
118 
119  $group_contents = $view_controls->getInputs()[C\Table\Data::VIEWCONTROL_KEY_PAGINATION]->getInputs();
120  array_walk(
121  $group_contents,
122  fn($vc) => $this->assertInstanceOf(I\Input\ViewControl\NullControl::class, $vc)
123  );
124  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$factory
Definition: metadata.php:75
getTable(int $total_count, array $columns)
+ Here is the call graph for this function:

◆ testDataTableHasViewControls()

DataViewControlsTest::testDataTableHasViewControls ( )

Definition at line 72 of file DataViewControlsTest.php.

References $factory, getTable(), and TableTestBase\getTableFactory().

72  : void
73  {
74  $factory = $this->getTableFactory();
75  $columns = [
76  'f1' => $factory->column()->text('f1'),
77  'f2' => $factory->column()->text('f2')->withIsOptional(true),
78  ];
79  $total_count = 12;
80  list($table, $view_controls) = $this->getTable($total_count, $columns);
81 
82  $this->assertInstanceOf(I\Input\Container\ViewControl\ViewControl::class, $view_controls);
83  $this->assertEquals(
84  [
85  C\Table\Data::VIEWCONTROL_KEY_PAGINATION,
86  C\Table\Data::VIEWCONTROL_KEY_ORDERING,
87  C\Table\Data::VIEWCONTROL_KEY_FIELDSELECTION,
88  ],
89  array_keys($view_controls->getInputs())
90  );
91  foreach (array_values($view_controls->getInputs()) as $vc) {
92  $this->assertInstanceOf(I\Input\Container\ViewControl\ViewControlInput::class, $vc);
93  }
94  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$factory
Definition: metadata.php:75
getTable(int $total_count, array $columns)
+ Here is the call graph for this function:

◆ testDataTableViewControlStorage()

DataViewControlsTest::testDataTableViewControlStorage ( )

Definition at line 185 of file DataViewControlsTest.php.

References $factory, getRequestMock(), getTable(), and TableTestBase\getTableFactory().

185  : void
186  {
187  $factory = $this->getTableFactory();
188  $columns = [
189  'f1' => $factory->column()->text('f1')->withIsOptional(true),
190  'f2' => $factory->column()->text('f2')->withIsOptional(true),
191  'f3' => $factory->column()->text('f3')->withIsOptional(true),
192  ];
193  $total_count = 12;
194  list($base_table, $view_controls) = $this->getTable($total_count, $columns);
195 
196  $table_id = 'testing_data_table';
197  $table = $base_table
198  ->withId($table_id)
199  ->withRequest(
200  $this->getRequestMock([
201  'view_control/input_0/input_1' => 0,
202  'view_control/input_0/input_2' => 10,
203  'view_control/input_3/input_4' => 'f2',
204  'view_control/input_3/input_5' => 'DESC',
205  'view_control/input_6' => ['f2']
206  ])
207  );
208  list($table, $view_controls) = $table->applyViewControls([], []);
209  //applied values from viewcontrols
210  $this->assertEquals(new Range(0, 10), $table->getRange());
211  $this->assertEquals(new Order('f2', Order::DESC), $table->getOrder());
212  $this->assertEquals(1, count($table->getSelectedOptionalColumns()));
213 
214  //default_values for different id
215  $table = $base_table
216  ->withId('other id')
217  ->withRequest($this->getRequestMock([]));
218  list($table, $view_controls) = $table->applyViewControls([], []);
219  $this->assertEquals(new Range(0, 12), $table->getRange());
220  $this->assertEquals(new Order('f1', Order::ASC), $table->getOrder());
221  $this->assertEquals(3, count($table->getSelectedOptionalColumns()));
222 
223  //applied values from session with empty request
224  $table = $base_table
225  ->withId($table_id)
226  ->withRequest($this->getRequestMock([]));
227  list($table, $view_controls) = $table->applyViewControls([], []);
228  $this->assertEquals(new Range(0, 10), $table->getRange());
229  $this->assertEquals(new Order('f2', Order::DESC), $table->getOrder());
230  $this->assertEquals(1, count($table->getSelectedOptionalColumns()));
231  }
Both the subject and the direction need to be specified when expressing an order. ...
Definition: Order.php:12
getRequestMock(array $returns)
A simple class to express a range of whole positive numbers.
Definition: Range.php:30
$factory
Definition: metadata.php:75
getTable(int $total_count, array $columns)
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: