ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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.

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

38  {
39  return new ILIAS\Data\Factory();
40  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ getExtendedDataset()

ChartBarTest::getExtendedDataset ( )
protected

Definition at line 64 of file ChartBarTest.php.

References getDataFactory().

Referenced by testRenderVertical(), and testWithDataset().

65  {
66  $df = $this->getDataFactory();
67 
68  $c_dimension = $df->dimension()->cardinal();
69  $t_dimension = $df->dimension()->range($c_dimension);
70 
71  $dataset = $df->dataset(["Dataset 1" => $c_dimension, "Dataset 2" => $t_dimension]);
72  $dataset = $dataset->withPoint("Item 1", ["Dataset 1" => -1.25, "Dataset 2" => [-2, -1]]);
73  $dataset = $dataset->withPoint("Item 2", ["Dataset 1" => null, "Dataset 2" => [0, 0.5]]);
74 
75  return $dataset;
76  }
+ 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 52 of file ChartBarTest.php.

References getDataFactory().

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

53  {
54  $df = $this->getDataFactory();
55 
56  $c_dimension = $df->dimension()->cardinal();
57 
58  $dataset = $df->dataset(["Dataset" => $c_dimension]);
59  $dataset = $dataset->withPoint("Item", ["Dataset" => 0]);
60 
61  return $dataset;
62  }
+ 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.

References ILIAS\Repository\listing().

42  : NoUIFactory
43  {
44  return new class () extends NoUIFactory {
45  public function listing(): I\Component\Listing\Factory
46  {
47  return new I\Component\Listing\Factory();
48  }
49  };
50  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ testEmptyDataset()

ChartBarTest::testEmptyDataset ( )

Definition at line 107 of file ChartBarTest.php.

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

107  : void
108  {
109  $f = $this->getFactory();
110  $df = $this->getDataFactory();
111 
112  $c_dimension = $df->dimension()->cardinal();
113 
114  $dataset = $df->dataset(["Dataset" => $c_dimension]);
115 
116  $this->expectException(LogicException::class);
117  $this->expectExceptionMessage("Dataset must not be empty.");
118  $horizontal = $f->horizontal(
119  "Horizontal Bar",
120  $dataset
121  );
122  }
+ Here is the call graph for this function:

◆ testGetInstances()

ChartBarTest::testGetInstances ( )

Definition at line 85 of file ChartBarTest.php.

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

85  : void
86  {
87  $f = $this->getFactory();
88 
89  $dataset = $this->getSimpleDataset();
90 
91  $horizontal = $f->horizontal(
92  "Horizontal Bar",
93  $dataset
94  );
95 
96  $this->assertInstanceOf("ILIAS\\UI\\Component\\Chart\\Bar\\Bar", $horizontal);
97  $this->assertInstanceOf("ILIAS\\UI\\Component\\Chart\\Bar\\Horizontal", $horizontal);
98 
99  $vertical = $f->vertical(
100  "Vertical Bar",
101  $dataset
102  );
103  $this->assertInstanceOf("ILIAS\\UI\\Component\\Chart\\Bar\\Bar", $vertical);
104  $this->assertInstanceOf("ILIAS\\UI\\Component\\Chart\\Bar\\Vertical", $vertical);
105  }
+ Here is the call graph for this function:

◆ testImplementsFactoryInterface()

ChartBarTest::testImplementsFactoryInterface ( )

Definition at line 78 of file ChartBarTest.php.

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

78  : void
79  {
80  $f = $this->getFactory();
81 
82  $this->assertInstanceOf("ILIAS\\UI\\Component\\Chart\\Bar\\Factory", $f);
83  }
+ Here is the call graph for this function:

◆ testIndexAxis()

ChartBarTest::testIndexAxis ( )

Definition at line 306 of file ChartBarTest.php.

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

306  : void
307  {
308  $f = $this->getFactory();
309  $df = $this->getDataFactory();
310 
311  $dataset = $this->getSimpleDataset();
312 
313  $horizontal = $f->horizontal(
314  "Horizontal Bar",
315  $dataset
316  );
317 
318  $this->assertEquals("y", $horizontal->getIndexAxis());
319 
320  $vertical = $f->vertical(
321  "Vertical Bar",
322  $dataset
323  );
324 
325  $this->assertEquals("x", $vertical->getIndexAxis());
326  }
+ Here is the call graph for this function:

◆ testRenderHorizontal()

ChartBarTest::testRenderHorizontal ( )

Definition at line 328 of file ChartBarTest.php.

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

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

◆ testRenderVertical()

ChartBarTest::testRenderVertical ( )

Definition at line 361 of file ChartBarTest.php.

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

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

◆ testWithBarConfigs()

ChartBarTest::testWithBarConfigs ( )

Definition at line 258 of file ChartBarTest.php.

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

258  : void
259  {
260  $f = $this->getFactory();
261  $df = $this->getDataFactory();
262 
263  $dataset = $this->getSimpleDataset();
264 
265  $bc = new C\Chart\Bar\BarConfig();
266  $bc = $bc->withColor($df->color("#d38000"));
267 
268  $bars = [
269  "Dataset" => $bc,
270  ];
271 
272  $horizontal = $f->horizontal(
273  "Horizontal Bar",
274  $dataset
275  );
276  $horizontal1 = $horizontal->withBarConfigs($bars);
277 
278  $this->assertEquals([], $horizontal->getBarConfigs());
279  $this->assertEquals($bars, $horizontal1->getBarConfigs());
280  }
+ Here is the call graph for this function:

◆ testWithDataset()

ChartBarTest::testWithDataset ( )

Definition at line 241 of file ChartBarTest.php.

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

241  : void
242  {
243  $f = $this->getFactory();
244 
245  $s_dataset = $this->getSimpleDataset();
246  $e_dataset = $this->getExtendedDataset();
247 
248  $horizontal = $f->horizontal(
249  "Horizontal Bar",
250  $s_dataset
251  );
252  $horizontal1 = $horizontal->withDataset($e_dataset);
253 
254  $this->assertEquals($s_dataset, $horizontal->getDataset());
255  $this->assertEquals($e_dataset, $horizontal1->getDataset());
256  }
+ Here is the call graph for this function:

◆ testWithGroupConfigs()

ChartBarTest::testWithGroupConfigs ( )

Definition at line 282 of file ChartBarTest.php.

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

282  : void
283  {
284  $f = $this->getFactory();
285  $df = $this->getDataFactory();
286 
287  $dataset = $this->getSimpleDataset();
288 
289  $gc = new C\Chart\Bar\GroupConfig();
290  $gc = $gc->withStacked();
291 
292  $groups = [
293  "Group" => $gc,
294  ];
295 
296  $horizontal = $f->horizontal(
297  "Horizontal Bar",
298  $dataset
299  );
300  $horizontal1 = $horizontal->withGroupConfigs($groups);
301 
302  $this->assertEquals([], $horizontal->getGroupConfigs());
303  $this->assertEquals($groups, $horizontal1->getGroupConfigs());
304  }
+ Here is the call graph for this function:

◆ testWithInvalidLegendPosition()

ChartBarTest::testWithInvalidLegendPosition ( )

Definition at line 224 of file ChartBarTest.php.

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

224  : void
225  {
226  $f = $this->getFactory();
227 
228  $dataset = $this->getSimpleDataset();
229 
230  $horizontal = $f->horizontal(
231  "Horizontal Bar",
232  $dataset
233  );
234 
235  $this->expectException(InvalidArgumentException::class);
236  $this->expectExceptionMessage("Position must be 'bottom', 'top', 'left' or 'right'.");
237 
238  $horizontal = $horizontal->withLegendPosition("middle");
239  }
+ Here is the call graph for this function:

◆ testWithLegendInvisible()

ChartBarTest::testWithLegendInvisible ( )

Definition at line 192 of file ChartBarTest.php.

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

192  : void
193  {
194  $f = $this->getFactory();
195 
196  $dataset = $this->getSimpleDataset();
197 
198  $horizontal = $f->horizontal(
199  "Horizontal Bar",
200  $dataset
201  );
202  $horizontal1 = $horizontal->withLegendVisible(false);
203 
204  $this->assertEquals(true, $horizontal->isLegendVisible());
205  $this->assertEquals(false, $horizontal1->isLegendVisible());
206  }
+ Here is the call graph for this function:

◆ testWithLegendPosition()

ChartBarTest::testWithLegendPosition ( )

Definition at line 208 of file ChartBarTest.php.

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

208  : void
209  {
210  $f = $this->getFactory();
211 
212  $dataset = $this->getSimpleDataset();
213 
214  $horizontal = $f->horizontal(
215  "Horizontal Bar",
216  $dataset
217  );
218  $horizontal1 = $horizontal->withLegendPosition("left");
219 
220  $this->assertEquals("top", $horizontal->getLegendPosition());
221  $this->assertEquals("left", $horizontal1->getLegendPosition());
222  }
+ Here is the call graph for this function:

◆ testWithTitle()

ChartBarTest::testWithTitle ( )

Definition at line 144 of file ChartBarTest.php.

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

144  : void
145  {
146  $f = $this->getFactory();
147 
148  $dataset = $this->getSimpleDataset();
149 
150  $horizontal = $f->horizontal(
151  "Horizontal Bar",
152  $dataset
153  );
154  $horizontal1 = $horizontal->withTitle("Alternative title for Horizontal Bar");
155 
156  $this->assertEquals("Horizontal Bar", $horizontal->getTitle());
157  $this->assertEquals("Alternative title for Horizontal Bar", $horizontal1->getTitle());
158  }
+ Here is the call graph for this function:

◆ testWithTitleInvisible()

ChartBarTest::testWithTitleInvisible ( )

Definition at line 160 of file ChartBarTest.php.

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

160  : void
161  {
162  $f = $this->getFactory();
163 
164  $dataset = $this->getSimpleDataset();
165 
166  $horizontal = $f->horizontal(
167  "Horizontal Bar",
168  $dataset
169  );
170  $horizontal1 = $horizontal->withTitleVisible(false);
171 
172  $this->assertEquals(true, $horizontal->isTitleVisible());
173  $this->assertEquals(false, $horizontal1->isTitleVisible());
174  }
+ Here is the call graph for this function:

◆ testWithTooltipsInvisible()

ChartBarTest::testWithTooltipsInvisible ( )

Definition at line 176 of file ChartBarTest.php.

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

176  : void
177  {
178  $f = $this->getFactory();
179 
180  $dataset = $this->getSimpleDataset();
181 
182  $horizontal = $f->horizontal(
183  "Horizontal Bar",
184  $dataset
185  );
186  $horizontal1 = $horizontal->withTooltipsVisible(false);
187 
188  $this->assertEquals(true, $horizontal->isTooltipsVisible());
189  $this->assertEquals(false, $horizontal1->isTooltipsVisible());
190  }
+ Here is the call graph for this function:

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