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

Test on Bar Chart implementation. More...

+ Inheritance diagram for ChartBarTest:
+ Collaboration diagram for ChartBarTest:

Public Member Functions

 getDataFactory ()
 
 getUIFactory ()
 
 testImplementsFactoryInterface ()
 
 testGetInstances ()
 
 testEmptyDataset ()
 
 testWithTitle ()
 
 testWithTitleInvisible ()
 
 testWithTooltipsInvisible ()
 
 testWithLegendInvisible ()
 
 testWithLegendPosition ()
 
 testWithInvalidLegendPosition ()
 
 testWithDataset ()
 
 testWithBarConfigs ()
 
 testWithGroupConfigs ()
 
 testIndexAxis ()
 
 testRenderHorizontal ()
 
 testRenderVertical ()
 

Protected Member Functions

 getFactory ()
 
 getSimpleDataset ()
 
 getExtendedDataset ()
 

Detailed Description

Test on Bar Chart implementation.

Definition at line 30 of file ChartBarTest.php.

Member Function Documentation

◆ getDataFactory()

ChartBarTest::getDataFactory ( )

Definition at line 37 of file ChartBarTest.php.

38 {
39 return new ILIAS\Data\Factory();
40 }
Builds data types.
Definition: Factory.php:36

Referenced by getExtendedDataset(), getSimpleDataset(), testEmptyDataset(), testIndexAxis(), testWithBarConfigs(), and testWithGroupConfigs().

+ Here is the caller graph for this function:

◆ getExtendedDataset()

ChartBarTest::getExtendedDataset ( )
protected

Definition at line 68 of file ChartBarTest.php.

69 {
70 $df = $this->getDataFactory();
71
72 $c_dimension = $df->dimension()->cardinal();
73 $t_dimension = $df->dimension()->range($c_dimension);
74
75 $dataset = $df->dataset(["Dataset 1" => $c_dimension, "Dataset 2" => $t_dimension]);
76 $dataset = $dataset->withPoint("Item 1", ["Dataset 1" => -1.25, "Dataset 2" => [-2, -1]]);
77 $dataset = $dataset->withPoint("Item 2", ["Dataset 1" => null, "Dataset 2" => [0, 0.5]]);
78
79 return $dataset;
80 }

References getDataFactory().

Referenced by testRenderVertical(), and testWithDataset().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFactory()

ChartBarTest::getFactory ( )
protected

◆ getSimpleDataset()

ChartBarTest::getSimpleDataset ( )
protected

Definition at line 56 of file ChartBarTest.php.

57 {
58 $df = $this->getDataFactory();
59
60 $c_dimension = $df->dimension()->cardinal();
61
62 $dataset = $df->dataset(["Dataset" => $c_dimension]);
63 $dataset = $dataset->withPoint("Item", ["Dataset" => 0]);
64
65 return $dataset;
66 }

References getDataFactory().

Referenced by testGetInstances(), testIndexAxis(), testRenderHorizontal(), testWithBarConfigs(), testWithDataset(), testWithGroupConfigs(), testWithInvalidLegendPosition(), testWithLegendInvisible(), testWithLegendPosition(), testWithTitle(), testWithTitleInvisible(), and testWithTooltipsInvisible().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUIFactory()

ChartBarTest::getUIFactory ( )

Definition at line 42 of file ChartBarTest.php.

43 {
44 return new class () extends NoUIFactory {
45 public function listing(): I\Component\Listing\Factory
46 {
47 return new I\Component\Listing\Factory(
48 new I\Component\Listing\Workflow\Factory(),
49 new I\Component\Listing\CharacteristicValue\Factory(),
50 new I\Component\Listing\Entity\Factory(),
51 );
52 }
53 };
54 }

References ILIAS\Repository\listing().

+ Here is the call graph for this function:

◆ testEmptyDataset()

ChartBarTest::testEmptyDataset ( )

Definition at line 111 of file ChartBarTest.php.

111 : void
112 {
113 $f = $this->getFactory();
114 $df = $this->getDataFactory();
115
116 $c_dimension = $df->dimension()->cardinal();
117
118 $dataset = $df->dataset(["Dataset" => $c_dimension]);
119
120 $this->expectException(LogicException::class);
121 $this->expectExceptionMessage("Dataset must not be empty.");
122 $horizontal = $f->horizontal(
123 "Horizontal Bar",
124 $dataset
125 );
126 }

References Vendor\Package\$f, getDataFactory(), and getFactory().

+ Here is the call graph for this function:

◆ testGetInstances()

ChartBarTest::testGetInstances ( )

Definition at line 89 of file ChartBarTest.php.

89 : void
90 {
91 $f = $this->getFactory();
92
93 $dataset = $this->getSimpleDataset();
94
95 $horizontal = $f->horizontal(
96 "Horizontal Bar",
97 $dataset
98 );
99
100 $this->assertInstanceOf("ILIAS\\UI\\Component\\Chart\\Bar\\Bar", $horizontal);
101 $this->assertInstanceOf("ILIAS\\UI\\Component\\Chart\\Bar\\Horizontal", $horizontal);
102
103 $vertical = $f->vertical(
104 "Vertical Bar",
105 $dataset
106 );
107 $this->assertInstanceOf("ILIAS\\UI\\Component\\Chart\\Bar\\Bar", $vertical);
108 $this->assertInstanceOf("ILIAS\\UI\\Component\\Chart\\Bar\\Vertical", $vertical);
109 }

References Vendor\Package\$f, getFactory(), and getSimpleDataset().

+ Here is the call graph for this function:

◆ testImplementsFactoryInterface()

ChartBarTest::testImplementsFactoryInterface ( )

Definition at line 82 of file ChartBarTest.php.

82 : void
83 {
84 $f = $this->getFactory();
85
86 $this->assertInstanceOf("ILIAS\\UI\\Component\\Chart\\Bar\\Factory", $f);
87 }

References Vendor\Package\$f, and getFactory().

+ Here is the call graph for this function:

◆ testIndexAxis()

ChartBarTest::testIndexAxis ( )

Definition at line 310 of file ChartBarTest.php.

310 : void
311 {
312 $f = $this->getFactory();
313 $df = $this->getDataFactory();
314
315 $dataset = $this->getSimpleDataset();
316
317 $horizontal = $f->horizontal(
318 "Horizontal Bar",
319 $dataset
320 );
321
322 $this->assertEquals("y", $horizontal->getIndexAxis());
323
324 $vertical = $f->vertical(
325 "Vertical Bar",
326 $dataset
327 );
328
329 $this->assertEquals("x", $vertical->getIndexAxis());
330 }

References Vendor\Package\$f, getDataFactory(), getFactory(), and getSimpleDataset().

+ Here is the call graph for this function:

◆ testRenderHorizontal()

ChartBarTest::testRenderHorizontal ( )

Definition at line 332 of file ChartBarTest.php.

332 : void
333 {
334 $r = $this->getDefaultRenderer();
335 $f = $this->getFactory();
336
337 $dataset = $this->getSimpleDataset();
338
339 $horizontal = $f->horizontal(
340 "bar123",
341 $dataset
342 );
343
344 $html = $r->render($horizontal);
345
346 $expected_html = <<<EOT
347<div class="il-chart-bar-horizontal">
348 <canvas id="id_1" height="150px" aria-label="bar123" role="img"></canvas>
349</div>
350<div class="sr-only">
351 <dl>
352 <dt>Dataset</dt>
353 <dd>
354 <ul>
355 <li>Item: 0</li>
356 </ul>
357 </dd>
358 </dl>
359</div>
360EOT;
361
362 $this->assertHTMLEquals("<div>" . $expected_html . "</div>", "<div>" . $html . "</div>");
363 }

References Vendor\Package\$f, getFactory(), and getSimpleDataset().

+ Here is the call graph for this function:

◆ testRenderVertical()

ChartBarTest::testRenderVertical ( )

Definition at line 365 of file ChartBarTest.php.

365 : void
366 {
367 $r = $this->getDefaultRenderer();
368 $f = $this->getFactory();
369
370 $dataset = $this->getExtendedDataset();
371
372 $vertical = $f->vertical(
373 "bar123",
374 $dataset
375 );
376
377 $html = $r->render($vertical);
378
379 $expected_html = <<<EOT
380<div class="il-chart-bar-vertical">
381 <canvas id="id_1" height="165px" aria-label="bar123" role="img"></canvas>
382</div>
383<div class="sr-only">
384 <dl>
385 <dt>Dataset 1</dt>
386 <dd>
387 <ul>
388 <li>Item 1: -1.25</li>
389 <li>Item 2: -</li>
390 </ul>
391 </dd>
392 <dt>Dataset 2</dt>
393 <dd>
394 <ul>
395 <li>Item 1: -2 - -1</li>
396 <li>Item 2: 0 - 0.5</li>
397 </ul>
398 </dd>
399 </dl>
400</div>
401EOT;
402
403 $this->assertHTMLEquals("<div>" . $expected_html . "</div>", "<div>" . $html . "</div>");
404 }

References Vendor\Package\$f, getExtendedDataset(), and getFactory().

+ Here is the call graph for this function:

◆ testWithBarConfigs()

ChartBarTest::testWithBarConfigs ( )

Definition at line 262 of file ChartBarTest.php.

262 : void
263 {
264 $f = $this->getFactory();
265 $df = $this->getDataFactory();
266
267 $dataset = $this->getSimpleDataset();
268
269 $bc = new C\Chart\Bar\BarConfig();
270 $bc = $bc->withColor($df->color("#d38000"));
271
272 $bars = [
273 "Dataset" => $bc,
274 ];
275
276 $horizontal = $f->horizontal(
277 "Horizontal Bar",
278 $dataset
279 );
280 $horizontal1 = $horizontal->withBarConfigs($bars);
281
282 $this->assertEquals([], $horizontal->getBarConfigs());
283 $this->assertEquals($bars, $horizontal1->getBarConfigs());
284 }

References Vendor\Package\$f, getDataFactory(), getFactory(), and getSimpleDataset().

+ Here is the call graph for this function:

◆ testWithDataset()

ChartBarTest::testWithDataset ( )

Definition at line 245 of file ChartBarTest.php.

245 : void
246 {
247 $f = $this->getFactory();
248
249 $s_dataset = $this->getSimpleDataset();
250 $e_dataset = $this->getExtendedDataset();
251
252 $horizontal = $f->horizontal(
253 "Horizontal Bar",
254 $s_dataset
255 );
256 $horizontal1 = $horizontal->withDataset($e_dataset);
257
258 $this->assertEquals($s_dataset, $horizontal->getDataset());
259 $this->assertEquals($e_dataset, $horizontal1->getDataset());
260 }

References Vendor\Package\$f, getExtendedDataset(), getFactory(), and getSimpleDataset().

+ Here is the call graph for this function:

◆ testWithGroupConfigs()

ChartBarTest::testWithGroupConfigs ( )

Definition at line 286 of file ChartBarTest.php.

286 : void
287 {
288 $f = $this->getFactory();
289 $df = $this->getDataFactory();
290
291 $dataset = $this->getSimpleDataset();
292
293 $gc = new C\Chart\Bar\GroupConfig();
294 $gc = $gc->withStacked();
295
296 $groups = [
297 "Group" => $gc,
298 ];
299
300 $horizontal = $f->horizontal(
301 "Horizontal Bar",
302 $dataset
303 );
304 $horizontal1 = $horizontal->withGroupConfigs($groups);
305
306 $this->assertEquals([], $horizontal->getGroupConfigs());
307 $this->assertEquals($groups, $horizontal1->getGroupConfigs());
308 }

References Vendor\Package\$f, getDataFactory(), getFactory(), and getSimpleDataset().

+ Here is the call graph for this function:

◆ testWithInvalidLegendPosition()

ChartBarTest::testWithInvalidLegendPosition ( )

Definition at line 228 of file ChartBarTest.php.

228 : void
229 {
230 $f = $this->getFactory();
231
232 $dataset = $this->getSimpleDataset();
233
234 $horizontal = $f->horizontal(
235 "Horizontal Bar",
236 $dataset
237 );
238
239 $this->expectException(InvalidArgumentException::class);
240 $this->expectExceptionMessage("Position must be 'bottom', 'top', 'left' or 'right'.");
241
242 $horizontal = $horizontal->withLegendPosition("middle");
243 }

References Vendor\Package\$f, getFactory(), and getSimpleDataset().

+ Here is the call graph for this function:

◆ testWithLegendInvisible()

ChartBarTest::testWithLegendInvisible ( )

Definition at line 196 of file ChartBarTest.php.

196 : void
197 {
198 $f = $this->getFactory();
199
200 $dataset = $this->getSimpleDataset();
201
202 $horizontal = $f->horizontal(
203 "Horizontal Bar",
204 $dataset
205 );
206 $horizontal1 = $horizontal->withLegendVisible(false);
207
208 $this->assertEquals(true, $horizontal->isLegendVisible());
209 $this->assertEquals(false, $horizontal1->isLegendVisible());
210 }

References Vendor\Package\$f, getFactory(), and getSimpleDataset().

+ Here is the call graph for this function:

◆ testWithLegendPosition()

ChartBarTest::testWithLegendPosition ( )

Definition at line 212 of file ChartBarTest.php.

212 : void
213 {
214 $f = $this->getFactory();
215
216 $dataset = $this->getSimpleDataset();
217
218 $horizontal = $f->horizontal(
219 "Horizontal Bar",
220 $dataset
221 );
222 $horizontal1 = $horizontal->withLegendPosition("left");
223
224 $this->assertEquals("top", $horizontal->getLegendPosition());
225 $this->assertEquals("left", $horizontal1->getLegendPosition());
226 }

References Vendor\Package\$f, getFactory(), and getSimpleDataset().

+ Here is the call graph for this function:

◆ testWithTitle()

ChartBarTest::testWithTitle ( )

Definition at line 148 of file ChartBarTest.php.

148 : void
149 {
150 $f = $this->getFactory();
151
152 $dataset = $this->getSimpleDataset();
153
154 $horizontal = $f->horizontal(
155 "Horizontal Bar",
156 $dataset
157 );
158 $horizontal1 = $horizontal->withTitle("Alternative title for Horizontal Bar");
159
160 $this->assertEquals("Horizontal Bar", $horizontal->getTitle());
161 $this->assertEquals("Alternative title for Horizontal Bar", $horizontal1->getTitle());
162 }

References Vendor\Package\$f, getFactory(), and getSimpleDataset().

+ Here is the call graph for this function:

◆ testWithTitleInvisible()

ChartBarTest::testWithTitleInvisible ( )

Definition at line 164 of file ChartBarTest.php.

164 : void
165 {
166 $f = $this->getFactory();
167
168 $dataset = $this->getSimpleDataset();
169
170 $horizontal = $f->horizontal(
171 "Horizontal Bar",
172 $dataset
173 );
174 $horizontal1 = $horizontal->withTitleVisible(false);
175
176 $this->assertEquals(true, $horizontal->isTitleVisible());
177 $this->assertEquals(false, $horizontal1->isTitleVisible());
178 }

References Vendor\Package\$f, getFactory(), and getSimpleDataset().

+ Here is the call graph for this function:

◆ testWithTooltipsInvisible()

ChartBarTest::testWithTooltipsInvisible ( )

Definition at line 180 of file ChartBarTest.php.

180 : void
181 {
182 $f = $this->getFactory();
183
184 $dataset = $this->getSimpleDataset();
185
186 $horizontal = $f->horizontal(
187 "Horizontal Bar",
188 $dataset
189 );
190 $horizontal1 = $horizontal->withTooltipsVisible(false);
191
192 $this->assertEquals(true, $horizontal->isTooltipsVisible());
193 $this->assertEquals(false, $horizontal1->isTooltipsVisible());
194 }

References Vendor\Package\$f, getFactory(), and getSimpleDataset().

+ Here is the call graph for this function:

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