ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ColumnTest Class Reference

Basic Tests for Table-Columns. More...

+ Inheritance diagram for ColumnTest:
+ Collaboration diagram for ColumnTest:

Public Member Functions

 setUp ()
 
 testDataTableColumnsAttributes ()
 
 testDataTableColumnBoolFormat ()
 
 testDataTableColumnBoolFormatWithIcon ()
 
 testDataTableColumnBoolFormatWithGlyph ()
 
 testDataTableColumnDateFormat ()
 
 testDataTableColumnTimespanFormat ()
 
 testDataTableColumnNumnberFormat ()
 
 testDataTableColumnAllowedFormats (Column\Column $column, mixed $value, bool $ok)
 
 testDataTableColumnLinkListingFormat ()
 
 testDataTableColumnLinkListingFormatAcceptsOnlyLinkListings ()
 
 testDataTableColumnLinkListingItemsFormatAcceptsOnlyLinks ()
 
 testDataTableColumnCustomOrderingLabels ()
 

Static Public Member Functions

static provideColumnFormats ()
 

Protected Attributes

Language $lng
 

Detailed Description

Basic Tests for Table-Columns.

Definition at line 36 of file ColumnTest.php.

Member Function Documentation

◆ provideColumnFormats()

static ColumnTest::provideColumnFormats ( )
static

Definition at line 137 of file ColumnTest.php.

137 : array
138 {
139 $lng = new class () extends \ilLanguage {
140 public function __construct()
141 {
142 }
143 };
144 return [
145 [
146 'column' => new Column\LinkListing($lng, ''),
147 'value' => new Listing\Unordered([(new Link\Standard('label', '#')),(new Link\Standard('label', '#'))]),
148 'ok' => true
149 ],
150 [
151 'column' => new Column\LinkListing($lng, ''),
152 'value' => new Listing\Unordered(['string', 'string']),
153 'ok' => false
154 ],
155 [
156 'column' => new Column\LinkListing($lng, ''),
157 'value' => new Listing\Ordered([(new Link\Standard('label', '#')),(new Link\Standard('label', '#'))]),
158 'ok' => true
159 ],
160 [
161 'column' => new Column\LinkListing($lng, ''),
162 'value' => 123,
163 'ok' => false
164 ],
165 [
166 'column' => new Column\Link($lng, ''),
167 'value' => new Link\Standard('label', '#'),
168 'ok' => true
169 ],
170 [
171 'column' => new Column\Link($lng, ''),
172 'value' => 'some string',
173 'ok' => false
174 ],
175 [
176 'column' => new Column\StatusIcon($lng, ''),
177 'value' => new StandardIcon('', '', 'small', false),
178 'ok' => true
179 ],
180 [
181 'column' => new Column\StatusIcon($lng, ''),
182 'value' => 'some string',
183 'ok' => false
184 ],
185 ];
186 }
Language $lng
Definition: ColumnTest.php:38
return true
language handling
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References $lng, ILIAS\GlobalScreen\Provider\__construct(), and true.

+ Here is the call graph for this function:

◆ setUp()

ColumnTest::setUp ( )

Definition at line 40 of file ColumnTest.php.

40 : void
41 {
42 $lng = $this->getMockBuilder(\ILIAS\Language\Language::class)
43 ->disableOriginalConstructor()
44 ->getMock();
45 $lng->method('txt')->willReturnCallback(fn($v) => $v);
46 $this->lng = $lng;
47 }
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

References $lng, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testDataTableColumnAllowedFormats()

ColumnTest::testDataTableColumnAllowedFormats ( Column\Column  $column,
mixed  $value,
bool  $ok 
)

Definition at line 189 of file ColumnTest.php.

193 : void {
194 if(! $ok) {
195 $this->expectException(\InvalidArgumentException::class);
196 }
197 $this->assertEquals($value, $column->format($value));
198 }

◆ testDataTableColumnBoolFormat()

ColumnTest::testDataTableColumnBoolFormat ( )

Definition at line 77 of file ColumnTest.php.

77 : void
78 {
79 $col = new Column\Boolean($this->lng, 'col', 'TRUE', 'FALSE');
80 $this->assertEquals('TRUE', $col->format(true));
81 $this->assertEquals('FALSE', $col->format(false));
82 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testDataTableColumnBoolFormatWithGlyph()

ColumnTest::testDataTableColumnBoolFormatWithGlyph ( )

Definition at line 93 of file ColumnTest.php.

93 : void
94 {
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));
100 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testDataTableColumnBoolFormatWithIcon()

ColumnTest::testDataTableColumnBoolFormatWithIcon ( )

Definition at line 84 of file ColumnTest.php.

84 : void
85 {
86 $ok = new StandardIcon('', 'ok', 'small', false);
87 $no = new StandardIcon('', 'notok', 'small', 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));
91 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testDataTableColumnCustomOrderingLabels()

ColumnTest::testDataTableColumnCustomOrderingLabels ( )

Definition at line 226 of file ColumnTest.php.

226 : void
227 {
228 $col = (new Column\LinkListing($this->lng, 'col'))
229 ->withIsSortable(true)
230 ->withOrderingLabels(
231 'custom label ASC',
232 'custom label DESC',
233 );
234 $this->assertEquals(
235 [
236 'custom label ASC',
237 'custom label DESC'
238 ],
239 $col->getOrderingLabels()
240 );
241 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testDataTableColumnDateFormat()

ColumnTest::testDataTableColumnDateFormat ( )

Definition at line 102 of file ColumnTest.php.

102 : void
103 {
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));
109 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testDataTableColumnLinkListingFormat()

ColumnTest::testDataTableColumnLinkListingFormat ( )

Definition at line 201 of file ColumnTest.php.

201 : void
202 {
203 $col = new Column\LinkListing($this->lng, 'col');
204 $link = new Link\Standard('label', '#');
205 $linklisting = new Listing\Unordered([$link, $link, $link]);
206 $this->assertEquals($linklisting, $col->format($linklisting));
207 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testDataTableColumnLinkListingFormatAcceptsOnlyLinkListings()

ColumnTest::testDataTableColumnLinkListingFormatAcceptsOnlyLinkListings ( )

Definition at line 209 of file ColumnTest.php.

209 : void
210 {
211 $this->expectException(\InvalidArgumentException::class);
212 $col = new Column\LinkListing($this->lng, 'col');
213 $linklisting_invalid = new Link\Standard('label', '#');
214 $this->assertEquals($linklisting_invalid, $col->format($linklisting_invalid));
215 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testDataTableColumnLinkListingItemsFormatAcceptsOnlyLinks()

ColumnTest::testDataTableColumnLinkListingItemsFormatAcceptsOnlyLinks ( )

Definition at line 217 of file ColumnTest.php.

217 : void
218 {
219 $this->expectException(\InvalidArgumentException::class);
220 $col = new Column\LinkListing($this->lng, 'col');
221 $link = 'some string';
222 $linklisting_invalid = new Listing\Unordered([$link, $link, $link]);
223 $this->assertEquals($linklisting_invalid, $col->format($linklisting_invalid));
224 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testDataTableColumnNumnberFormat()

ColumnTest::testDataTableColumnNumnberFormat ( )

Definition at line 123 of file ColumnTest.php.

123 : void
124 {
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));
135 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testDataTableColumnsAttributes()

ColumnTest::testDataTableColumnsAttributes ( )

Definition at line 49 of file ColumnTest.php.

49 : void
50 {
51 $col = new Column\Text($this->lng, 'col');
52 $this->assertEquals('col', $col->getTitle());
53
54 $this->assertTrue($col->isSortable());
55 $this->assertFalse($col->withIsSortable(false)->isSortable());
56 $this->assertTrue($col->withIsSortable(true)->isSortable());
57 $this->assertEquals([
58 'col, order_option_alphabetical_ascending',
59 'col, order_option_alphabetical_descending',
60 ], $col->getOrderingLabels());
61
62 $this->assertFalse($col->isOptional());
63 $this->assertTrue($col->withIsOptional(true)->isOptional());
64 $this->assertFalse($col->withIsOptional(false)->isOptional());
65
66 $this->assertTrue($col->isInitiallyVisible());
67 $this->assertFalse($col->withIsOptional(true, false)->isInitiallyVisible());
68 $this->assertTrue($col->withIsOptional(true, true)->isInitiallyVisible());
69
70 $this->assertFalse($col->isHighlighted());
71 $this->assertTrue($col->withHighlight(true)->isHighlighted());
72 $this->assertFalse($col->withHighlight(false)->isHighlighted());
73
74 $this->assertEquals(12, $col->withIndex(12)->getIndex());
75 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testDataTableColumnTimespanFormat()

ColumnTest::testDataTableColumnTimespanFormat ( )

Definition at line 111 of file ColumnTest.php.

111 : void
112 {
113 $df = new \ILIAS\Data\Factory();
114 $format = $df->dateFormat()->germanShort();
115 $dat = new \DateTimeImmutable();
116 $col = new Column\TimeSpan($this->lng, 'col', $format);
117 $this->assertEquals(
118 $dat->format($format->toString()) . ' - ' . $dat->format($format->toString()),
119 $col->format([$dat, $dat])
120 );
121 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

Field Documentation

◆ $lng

Language ColumnTest::$lng
protected

Definition at line 38 of file ColumnTest.php.

Referenced by provideColumnFormats(), and setUp().


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