ILIAS  release_8 Revision v8.24
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.

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 }
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:13
A simple class to express a range of whole positive numbers.
Definition: Range.php:31
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

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

+ Here is the caller graph for this function:

◆ getTable()

DataTest::getTable ( )
protected

Definition at line 130 of file DataTest.php.

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

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

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

+ 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.

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 }
$token
Definition: xapitoken.php:70

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

+ Here is the call graph for this function:

◆ testDataTableBasicConstruction()

DataTest::testDataTableBasicConstruction ( )

Definition at line 59 of file DataTest.php.

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 }

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

+ Here is the call graph for this function:

◆ testDataTableColumns()

DataTest::testDataTableColumns ( )

Definition at line 91 of file DataTest.php.

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 }
$check
Definition: buildRTE.php:81

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

+ Here is the call graph for this function:

◆ testDataTableConstructionWithErrorColumns()

DataTest::testDataTableConstructionWithErrorColumns ( )

Definition at line 75 of file DataTest.php.

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 }

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

+ Here is the call graph for this function:

◆ testDataTableConstructionWithoutColumns()

DataTest::testDataTableConstructionWithoutColumns ( )

Definition at line 83 of file DataTest.php.

83 : void
84 {
85 $this->expectException(\InvalidArgumentException::class);
86 $data = $this->getDataRetrieval();
87 $cols = [];
88 $table = $this->getTableFactory()->data('title', $cols, $data);
89 }

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

+ Here is the call graph for this function:

◆ testDataTableWithAdditionalParams()

DataTest::testDataTableWithAdditionalParams ( )

Definition at line 175 of file DataTest.php.

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

References $params, and getTable().

+ Here is the call graph for this function:

◆ testDataTableWithFilter()

DataTest::testDataTableWithFilter ( )

Definition at line 166 of file DataTest.php.

166 : void
167 {
168 $table = $this->getTable();
169 $filter = [
170 'aspect' => ['values']
171 ];
172 $this->assertEquals($filter, $table->withFilter($filter)->getFilter());
173 }

References getTable().

+ Here is the call graph for this function:

◆ testDataTableWithId()

DataTest::testDataTableWithId ( )

Definition at line 200 of file DataTest.php.

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 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

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

+ Here is the call graph for this function:

◆ testDataTableWithIdAndStorage()

DataTest::testDataTableWithIdAndStorage ( )

Definition at line 226 of file DataTest.php.

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 }

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

+ Here is the call graph for this function:

◆ testDataTableWithNumberOfRows()

DataTest::testDataTableWithNumberOfRows ( )

Definition at line 145 of file DataTest.php.

145 : void
146 {
147 $table = $this->getTable();
148 $nor = 12;
149 $this->assertEquals($nor, $table->withNumberOfRows($nor)->getNumberOfRows());
150 }

References getTable().

+ Here is the call graph for this function:

◆ testDataTableWithOrder()

DataTest::testDataTableWithOrder ( )

Definition at line 152 of file DataTest.php.

152 : void
153 {
154 $table = $this->getTable();
155 $order = new Order('aspect', 'DESC');
156 $this->assertEquals($order, $table->withOrder($order)->getOrder());
157 }

References getTable().

+ Here is the call graph for this function:

◆ testDataTableWithRange()

DataTest::testDataTableWithRange ( )

Definition at line 159 of file DataTest.php.

159 : void
160 {
161 $table = $this->getTable();
162 $range = new Range(17, 53);
163 $this->assertEquals($range, $table->withRange($range)->getRange());
164 }

References getTable().

+ Here is the call graph for this function:

◆ testDataTableWithRequest()

DataTest::testDataTableWithRequest ( )

Definition at line 138 of file DataTest.php.

138 : void
139 {
140 $table = $this->getTable();
141 $request = $this->createMock(ServerRequestInterface::class);
142 $this->assertEquals($request, $table->withRequest($request)->getRequest());
143 }

References getTable().

+ Here is the call graph for this function:

◆ testDataTableWithSelectedOptionalCols()

DataTest::testDataTableWithSelectedOptionalCols ( )

Definition at line 184 of file DataTest.php.

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 }

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

+ Here is the call graph for this function:

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