19 declare(strict_types=1);
22 require_once(
"libs/composer/vendor/autoload.php");
23 require_once(__DIR__ .
"/../../../Base.php");
39 $lng = $this->getMockBuilder(\ilLanguage::class)
40 ->disableOriginalConstructor()
42 $lng->method(
'txt')->willReturnCallback(fn($v) => $v);
48 $col =
new Column\Text($this->
lng,
'col');
49 $this->assertEquals(
'col', $col->getTitle());
51 $this->assertTrue($col->isSortable());
52 $this->assertFalse($col->withIsSortable(
false)->isSortable());
53 $this->assertTrue($col->withIsSortable(
true)->isSortable());
55 'col, order_option_alphabetical_ascending',
56 'col, order_option_alphabetical_descending',
57 ], $col->getOrderingLabels());
59 $this->assertFalse($col->isOptional());
60 $this->assertTrue($col->withIsOptional(
true)->isOptional());
61 $this->assertFalse($col->withIsOptional(
false)->isOptional());
63 $this->assertTrue($col->isInitiallyVisible());
64 $this->assertFalse($col->withIsOptional(
true,
false)->isInitiallyVisible());
65 $this->assertTrue($col->withIsOptional(
true,
true)->isInitiallyVisible());
67 $this->assertFalse($col->isHighlighted());
68 $this->assertTrue($col->withHighlight(
true)->isHighlighted());
69 $this->assertFalse($col->withHighlight(
false)->isHighlighted());
71 $this->assertEquals(12, $col->withIndex(12)->getIndex());
76 $col =
new Column\Boolean($this->
lng,
'col',
'TRUE',
'FALSE');
77 $this->assertEquals(
'TRUE', $col->format(
true));
78 $this->assertEquals(
'FALSE', $col->format(
false));
85 $col =
new Column\Boolean($this->
lng,
'col', $ok, $no);
86 $this->assertEquals($ok, $col->format(
true));
87 $this->assertEquals($no, $col->format(
false));
92 $ok =
new Glyph(GlyphInterface::LIKE,
'');
93 $no =
new Glyph(GlyphInterface::DISLIKE,
'');
94 $col =
new Column\Boolean($this->
lng,
'col', $ok, $no);
95 $this->assertEquals($ok, $col->format(
true));
96 $this->assertEquals($no, $col->format(
false));
101 $df = new \ILIAS\Data\Factory();
102 $format = $df->dateFormat()->germanShort();
103 $dat = new \DateTimeImmutable();
104 $col =
new Column\Date($this->
lng,
'col', $format);
105 $this->assertEquals($dat->format($format->toString()), $col->format($dat));
110 $df = new \ILIAS\Data\Factory();
111 $format = $df->dateFormat()->germanShort();
112 $dat = new \DateTimeImmutable();
113 $col =
new Column\Timespan($this->
lng,
'col', $format);
115 $dat->format($format->toString()) .
' - ' . $dat->format($format->toString()),
116 $col->format([$dat, $dat])
122 $df = new \ILIAS\Data\Factory();
123 $dat = new \DateTimeImmutable();
124 $col =
new Column\Number($this->
lng,
'col');
125 $this->assertEquals(
'1', $col->format(1));
126 $col = $col->withDecimals(3);
127 $this->assertEquals(
'1,000', $col->format(1));
128 $col = $col->withDecimals(2)->withUnit(
'$', $col::UNIT_POSITION_FORE);
129 $this->assertEquals(
'$ 1,00', $col->format(1));
130 $col = $col->withUnit(
'€', $col::UNIT_POSITION_AFT);
131 $this->assertEquals(
'1,00 €', $col->format(1));
143 'column' =>
new Column\LinkListing(
$lng,
''),
148 'column' =>
new Column\LinkListing(
$lng,
''),
149 'value' =>
new Listing\Unordered([
'string',
'string']),
153 'column' =>
new Column\LinkListing(
$lng,
''),
158 'column' =>
new Column\LinkListing(
$lng,
''),
163 'column' =>
new Column\Link(
$lng,
''),
164 'value' =>
new Link\Standard(
'label',
'#'),
168 'column' =>
new Column\Link(
$lng,
''),
169 'value' =>
'some string',
173 'column' =>
new Column\StatusIcon(
$lng,
''),
178 'column' =>
new Column\StatusIcon(
$lng,
''),
179 'value' =>
'some string',
194 $this->expectException(\InvalidArgumentException::class);
196 $this->assertEquals($value, $column->format($value));
202 $col =
new Column\LinkListing($this->
lng,
'col');
203 $link =
new Link\Standard(
'label',
'#');
204 $linklisting =
new Listing\Unordered([$link, $link, $link]);
205 $this->assertEquals($linklisting, $col->format($linklisting));
210 $this->expectException(\InvalidArgumentException::class);
211 $col =
new Column\LinkListing($this->
lng,
'col');
212 $linklisting_invalid =
new Link\Standard(
'label',
'#');
213 $this->assertEquals($linklisting_invalid, $col->format($linklisting_invalid));
218 $this->expectException(\InvalidArgumentException::class);
219 $col =
new Column\LinkListing($this->
lng,
'col');
220 $link =
'some string';
221 $linklisting_invalid =
new Listing\Unordered([$link, $link, $link]);
222 $this->assertEquals($linklisting_invalid, $col->format($linklisting_invalid));
227 $col = (
new Column\LinkListing($this->
lng,
'col'))
228 ->withIsSortable(
true)
229 ->withOrderingLabels(
238 $col->getOrderingLabels()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static provideColumnFormats()
testDataTableColumnBoolFormatWithGlyph()
testDataTableColumnsAttributes()
testDataTableColumnCustomOrderingLabels()
testDataTableColumnNumnberFormat()
This describes how a glyph could be modified during construction of UI.
This implements commonalities between Links.
testDataTableColumnBoolFormatWithIcon()
Provides common functionality for UI tests.
testDataTableColumnDateFormat()
testDataTableColumnLinkListingFormat()
testDataTableColumnTimespanFormat()
testDataTableColumnAllowedFormats(Column\Column $column, mixed $value, bool $ok)
 * provideColumnFormats 
testDataTableColumnLinkListingItemsFormatAcceptsOnlyLinks()
testDataTableColumnBoolFormat()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
A Column describes the form of presentation for a certain aspect of data, i.e.
testDataTableColumnLinkListingFormatAcceptsOnlyLinkListings()
Basic Tests for Table-Columns.