19 declare(strict_types=1);
22 require_once(
"vendor/composer/vendor/autoload.php");
23 require_once(__DIR__ .
"/../../../Base.php");
43 ->disableOriginalConstructor()
45 $lng->method(
'txt')->willReturnCallback(fn($v) => $v);
51 $col =
new Column\Text($this->
lng,
'col');
52 $this->assertEquals(
'col', $col->getTitle());
54 $this->assertTrue($col->isSortable());
55 $this->assertFalse($col->withIsSortable(
false)->isSortable());
56 $this->assertTrue($col->withIsSortable(
true)->isSortable());
58 'col, order_option_alphabetical_ascending',
59 'col, order_option_alphabetical_descending',
60 ], $col->getOrderingLabels());
62 $this->assertFalse($col->isOptional());
63 $this->assertTrue($col->withIsOptional(
true)->isOptional());
64 $this->assertFalse($col->withIsOptional(
false)->isOptional());
66 $this->assertTrue($col->isInitiallyVisible());
67 $this->assertFalse($col->withIsOptional(
true,
false)->isInitiallyVisible());
68 $this->assertTrue($col->withIsOptional(
true,
true)->isInitiallyVisible());
70 $this->assertFalse($col->isHighlighted());
71 $this->assertTrue($col->withHighlight(
true)->isHighlighted());
72 $this->assertFalse($col->withHighlight(
false)->isHighlighted());
74 $this->assertEquals(12, $col->withIndex(12)->getIndex());
79 $col =
new Column\Boolean($this->
lng,
'col',
'TRUE',
'FALSE');
80 $this->assertEquals(
'TRUE', $col->format(
true));
81 $this->assertEquals(
'FALSE', $col->format(
false));
88 $col =
new Column\Boolean($this->
lng,
'col', $ok, $no);
89 $this->assertEquals($ok, $col->format(
true));
90 $this->assertEquals($no, $col->format(
false));
95 $ok =
new Glyph(GlyphInterface::LIKE,
'');
96 $no =
new Glyph(GlyphInterface::DISLIKE,
'');
97 $col =
new Column\Boolean($this->
lng,
'col', $ok, $no);
98 $this->assertEquals($ok, $col->format(
true));
99 $this->assertEquals($no, $col->format(
false));
104 $df = new \ILIAS\Data\Factory();
105 $format = $df->dateFormat()->germanShort();
106 $dat = new \DateTimeImmutable();
107 $col =
new Column\Date($this->
lng,
'col', $format);
108 $this->assertEquals($dat->format($format->toString()), $col->format($dat));
113 $df = new \ILIAS\Data\Factory();
114 $format = $df->dateFormat()->germanShort();
115 $dat = new \DateTimeImmutable();
116 $col =
new Column\TimeSpan($this->
lng,
'col', $format);
118 $dat->format($format->toString()) .
' - ' . $dat->format($format->toString()),
119 $col->format([$dat, $dat])
125 $df = new \ILIAS\Data\Factory();
126 $dat = new \DateTimeImmutable();
127 $col =
new Column\Number($this->
lng,
'col');
128 $this->assertEquals(
'1', $col->format(1));
129 $col = $col->withDecimals(3);
130 $this->assertEquals(
'1,000', $col->format(1));
131 $col = $col->withDecimals(2)->withUnit(
'$', $col::UNIT_POSITION_FORE);
132 $this->assertEquals(
'$ 1,00', $col->format(1));
133 $col = $col->withUnit(
'€', $col::UNIT_POSITION_AFT);
134 $this->assertEquals(
'1,00 €', $col->format(1));
146 'column' =>
new Column\LinkListing($lng,
''),
151 'column' =>
new Column\LinkListing($lng,
''),
152 'value' =>
new Listing\Unordered([
'string',
'string']),
156 'column' =>
new Column\LinkListing($lng,
''),
161 'column' =>
new Column\LinkListing($lng,
''),
166 'column' =>
new Column\Link($lng,
''),
167 'value' =>
new Link\Standard(
'label',
'#'),
171 'column' =>
new Column\Link($lng,
''),
172 'value' =>
'some string',
176 'column' =>
new Column\StatusIcon($lng,
''),
181 'column' =>
new Column\StatusIcon($lng,
''),
182 'value' =>
'some string',
197 $this->expectException(\InvalidArgumentException::class);
199 $this->assertEquals($value, $column->format($value));
205 $col =
new Column\LinkListing($this->
lng,
'col');
206 $link =
new Link\Standard(
'label',
'#');
207 $linklisting =
new Listing\Unordered([$link, $link, $link]);
208 $this->assertEquals($linklisting, $col->format($linklisting));
213 $this->expectException(\InvalidArgumentException::class);
214 $col =
new Column\LinkListing($this->
lng,
'col');
215 $linklisting_invalid =
new Link\Standard(
'label',
'#');
216 $this->assertEquals($linklisting_invalid, $col->format($linklisting_invalid));
221 $this->expectException(\InvalidArgumentException::class);
222 $col =
new Column\LinkListing($this->
lng,
'col');
223 $link =
'some string';
224 $linklisting_invalid =
new Listing\Unordered([$link, $link, $link]);
225 $this->assertEquals($linklisting_invalid, $col->format($linklisting_invalid));
230 $col = (
new Column\LinkListing($this->
lng,
'col'))
231 ->withIsSortable(
true)
232 ->withOrderingLabels(
241 $col->getOrderingLabels()
static provideColumnFormats()
testDataTableColumnBoolFormatWithGlyph()
Interface Observer Contains several chained tasks and infos about them.
testDataTableColumnsAttributes()
testDataTableColumnCustomOrderingLabels()
testDataTableColumnNumnberFormat()
testDataTableColumnBoolFormatWithIcon()
testDataTableColumnDateFormat()
testDataTableColumnLinkListingFormat()
testDataTableColumnTimespanFormat()
testDataTableColumnAllowedFormats(Column\Column $column, mixed $value, bool $ok)
 * provideColumnFormats 
testDataTableColumnLinkListingItemsFormatAcceptsOnlyLinks()
testDataTableColumnBoolFormat()
__construct(Container $dic, ilPlugin $plugin)
testDataTableColumnLinkListingFormatAcceptsOnlyLinkListings()
Basic Tests for Table-Columns.