ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)
  * provideColumnFormats  More...
 
 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.

References ILIAS\GlobalScreen\Provider\__construct().

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
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

◆ setUp()

ColumnTest::setUp ( )

Definition at line 40 of file ColumnTest.php.

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

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 Contains several chained tasks and infos about them.
Language $lng
Definition: ColumnTest.php:38
+ Here is the call graph for this function:

◆ testDataTableColumnAllowedFormats()

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

 * provideColumnFormats 

Definition at line 191 of file ColumnTest.php.

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

◆ testDataTableColumnBoolFormat()

ColumnTest::testDataTableColumnBoolFormat ( )

Definition at line 77 of file ColumnTest.php.

References ILIAS\Repository\lng().

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  }
+ Here is the call graph for this function:

◆ testDataTableColumnBoolFormatWithGlyph()

ColumnTest::testDataTableColumnBoolFormatWithGlyph ( )

Definition at line 93 of file ColumnTest.php.

References ILIAS\Repository\lng().

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  }
+ Here is the call graph for this function:

◆ testDataTableColumnBoolFormatWithIcon()

ColumnTest::testDataTableColumnBoolFormatWithIcon ( )

Definition at line 84 of file ColumnTest.php.

References ILIAS\Repository\lng().

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  }
+ Here is the call graph for this function:

◆ testDataTableColumnCustomOrderingLabels()

ColumnTest::testDataTableColumnCustomOrderingLabels ( )

Definition at line 228 of file ColumnTest.php.

References ILIAS\Repository\lng().

228  : void
229  {
230  $col = (new Column\LinkListing($this->lng, 'col'))
231  ->withIsSortable(true)
232  ->withOrderingLabels(
233  'custom label ASC',
234  'custom label DESC',
235  );
236  $this->assertEquals(
237  [
238  'custom label ASC',
239  'custom label DESC'
240  ],
241  $col->getOrderingLabels()
242  );
243  }
+ Here is the call graph for this function:

◆ testDataTableColumnDateFormat()

ColumnTest::testDataTableColumnDateFormat ( )

Definition at line 102 of file ColumnTest.php.

References ILIAS\Repository\lng().

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  }
+ Here is the call graph for this function:

◆ testDataTableColumnLinkListingFormat()

ColumnTest::testDataTableColumnLinkListingFormat ( )

Definition at line 203 of file ColumnTest.php.

References ILIAS\Repository\lng().

203  : void
204  {
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));
209  }
+ Here is the call graph for this function:

◆ testDataTableColumnLinkListingFormatAcceptsOnlyLinkListings()

ColumnTest::testDataTableColumnLinkListingFormatAcceptsOnlyLinkListings ( )

Definition at line 211 of file ColumnTest.php.

References ILIAS\Repository\lng().

211  : void
212  {
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));
217  }
+ Here is the call graph for this function:

◆ testDataTableColumnLinkListingItemsFormatAcceptsOnlyLinks()

ColumnTest::testDataTableColumnLinkListingItemsFormatAcceptsOnlyLinks ( )

Definition at line 219 of file ColumnTest.php.

References ILIAS\Repository\lng().

219  : void
220  {
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));
226  }
+ Here is the call graph for this function:

◆ testDataTableColumnNumnberFormat()

ColumnTest::testDataTableColumnNumnberFormat ( )

Definition at line 123 of file ColumnTest.php.

References ILIAS\Repository\lng().

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  }
+ Here is the call graph for this function:

◆ testDataTableColumnsAttributes()

ColumnTest::testDataTableColumnsAttributes ( )

Definition at line 49 of file ColumnTest.php.

References ILIAS\Repository\lng().

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  }
+ Here is the call graph for this function:

◆ testDataTableColumnTimespanFormat()

ColumnTest::testDataTableColumnTimespanFormat ( )

Definition at line 111 of file ColumnTest.php.

References ILIAS\Repository\lng().

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  }
+ 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 setUp().


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