ILIAS  release_8 Revision v8.24
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, $value, bool $ok)
  * @dataProvider provideColumnFormats 
More...
 
 testDataTableColumnLinkListingFormat ()
 
 testDataTableColumnLinkListingFormatAcceptsOnlyLinkListings ()
 
 testDataTableColumnLinkListingItemsFormatAcceptsOnlyLinks ()
 
 testDataTableColumnCustomOrderingLabels ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML (string $html)
 
 assertHTMLEquals (string $expected_html_as_string, string $html_as_string)
 

Static Public Member Functions

static provideColumnFormats ()
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML (string $html)
 A more radical version of normalizeHTML. More...
 
 brutallyTrimSignals (string $html)
 A naive replacement of all il_signal-ids with dots to ease comparisons of rendered output. More...
 

Detailed Description

Basic Tests for Table-Columns.

Definition at line 35 of file ColumnTest.php.

Member Function Documentation

◆ provideColumnFormats()

static ColumnTest::provideColumnFormats ( )
static

Definition at line 134 of file ColumnTest.php.

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

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

+ Here is the call graph for this function:

◆ setUp()

ColumnTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 37 of file ColumnTest.php.

37 : void
38 {
39 $lng = $this->getMockBuilder(\ilLanguage::class)
40 ->disableOriginalConstructor()
41 ->getMock();
42 $lng->method('txt')->willReturnCallback(fn($v) => $v);
43 $this->lng = $lng;
44 }

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

+ Here is the call graph for this function:

◆ testDataTableColumnAllowedFormats()

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

 * @dataProvider provideColumnFormats 

Definition at line 188 of file ColumnTest.php.

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

◆ testDataTableColumnBoolFormat()

ColumnTest::testDataTableColumnBoolFormat ( )

Definition at line 74 of file ColumnTest.php.

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

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testDataTableColumnBoolFormatWithGlyph()

ColumnTest::testDataTableColumnBoolFormatWithGlyph ( )

Definition at line 90 of file ColumnTest.php.

90 : void
91 {
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));
97 }
This describes how a glyph could be modified during construction of UI.
Definition: Glyph.php:31

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testDataTableColumnBoolFormatWithIcon()

ColumnTest::testDataTableColumnBoolFormatWithIcon ( )

Definition at line 81 of file ColumnTest.php.

81 : void
82 {
83 $ok = new StandardIcon('', 'ok', 'small', false);
84 $no = new StandardIcon('', 'notok', 'small', 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));
88 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testDataTableColumnCustomOrderingLabels()

ColumnTest::testDataTableColumnCustomOrderingLabels ( )

Definition at line 224 of file ColumnTest.php.

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

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testDataTableColumnDateFormat()

ColumnTest::testDataTableColumnDateFormat ( )

Definition at line 99 of file ColumnTest.php.

99 : void
100 {
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));
106 }
$format
Definition: metadata.php:235

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

+ Here is the call graph for this function:

◆ testDataTableColumnLinkListingFormat()

ColumnTest::testDataTableColumnLinkListingFormat ( )

Definition at line 199 of file ColumnTest.php.

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

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testDataTableColumnLinkListingFormatAcceptsOnlyLinkListings()

ColumnTest::testDataTableColumnLinkListingFormatAcceptsOnlyLinkListings ( )

Definition at line 207 of file ColumnTest.php.

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

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testDataTableColumnLinkListingItemsFormatAcceptsOnlyLinks()

ColumnTest::testDataTableColumnLinkListingItemsFormatAcceptsOnlyLinks ( )

Definition at line 215 of file ColumnTest.php.

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

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testDataTableColumnNumnberFormat()

ColumnTest::testDataTableColumnNumnberFormat ( )

Definition at line 120 of file ColumnTest.php.

120 : void
121 {
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));
132 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testDataTableColumnsAttributes()

ColumnTest::testDataTableColumnsAttributes ( )

Definition at line 46 of file ColumnTest.php.

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

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ testDataTableColumnTimespanFormat()

ColumnTest::testDataTableColumnTimespanFormat ( )

Definition at line 108 of file ColumnTest.php.

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

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

+ Here is the call graph for this function:

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