ILIAS  release_8 Revision v8.23
DataTest Class Reference

Tests for the Data Table. More...

+ Inheritance diagram for DataTest:
+ Collaboration diagram for DataTest:

Public Member Functions

 testDataTableBasicConstruction ()
 
 testDataTableConstructionWithErrorColumns ()
 
 testDataTableConstructionWithoutColumns ()
 
 testDataTableColumns ()
 
 testDataTableActions ()
 
 testDataTableWithRequest ()
 
 testDataTableWithNumberOfRows ()
 
 testDataTableWithOrder ()
 
 testDataTableWithRange ()
 
 testDataTableWithFilter ()
 
 testDataTableWithAdditionalParams ()
 
 testDataTableWithSelectedOptionalCols ()
 
 testDataTableWithId ()
 
 testDataTableWithIdAndStorage ()
 
- 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 ()
 
 getTable ()
 
- 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...
 

Detailed Description

Tests for the Data Table.

Definition at line 35 of file DataTest.php.

Member Function Documentation

◆ getDataRetrieval()

DataTest::getDataRetrieval ( )
protected

Definition at line 37 of file DataTest.php.

Referenced by getTable(), testDataTableActions(), testDataTableBasicConstruction(), testDataTableColumns(), testDataTableConstructionWithErrorColumns(), testDataTableConstructionWithoutColumns(), and testDataTableWithSelectedOptionalCols().

37  : I\Table\DataRetrieval
38  {
39  return new class () implements I\Table\DataRetrieval {
40  public function getRows(
41  I\Table\DataRowBuilder $row_builder,
42  array $visible_column_ids,
43  Range $range,
44  Order $order,
45  ?array $filter_data,
46  ?array $additional_parameters
47  ): \Generator {
48  yield $row_builder->buildStandardRow('', []);
49  }
50  public function getTotalRowCount(
51  ?array $filter_data,
52  ?array $additional_parameters
53  ): ?int {
54  return null;
55  }
56  };
57  }
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
A simple class to express a range of whole positive numbers.
Definition: Range.php:30
+ Here is the caller graph for this function:

◆ getTable()

DataTest::getTable ( )
protected

Definition at line 130 of file DataTest.php.

References $cols, $data, getDataRetrieval(), and TableTestBase\getTableFactory().

Referenced by testDataTableWithAdditionalParams(), testDataTableWithFilter(), testDataTableWithNumberOfRows(), testDataTableWithOrder(), testDataTableWithRange(), and testDataTableWithRequest().

130  : I\Table\Data
131  {
132  $data = $this->getDataRetrieval();
133  $cols = ['f0' => $this->getTableFactory()->column()->text("col1")];
134  $table = $this->getTableFactory()->data('title', $cols, $data);
135  return $table;
136  }
getDataRetrieval()
Definition: DataTest.php:37
$cols
Definition: xhr_table.php:11
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testDataTableActions()

DataTest::testDataTableActions ( )

Definition at line 109 of file DataTest.php.

References $cols, Vendor\Package\$f, $token, getDataRetrieval(), and TableTestBase\getTableFactory().

109  : void
110  {
111  $f = $this->getTableFactory()->action();
112  $df = new \ILIAS\Data\Factory();
113  $target = $df->uri('http://wwww.ilias.de?ref_id=1');
114  $url_builder = new URLBuilder($target);
115  list($builder, $token) = $url_builder->acquireParameter(['namespace'], 'rowids');
116  $actions = [
117  $f->single('act1', $builder, $token),
118  $f->multi('act2', $builder, $token),
119  $f->standard('act0', $builder, $token)
120  ];
121  $cols = ['f0' => $this->getTableFactory()->column()->text("col1")];
122  $table = $this->getTableFactory()->data('title', $cols, $this->getDataRetrieval())
123  ->withActions($actions);
124 
125  $this->assertEquals($actions, $table->getAllActions());
126  $this->assertEqualsCanonicalizing([$actions[0], $actions[2]], $table->getSingleActions());
127  $this->assertEqualsCanonicalizing([$actions[1], $actions[2]], $table->getMultiActions());
128  }
getDataRetrieval()
Definition: DataTest.php:37
$token
Definition: xapitoken.php:70
URLBuilder.
Definition: URLBuilder.php:39
$cols
Definition: xhr_table.php:11
+ Here is the call graph for this function:

◆ testDataTableBasicConstruction()

DataTest::testDataTableBasicConstruction ( )

Definition at line 59 of file DataTest.php.

References $cols, $data, getDataRetrieval(), and TableTestBase\getTableFactory().

59  : void
60  {
61  $data = $this->getDataRetrieval();
62  $cols = ['f0' => $this->getTableFactory()->column()->text("col1")];
63  $table = $this->getTableFactory()->data('title', $cols, $data);
64  $this->assertEquals(800, $table->getNumberOfRows());
65  $this->assertInstanceOf(Order::class, $table->getOrder());
66  $this->assertInstanceOf(Range::class, $table->getRange());
67  $this->assertInstanceOf(I\Signal::class, $table->getAsyncActionSignal());
68  $this->assertInstanceOf(I\Signal::class, $table->getMultiActionSignal());
69  $this->assertInstanceOf(I\Signal::class, $table->getSelectionSignal());
70  $this->assertFalse($table->hasSingleActions());
71  $this->assertFalse($table->hasMultiActions());
72  $this->assertEquals($data, $table->getDataRetrieval());
73  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getDataRetrieval()
Definition: DataTest.php:37
$cols
Definition: xhr_table.php:11
+ Here is the call graph for this function:

◆ testDataTableColumns()

DataTest::testDataTableColumns ( )

Definition at line 91 of file DataTest.php.

References $check, $cols, Vendor\Package\$f, getDataRetrieval(), and TableTestBase\getTableFactory().

91  : void
92  {
93  $f = $this->getTableFactory()->column();
94  $cols = [
95  'f0' => $f->text("col1"),
96  'f1' => $f->text("col2")
97  ];
98  $table = $this->getTableFactory()->data('title', $cols, $this->getDataRetrieval());
99 
100  $this->assertEquals(2, $table->getColumnCount());
101  $check = [
102  'f0' => $f->text("col1")->withIndex(0),
103  'f1' => $f->text("col2")->withIndex(1)
104  ];
105  $this->assertEquals($check, $table->getColumns());
106  $this->assertEquals($check, $table->getVisibleColumns());
107  }
getDataRetrieval()
Definition: DataTest.php:37
$check
Definition: buildRTE.php:81
$cols
Definition: xhr_table.php:11
+ Here is the call graph for this function:

◆ testDataTableConstructionWithErrorColumns()

DataTest::testDataTableConstructionWithErrorColumns ( )

Definition at line 75 of file DataTest.php.

References $cols, $data, getDataRetrieval(), and TableTestBase\getTableFactory().

75  : void
76  {
77  $this->expectException(\InvalidArgumentException::class);
78  $data = $this->getDataRetrieval();
79  $cols = ['f0' => "col1"];
80  $table = $this->getTableFactory()->data('title', $cols, $data);
81  }
getDataRetrieval()
Definition: DataTest.php:37
$cols
Definition: xhr_table.php:11
+ Here is the call graph for this function:

◆ testDataTableConstructionWithoutColumns()

DataTest::testDataTableConstructionWithoutColumns ( )

Definition at line 83 of file DataTest.php.

References $cols, $data, getDataRetrieval(), and TableTestBase\getTableFactory().

83  : void
84  {
85  $this->expectException(\InvalidArgumentException::class);
86  $data = $this->getDataRetrieval();
87  $cols = [];
88  $table = $this->getTableFactory()->data('title', $cols, $data);
89  }
getDataRetrieval()
Definition: DataTest.php:37
$cols
Definition: xhr_table.php:11
+ Here is the call graph for this function:

◆ testDataTableWithAdditionalParams()

DataTest::testDataTableWithAdditionalParams ( )

Definition at line 175 of file DataTest.php.

References $params, and getTable().

175  : void
176  {
177  $table = $this->getTable();
178  $params = [
179  'param' => 'value'
180  ];
181  $this->assertEquals($params, $table->withAdditionalParameters($params)->getAdditionalParameters());
182  }
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
getTable()
Definition: DataTest.php:130
+ Here is the call graph for this function:

◆ testDataTableWithFilter()

DataTest::testDataTableWithFilter ( )

Definition at line 166 of file DataTest.php.

References getTable().

166  : void
167  {
168  $table = $this->getTable();
169  $filter = [
170  'aspect' => ['values']
171  ];
172  $this->assertEquals($filter, $table->withFilter($filter)->getFilter());
173  }
getTable()
Definition: DataTest.php:130
+ Here is the call graph for this function:

◆ testDataTableWithId()

DataTest::testDataTableWithId ( )

Definition at line 200 of file DataTest.php.

References ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\Survey\Mode\getId().

200  : void
201  {
202  $table = new class () extends C\Table\Data {
203  public function __construct()
204  {
205  }
206  public function mockGetStorageId(): ?string
207  {
208  return $this->getStorageId();
209  }
210  public function mockGetId(): ?string
211  {
212  return $this->getId();
213  }
214  };
215 
216  $this->assertNull($table->mockGetId());
217  $this->assertNull($table->mockGetStorageId());
218 
219  $table_id = 'some_id';
220  $internal_table_id = C\Table\Data::STORAGE_ID_PREFIX . $table_id;
221  $table = $table->withId($table_id);
222  $this->assertEquals($table_id, $table->mockGetId());
223  $this->assertEquals($internal_table_id, $table->mockGetStorageId());
224  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

◆ testDataTableWithIdAndStorage()

DataTest::testDataTableWithIdAndStorage ( )

Definition at line 226 of file DataTest.php.

References ILIAS\GlobalScreen\Provider\__construct(), and TableTestBase\getMockStorage().

226  : void
227  {
228  $table_id = 'some_id';
229  $internal_table_id = C\Table\Data::STORAGE_ID_PREFIX . $table_id;
230  $table_data = ['a' => 'b'];
231  $storage = $this->getMockStorage();
232  $storage[$internal_table_id] = $table_data;
233 
234  $table = new class ($storage) extends C\Table\Data {
235  protected \ArrayAccess $storage;
236  public function __construct(
237  \ArrayAccess $storage
238  ) {
239  $this->storage = $storage;
240  }
241  public function mockGetStorageData(): ?array
242  {
243  return $this->getStorageData();
244  }
245  };
246 
247  $table = $table->withId($table_id);
248  $this->assertEquals($table_data, $table->mockGetStorageData());
249  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

◆ testDataTableWithNumberOfRows()

DataTest::testDataTableWithNumberOfRows ( )

Definition at line 145 of file DataTest.php.

References getTable().

145  : void
146  {
147  $table = $this->getTable();
148  $nor = 12;
149  $this->assertEquals($nor, $table->withNumberOfRows($nor)->getNumberOfRows());
150  }
getTable()
Definition: DataTest.php:130
+ Here is the call graph for this function:

◆ testDataTableWithOrder()

DataTest::testDataTableWithOrder ( )

Definition at line 152 of file DataTest.php.

References getTable().

152  : void
153  {
154  $table = $this->getTable();
155  $order = new Order('aspect', 'DESC');
156  $this->assertEquals($order, $table->withOrder($order)->getOrder());
157  }
Both the subject and the direction need to be specified when expressing an order. ...
Definition: Order.php:12
getTable()
Definition: DataTest.php:130
+ Here is the call graph for this function:

◆ testDataTableWithRange()

DataTest::testDataTableWithRange ( )

Definition at line 159 of file DataTest.php.

References getTable().

159  : void
160  {
161  $table = $this->getTable();
162  $range = new Range(17, 53);
163  $this->assertEquals($range, $table->withRange($range)->getRange());
164  }
getTable()
Definition: DataTest.php:130
A simple class to express a range of whole positive numbers.
Definition: Range.php:30
+ Here is the call graph for this function:

◆ testDataTableWithRequest()

DataTest::testDataTableWithRequest ( )

Definition at line 138 of file DataTest.php.

References getTable().

138  : void
139  {
140  $table = $this->getTable();
141  $request = $this->createMock(ServerRequestInterface::class);
142  $this->assertEquals($request, $table->withRequest($request)->getRequest());
143  }
getTable()
Definition: DataTest.php:130
+ Here is the call graph for this function:

◆ testDataTableWithSelectedOptionalCols()

DataTest::testDataTableWithSelectedOptionalCols ( )

Definition at line 184 of file DataTest.php.

References $cols, $data, getDataRetrieval(), and TableTestBase\getTableFactory().

184  : void
185  {
186  $data = $this->getDataRetrieval();
187  $cols = [
188  'f0' => $this->getTableFactory()->column()->text(''),
189  'f1' => $this->getTableFactory()->column()->text('')
190  ->withIsOptional(true, false),
191  'f2' => $this->getTableFactory()->column()->text('')
192  ];
193  $table = $this->getTableFactory()->data('title', $cols, $data);
194  $this->assertEquals(3, $table->getColumnCount());
195  $this->assertEquals(['f0', 'f2'], array_keys($table->getVisibleColumns()));
196  $this->assertEquals(0, $table->getVisibleColumns()['f0']->getIndex());
197  $this->assertEquals(2, $table->getVisibleColumns()['f2']->getIndex());
198  }
getDataRetrieval()
Definition: DataTest.php:37
$cols
Definition: xhr_table.php:11
+ Here is the call graph for this function:

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