19declare(strict_types=1);
21require_once(
"vendor/composer/vendor/autoload.php");
22require_once(__DIR__ .
"/TableTestBase.php");
29use Psr\Http\Message\ServerRequestInterface;
39 return new C\Table\Factory(
40 new C\SignalGenerator(),
44 new C\
Table\DataRowBuilder(),
45 new C\
Table\OrderingRowBuilder()
51 return new class () implements
I\
Table\DataRetrieval {
52 public function getRows(
53 I\
Table\DataRowBuilder $row_builder,
54 array $visible_column_ids,
57 mixed $additional_viewcontrol_data,
59 mixed $additional_parameters
61 yield $row_builder->buildStandardRow(
'', []);
63 public function getTotalRowCount(
64 mixed $additional_viewcontrol_data,
66 mixed $additional_parameters
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());
90 $this->expectException(\InvalidArgumentException::class);
92 $cols = [
'f0' =>
"col1"];
98 $this->expectException(\InvalidArgumentException::class);
108 'f0' =>
$f->text(
"col1"),
109 'f1' =>
$f->text(
"col2")
113 $this->assertEquals(2, $table->getColumnCount());
115 'f0' =>
$f->text(
"col1")->withIndex(0),
116 'f1' =>
$f->text(
"col2")->withIndex(1)
118 $this->assertEquals(
$check, $table->getColumns());
119 $this->assertEquals(
$check, $table->getVisibleColumns());
125 $df = new \ILIAS\Data\Factory();
126 $target = $df->uri(
'http://wwww.ilias.de?ref_id=1');
128 list($builder,
$token) = $url_builder->acquireParameter([
'namespace'],
'rowids');
130 $f->single(
'act1', $builder,
$token),
131 $f->multi(
'act2', $builder,
$token),
132 $f->standard(
'act0', $builder,
$token)
136 ->withActions($actions);
138 $this->assertEquals($actions, $table->getAllActions());
139 $this->assertEqualsCanonicalizing([$actions[0], $actions[2]], $table->getSingleActions());
140 $this->assertEqualsCanonicalizing([$actions[1], $actions[2]], $table->getMultiActions());
154 $request = $this->createMock(ServerRequestInterface::class);
155 $this->assertEquals($request, $table->withRequest($request)->getRequest());
161 $order =
new Order(
'aspect',
'DESC');
162 $this->assertEquals($order, $table->withOrder($order)->getOrder());
169 $this->assertEquals(
$range, $table->withRange(
$range)->getRange());
176 'aspect' => [
'values']
178 $this->assertEquals($filter, $table->withFilter($filter)->getFilter());
187 $this->assertEquals(
$params, $table->withAdditionalParameters(
$params)->getAdditionalParameters());
196 ->withIsOptional(
true,
false),
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());
212 public function mockGetStorageId(): ?
string
214 return $this->getStorageId();
216 public function mockGetId(): ?
string
218 return $this->
getId();
222 $this->assertNull($table->mockGetId());
223 $this->assertNull($table->mockGetStorageId());
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());
234 $table_id =
'some_id';
235 $internal_table_id = C\Table\Data::STORAGE_ID_PREFIX . $table_id;
236 $table_data = [
'a' =>
'b'];
238 $storage[$internal_table_id] = $table_data;
240 $table =
new class ($storage) extends
C\
Table\
Data {
242 protected \ArrayAccess $storage,
245 public function mockGetStorageData(): ?array
247 return $this->getStorageData();
251 $table = $table->withId($table_id);
252 $this->assertEquals($table_data, $table->mockGetStorageData());
Tests for the Data Table.
testDataTableWithFilter()
testDataTableWithIdAndStorage()
testDataTableBasicConstruction()
testDataTableWithRequest()
testDataTableConstructionWithErrorColumns()
testDataTableConstructionWithoutColumns()
testDataTableWithSelectedOptionalCols()
testDataTableWithAdditionalParams()
Both the subject and the direction need to be specified when expressing an order.
A simple class to express a naive range of whole positive numbers.
Basic Tests for all Tables.
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.