ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
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 ()
 
 testDataTableWithOrder ()
 
 testDataTableWithRange ()
 
 testDataTableWithFilter ()
 
 testDataTableWithAdditionalParams ()
 
 testDataTableWithSelectedOptionalCols ()
 
 testDataTableWithId ()
 
 testDataTableWithIdAndStorage ()
 

Protected Member Functions

 getFactory ()
 
 getDataRetrieval ()
 
 getTable ()
 
- Protected Member Functions inherited from TableTestBase
 buildFieldFactory ()
 
 buildRefinery ()
 
 getViewControlFactory ()
 
 getViewControlContainerFactory ()
 
 getTableFactory ()
 
 getMockStorage ()
 

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 49 of file DataTest.php.

49 : I\Table\DataRetrieval
50 {
51 return new class () implements I\Table\DataRetrieval {
52 public function getRows(
53 I\Table\DataRowBuilder $row_builder,
54 array $visible_column_ids,
56 Order $order,
57 mixed $additional_viewcontrol_data,
58 mixed $filter_data,
59 mixed $additional_parameters
60 ): \Generator {
61 yield $row_builder->buildStandardRow('', []);
62 }
63 public function getTotalRowCount(
64 mixed $additional_viewcontrol_data,
65 mixed $filter_data,
66 mixed $additional_parameters
67 ): ?int {
68 return null;
69 }
70 };
71 }
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:29
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ILIAS\UI\Implementation\Component\Table\$range.

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

+ Here is the caller graph for this function:

◆ getFactory()

DataTest::getFactory ( )
protected

Definition at line 37 of file DataTest.php.

38 {
39 return new C\Table\Factory(
40 new C\SignalGenerator(),
41 new \ILIAS\Data\Factory(),
42 new C\Table\Column\Factory(),
43 new C\Table\Action\Factory(),
44 new C\Table\DataRowBuilder(),
45 new C\Table\OrderingRowBuilder()
46 );
47 }
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

◆ getTable()

DataTest::getTable ( )
protected

Definition at line 143 of file DataTest.php.

143 : I\Table\Data
144 {
145 $data = $this->getDataRetrieval();
146 $cols = ['f0' => $this->getTableFactory()->column()->text("col1")];
147 $table = $this->getTableFactory()->data($data, 'title', $cols);
148 return $table;
149 }
getDataRetrieval()
Definition: DataTest.php:49

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

Referenced by testDataTableWithAdditionalParams(), testDataTableWithFilter(), 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 122 of file DataTest.php.

122 : void
123 {
124 $f = $this->getTableFactory()->action();
125 $df = new \ILIAS\Data\Factory();
126 $target = $df->uri('http://wwww.ilias.de?ref_id=1');
127 $url_builder = new URLBuilder($target);
128 list($builder, $token) = $url_builder->acquireParameter(['namespace'], 'rowids');
129 $actions = [
130 $f->single('act1', $builder, $token),
131 $f->multi('act2', $builder, $token),
132 $f->standard('act0', $builder, $token)
133 ];
134 $cols = ['f0' => $this->getTableFactory()->column()->text("col1")];
135 $table = $this->getTableFactory()->data($this->getDataRetrieval(), 'title', $cols)
136 ->withActions($actions);
137
138 $this->assertEquals($actions, $table->getAllActions());
139 $this->assertEqualsCanonicalizing([$actions[0], $actions[2]], $table->getSingleActions());
140 $this->assertEqualsCanonicalizing([$actions[1], $actions[2]], $table->getMultiActions());
141 }
$token
Definition: xapitoken.php:67

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

+ Here is the call graph for this function:

◆ testDataTableBasicConstruction()

DataTest::testDataTableBasicConstruction ( )

Definition at line 73 of file DataTest.php.

73 : void
74 {
75 $data = $this->getDataRetrieval();
76 $cols = ['f0' => $this->getTableFactory()->column()->text("col1")];
77 $table = $this->getTableFactory()->data($data, 'title', $cols);
78 $this->assertInstanceOf(Order::class, $table->getOrder());
79 $this->assertInstanceOf(Range::class, $table->getRange());
80 $this->assertInstanceOf(I\Signal::class, $table->getAsyncActionSignal());
81 $this->assertInstanceOf(I\Signal::class, $table->getMultiActionSignal());
82 $this->assertInstanceOf(I\Signal::class, $table->getSelectionSignal());
83 $this->assertFalse($table->hasSingleActions());
84 $this->assertFalse($table->hasMultiActions());
85 $this->assertEquals($data, $table->getDataRetrieval());
86 }

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

+ Here is the call graph for this function:

◆ testDataTableColumns()

DataTest::testDataTableColumns ( )

Definition at line 104 of file DataTest.php.

104 : void
105 {
106 $f = $this->getTableFactory()->column();
107 $cols = [
108 'f0' => $f->text("col1"),
109 'f1' => $f->text("col2")
110 ];
111 $table = $this->getTableFactory()->data($this->getDataRetrieval(), 'title', $cols);
112
113 $this->assertEquals(2, $table->getColumnCount());
114 $check = [
115 'f0' => $f->text("col1")->withIndex(0),
116 'f1' => $f->text("col2")->withIndex(1)
117 ];
118 $this->assertEquals($check, $table->getColumns());
119 $this->assertEquals($check, $table->getVisibleColumns());
120 }
$check
Definition: buildRTE.php:81

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

+ Here is the call graph for this function:

◆ testDataTableConstructionWithErrorColumns()

DataTest::testDataTableConstructionWithErrorColumns ( )

Definition at line 88 of file DataTest.php.

88 : void
89 {
90 $this->expectException(\InvalidArgumentException::class);
91 $data = $this->getDataRetrieval();
92 $cols = ['f0' => "col1"];
93 $table = $this->getTableFactory()->data($data, 'title', $cols);
94 }

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

+ Here is the call graph for this function:

◆ testDataTableConstructionWithoutColumns()

DataTest::testDataTableConstructionWithoutColumns ( )

Definition at line 96 of file DataTest.php.

96 : void
97 {
98 $this->expectException(\InvalidArgumentException::class);
99 $data = $this->getDataRetrieval();
100 $cols = [];
101 $table = $this->getTableFactory()->data($data, 'title', $cols);
102 }

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

+ Here is the call graph for this function:

◆ testDataTableWithAdditionalParams()

DataTest::testDataTableWithAdditionalParams ( )

Definition at line 181 of file DataTest.php.

181 : void
182 {
183 $table = $this->getTable();
184 $params = [
185 'param' => 'value'
186 ];
187 $this->assertEquals($params, $table->withAdditionalParameters($params)->getAdditionalParameters());
188 }
getTable()
Definition: DataTest.php:143
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31

References $params, and getTable().

+ Here is the call graph for this function:

◆ testDataTableWithFilter()

DataTest::testDataTableWithFilter ( )

Definition at line 172 of file DataTest.php.

172 : void
173 {
174 $table = $this->getTable();
175 $filter = [
176 'aspect' => ['values']
177 ];
178 $this->assertEquals($filter, $table->withFilter($filter)->getFilter());
179 }

References getTable().

+ Here is the call graph for this function:

◆ testDataTableWithId()

DataTest::testDataTableWithId ( )

Definition at line 206 of file DataTest.php.

206 : void
207 {
208 $table = new class () extends C\Table\Data {
209 public function __construct()
210 {
211 }
212 public function mockGetStorageId(): ?string
213 {
214 return $this->getStorageId();
215 }
216 public function mockGetId(): ?string
217 {
218 return $this->getId();
219 }
220 };
221
222 $this->assertNull($table->mockGetId());
223 $this->assertNull($table->mockGetStorageId());
224
225 $table_id = 'some_id';
226 $internal_table_id = C\Table\Data::STORAGE_ID_PREFIX . $table_id;
227 $table = $table->withId($table_id);
228 $this->assertEquals($table_id, $table->mockGetId());
229 $this->assertEquals($internal_table_id, $table->mockGetStorageId());
230 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

◆ testDataTableWithIdAndStorage()

DataTest::testDataTableWithIdAndStorage ( )

Definition at line 232 of file DataTest.php.

232 : void
233 {
234 $table_id = 'some_id';
235 $internal_table_id = C\Table\Data::STORAGE_ID_PREFIX . $table_id;
236 $table_data = ['a' => 'b'];
237 $storage = $this->getMockStorage();
238 $storage[$internal_table_id] = $table_data;
239
240 $table = new class ($storage) extends C\Table\Data {
241 public function __construct(
242 protected \ArrayAccess $storage,
243 ) {
244 }
245 public function mockGetStorageData(): ?array
246 {
247 return $this->getStorageData();
248 }
249 };
250
251 $table = $table->withId($table_id);
252 $this->assertEquals($table_data, $table->mockGetStorageData());
253 }

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

+ Here is the call graph for this function:

◆ testDataTableWithOrder()

DataTest::testDataTableWithOrder ( )

Definition at line 158 of file DataTest.php.

158 : void
159 {
160 $table = $this->getTable();
161 $order = new Order('aspect', 'DESC');
162 $this->assertEquals($order, $table->withOrder($order)->getOrder());
163 }

References getTable().

+ Here is the call graph for this function:

◆ testDataTableWithRange()

DataTest::testDataTableWithRange ( )

Definition at line 165 of file DataTest.php.

165 : void
166 {
167 $table = $this->getTable();
168 $range = new Range(17, 53);
169 $this->assertEquals($range, $table->withRange($range)->getRange());
170 }

References ILIAS\UI\Implementation\Component\Table\$range, and getTable().

+ Here is the call graph for this function:

◆ testDataTableWithRequest()

DataTest::testDataTableWithRequest ( )

Definition at line 151 of file DataTest.php.

151 : void
152 {
153 $table = $this->getTable();
154 $request = $this->createMock(ServerRequestInterface::class);
155 $this->assertEquals($request, $table->withRequest($request)->getRequest());
156 }

References getTable().

+ Here is the call graph for this function:

◆ testDataTableWithSelectedOptionalCols()

DataTest::testDataTableWithSelectedOptionalCols ( )

Definition at line 190 of file DataTest.php.

190 : void
191 {
192 $data = $this->getDataRetrieval();
193 $cols = [
194 'f0' => $this->getTableFactory()->column()->text(''),
195 'f1' => $this->getTableFactory()->column()->text('')
196 ->withIsOptional(true, false),
197 'f2' => $this->getTableFactory()->column()->text('')
198 ];
199 $table = $this->getTableFactory()->data($data, 'title', $cols);
200 $this->assertEquals(3, $table->getColumnCount());
201 $this->assertEquals(['f0', 'f2'], array_keys($table->getVisibleColumns()));
202 $this->assertEquals(0, $table->getVisibleColumns()['f0']->getIndex());
203 $this->assertEquals(2, $table->getVisibleColumns()['f2']->getIndex());
204 }

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

+ Here is the call graph for this function:

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