ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 ?array $filter_data,
58 ?array $additional_parameters
59 ): \Generator {
60 yield $row_builder->buildStandardRow('', []);
61 }
62 public function getTotalRowCount(
63 ?array $filter_data,
64 ?array $additional_parameters
65 ): ?int {
66 return null;
67 }
68 };
69 }
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 141 of file DataTest.php.

141 : I\Table\Data
142 {
143 $data = $this->getDataRetrieval();
144 $cols = ['f0' => $this->getTableFactory()->column()->text("col1")];
145 $table = $this->getTableFactory()->data($data, 'title', $cols);
146 return $table;
147 }
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 120 of file DataTest.php.

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

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

+ Here is the call graph for this function:

◆ testDataTableBasicConstruction()

DataTest::testDataTableBasicConstruction ( )

Definition at line 71 of file DataTest.php.

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

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

+ Here is the call graph for this function:

◆ testDataTableColumns()

DataTest::testDataTableColumns ( )

Definition at line 102 of file DataTest.php.

102 : void
103 {
104 $f = $this->getTableFactory()->column();
105 $cols = [
106 'f0' => $f->text("col1"),
107 'f1' => $f->text("col2")
108 ];
109 $table = $this->getTableFactory()->data($this->getDataRetrieval(), 'title', $cols);
110
111 $this->assertEquals(2, $table->getColumnCount());
112 $check = [
113 'f0' => $f->text("col1")->withIndex(0),
114 'f1' => $f->text("col2")->withIndex(1)
115 ];
116 $this->assertEquals($check, $table->getColumns());
117 $this->assertEquals($check, $table->getVisibleColumns());
118 }
$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 86 of file DataTest.php.

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

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

+ Here is the call graph for this function:

◆ testDataTableConstructionWithoutColumns()

DataTest::testDataTableConstructionWithoutColumns ( )

Definition at line 94 of file DataTest.php.

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

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

+ Here is the call graph for this function:

◆ testDataTableWithAdditionalParams()

DataTest::testDataTableWithAdditionalParams ( )

Definition at line 179 of file DataTest.php.

179 : void
180 {
181 $table = $this->getTable();
182 $params = [
183 'param' => 'value'
184 ];
185 $this->assertEquals($params, $table->withAdditionalParameters($params)->getAdditionalParameters());
186 }
getTable()
Definition: DataTest.php:141
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 170 of file DataTest.php.

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

References getTable().

+ Here is the call graph for this function:

◆ testDataTableWithId()

DataTest::testDataTableWithId ( )

Definition at line 204 of file DataTest.php.

204 : void
205 {
206 $table = new class () extends C\Table\Data {
207 public function __construct()
208 {
209 }
210 public function mockGetStorageId(): ?string
211 {
212 return $this->getStorageId();
213 }
214 public function mockGetId(): ?string
215 {
216 return $this->getId();
217 }
218 };
219
220 $this->assertNull($table->mockGetId());
221 $this->assertNull($table->mockGetStorageId());
222
223 $table_id = 'some_id';
224 $internal_table_id = C\Table\Data::STORAGE_ID_PREFIX . $table_id;
225 $table = $table->withId($table_id);
226 $this->assertEquals($table_id, $table->mockGetId());
227 $this->assertEquals($internal_table_id, $table->mockGetStorageId());
228 }
__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 230 of file DataTest.php.

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

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

+ Here is the call graph for this function:

◆ testDataTableWithOrder()

DataTest::testDataTableWithOrder ( )

Definition at line 156 of file DataTest.php.

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

References getTable().

+ Here is the call graph for this function:

◆ testDataTableWithRange()

DataTest::testDataTableWithRange ( )

Definition at line 163 of file DataTest.php.

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

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

+ Here is the call graph for this function:

◆ testDataTableWithRequest()

DataTest::testDataTableWithRequest ( )

Definition at line 149 of file DataTest.php.

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

References getTable().

+ Here is the call graph for this function:

◆ testDataTableWithSelectedOptionalCols()

DataTest::testDataTableWithSelectedOptionalCols ( )

Definition at line 188 of file DataTest.php.

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

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: