ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 ()
 
 getHelpTextRetriever ()
 
 getUploadLimitResolver ()
 
 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\UI\Implementation\Component\Table\$range, and ILIAS\MetaData\Repository\Validation\Data\__construct().

Referenced by getTable().

37  : I\Table\DataRetrieval
38  {
39  return new class ($total_count) implements I\Table\DataRetrieval {
40  public function __construct(
41  protected int $total_count
42  ) {
43  }
44  public function getRows(
45  I\Table\DataRowBuilder $row_builder,
46  array $visible_column_ids,
47  Range $range,
48  Order $order,
49  ?array $filter_data,
50  ?array $additional_parameters
51  ): \Generator {
52  yield $row_builder->buildStandardRow('', []);
53  }
54  public function getTotalRowCount(
55  ?array $filter_data,
56  ?array $additional_parameters
57  ): ?int {
58  return $this->total_count;
59  }
60  };
61  }
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(VocabulariesInterface $vocabularies)
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 166 of file DataViewControlsTest.php.

Referenced by testDataTableViewControlStorage().

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

◆ getTable()

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

Definition at line 63 of file DataViewControlsTest.php.

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

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

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

◆ testDataTableHasNoFieldSelectionViewControl()

DataViewControlsTest::testDataTableHasNoFieldSelectionViewControl ( )

Definition at line 146 of file DataViewControlsTest.php.

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

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

◆ testDataTableHasNoOrderingViewControl()

DataViewControlsTest::testDataTableHasNoOrderingViewControl ( )

Definition at line 124 of file DataViewControlsTest.php.

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

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

◆ testDataTableHasNoPaginationViewControl()

DataViewControlsTest::testDataTableHasNoPaginationViewControl ( )

Definition at line 94 of file DataViewControlsTest.php.

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

94  : void
95  {
96  $factory = $this->getTableFactory();
97  $columns = [
98  'f1' => $factory->column()->text('f1'),
99  'f2' => $factory->column()->text('f2')->withIsOptional(true),
100  ];
101  $total_count = current(C\Input\ViewControl\Pagination::DEFAULT_LIMITS) - 1;
102  list($table, $view_controls) = $this->getTable($total_count, $columns);
103 
104  $this->assertEquals(
105  [
106  C\Table\Data::VIEWCONTROL_KEY_PAGINATION,
107  C\Table\Data::VIEWCONTROL_KEY_ORDERING,
108  C\Table\Data::VIEWCONTROL_KEY_FIELDSELECTION,
109  ],
110  array_keys($view_controls->getInputs())
111  );
112  $this->assertInstanceOf(
113  I\Input\ViewControl\Group::class,
114  $view_controls->getInputs()[C\Table\Data::VIEWCONTROL_KEY_PAGINATION]
115  );
116 
117  $group_contents = $view_controls->getInputs()[C\Table\Data::VIEWCONTROL_KEY_PAGINATION]->getInputs();
118  array_walk(
119  $group_contents,
120  fn($vc) => $this->assertInstanceOf(I\Input\ViewControl\NullControl::class, $vc)
121  );
122  }
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...
getTable(int $total_count, array $columns)
+ Here is the call graph for this function:

◆ testDataTableHasViewControls()

DataViewControlsTest::testDataTableHasViewControls ( )

Definition at line 70 of file DataViewControlsTest.php.

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

70  : void
71  {
72  $factory = $this->getTableFactory();
73  $columns = [
74  'f1' => $factory->column()->text('f1'),
75  'f2' => $factory->column()->text('f2')->withIsOptional(true),
76  ];
77  $total_count = 12;
78  list($table, $view_controls) = $this->getTable($total_count, $columns);
79 
80  $this->assertInstanceOf(I\Input\Container\ViewControl\ViewControl::class, $view_controls);
81  $this->assertEquals(
82  [
83  C\Table\Data::VIEWCONTROL_KEY_PAGINATION,
84  C\Table\Data::VIEWCONTROL_KEY_ORDERING,
85  C\Table\Data::VIEWCONTROL_KEY_FIELDSELECTION,
86  ],
87  array_keys($view_controls->getInputs())
88  );
89  foreach (array_values($view_controls->getInputs()) as $vc) {
90  $this->assertInstanceOf(I\Input\Container\ViewControl\ViewControlInput::class, $vc);
91  }
92  }
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...
getTable(int $total_count, array $columns)
+ Here is the call graph for this function:

◆ testDataTableViewControlStorage()

DataViewControlsTest::testDataTableViewControlStorage ( )

Definition at line 183 of file DataViewControlsTest.php.

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

183  : void
184  {
185  $factory = $this->getTableFactory();
186  $columns = [
187  'f1' => $factory->column()->text('f1')->withIsOptional(true),
188  'f2' => $factory->column()->text('f2')->withIsOptional(true),
189  'f3' => $factory->column()->text('f3')->withIsOptional(true),
190  ];
191  $total_count = 12;
192  list($base_table, $view_controls) = $this->getTable($total_count, $columns);
193 
194  $table_id = 'testing_data_table';
195  $table = $base_table
196  ->withId($table_id)
197  ->withRequest(
198  $this->getRequestMock([
199  'view_control/input_0/input_1' => 0,
200  'view_control/input_0/input_2' => 10,
201  'view_control/input_3/input_4' => 'f2',
202  'view_control/input_3/input_5' => 'DESC',
203  'view_control/input_6' => ['f2']
204  ])
205  );
206  list($table, $view_controls) = $table->applyViewControls([], []);
207  //applied values from viewcontrols
208  $this->assertEquals(new Range(0, 10), $table->getRange());
209  $this->assertEquals(new Order('f2', Order::DESC), $table->getOrder());
210  $this->assertEquals(1, count($table->getSelectedOptionalColumns()));
211 
212  //default_values for different id
213  $table = $base_table
214  ->withId('other id')
215  ->withRequest($this->getRequestMock([]));
216  list($table, $view_controls) = $table->applyViewControls([], []);
217  $this->assertEquals(new Range(0, 12), $table->getRange());
218  $this->assertEquals(new Order('f1', Order::ASC), $table->getOrder());
219  $this->assertEquals(3, count($table->getSelectedOptionalColumns()));
220 
221  //applied values from session with empty request
222  $table = $base_table
223  ->withId($table_id)
224  ->withRequest($this->getRequestMock([]));
225  list($table, $view_controls) = $table->applyViewControls([], []);
226  $this->assertEquals(new Range(0, 10), $table->getRange());
227  $this->assertEquals(new Order('f2', Order::DESC), $table->getOrder());
228  $this->assertEquals(1, count($table->getSelectedOptionalColumns()));
229  }
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
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: