ILIAS  release_8 Revision v8.23
ChartBarTest Class Reference

Test on Bar Chart implementation. More...

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

Public Member Functions

 getDataFactory ()
 
 getUIFactory ()
 
 test_implements_factory_interface ()
 
 test_get_instances ()
 
 test_empty_dataset ()
 
 test_with_title ()
 
 test_with_title_invisible ()
 
 test_with_tooltips_invisible ()
 
 test_with_legend_invisible ()
 
 test_with_legend_position ()
 
 test_with_invalid_legend_position ()
 
 test_with_dataset ()
 
 test_with_bar_configs ()
 
 test_index_axis ()
 
 test_render_horizontal ()
 
 test_render_vertical ()
 
- 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)
 

Protected Member Functions

 getFactory ()
 
 getSimpleDataset ()
 
 getExtendedDataset ()
 
- 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

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(), test_empty_dataset(), test_index_axis(), and test_with_bar_configs().

38  {
39  return new ILIAS\Data\Factory();
40  }
+ Here is the caller graph for this function:

◆ getExtendedDataset()

ChartBarTest::getExtendedDataset ( )
protected

Definition at line 64 of file ChartBarTest.php.

References getDataFactory().

Referenced by test_render_vertical(), and test_with_dataset().

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 test_get_instances(), test_index_axis(), test_render_horizontal(), test_with_bar_configs(), test_with_dataset(), test_with_invalid_legend_position(), test_with_legend_invisible(), test_with_legend_position(), test_with_title(), test_with_title_invisible(), and test_with_tooltips_invisible().

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.

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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ test_empty_dataset()

ChartBarTest::test_empty_dataset ( )

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:

◆ test_get_instances()

ChartBarTest::test_get_instances ( )

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:

◆ test_implements_factory_interface()

ChartBarTest::test_implements_factory_interface ( )

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:

◆ test_index_axis()

ChartBarTest::test_index_axis ( )

Definition at line 281 of file ChartBarTest.php.

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

281  : void
282  {
283  $f = $this->getFactory();
284  $df = $this->getDataFactory();
285 
286  $dataset = $this->getSimpleDataset();
287 
288  $horizontal = $f->horizontal(
289  "Horizontal Bar",
290  $dataset
291  );
292 
293  $this->assertEquals("y", $horizontal->getIndexAxis());
294 
295  $vertical = $f->vertical(
296  "Vertical Bar",
297  $dataset
298  );
299 
300  $this->assertEquals("x", $vertical->getIndexAxis());
301  }
+ Here is the call graph for this function:

◆ test_render_horizontal()

ChartBarTest::test_render_horizontal ( )

Definition at line 303 of file ChartBarTest.php.

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

303  : void
304  {
305  $r = $this->getDefaultRenderer();
306  $f = $this->getFactory();
307 
308  $dataset = $this->getSimpleDataset();
309 
310  $horizontal = $f->horizontal(
311  "bar123",
312  $dataset
313  );
314 
315  $html = $r->render($horizontal);
316 
317  $expected_html = <<<EOT
318 <div class="il-chart-bar-horizontal">
319  <canvas id="id_1" height="150px" aria-label="bar123" role="img"></canvas>
320 </div>
321 <div class="sr-only">
322  <dl>
323  <dt>Dataset</dt>
324  <dd>
325  <ul>
326  <li>Item: 0</li>
327  </ul>
328  </dd>
329  </dl>
330 </div>
331 EOT;
332 
333  $this->assertHTMLEquals("<div>" . $expected_html . "</div>", "<div>" . $html . "</div>");
334  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
+ Here is the call graph for this function:

◆ test_render_vertical()

ChartBarTest::test_render_vertical ( )

Definition at line 336 of file ChartBarTest.php.

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

336  : void
337  {
338  $r = $this->getDefaultRenderer();
339  $f = $this->getFactory();
340 
341  $dataset = $this->getExtendedDataset();
342 
343  $vertical = $f->vertical(
344  "bar123",
345  $dataset
346  );
347 
348  $html = $r->render($vertical);
349 
350  $expected_html = <<<EOT
351 <div class="il-chart-bar-vertical">
352  <canvas id="id_1" height="165px" aria-label="bar123" role="img"></canvas>
353 </div>
354 <div class="sr-only">
355  <dl>
356  <dt>Dataset 1</dt>
357  <dd>
358  <ul>
359  <li>Item 1: -1.25</li>
360  <li>Item 2: -</li>
361  </ul>
362  </dd>
363  <dt>Dataset 2</dt>
364  <dd>
365  <ul>
366  <li>Item 1: -2 - -1</li>
367  <li>Item 2: 0 - 0.5</li>
368  </ul>
369  </dd>
370  </dl>
371 </div>
372 EOT;
373 
374  $this->assertHTMLEquals("<div>" . $expected_html . "</div>", "<div>" . $html . "</div>");
375  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
+ Here is the call graph for this function:

◆ test_with_bar_configs()

ChartBarTest::test_with_bar_configs ( )

Definition at line 257 of file ChartBarTest.php.

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

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

◆ test_with_dataset()

ChartBarTest::test_with_dataset ( )

Definition at line 240 of file ChartBarTest.php.

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

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

◆ test_with_invalid_legend_position()

ChartBarTest::test_with_invalid_legend_position ( )

Definition at line 223 of file ChartBarTest.php.

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

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

◆ test_with_legend_invisible()

ChartBarTest::test_with_legend_invisible ( )

Definition at line 191 of file ChartBarTest.php.

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

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

◆ test_with_legend_position()

ChartBarTest::test_with_legend_position ( )

Definition at line 207 of file ChartBarTest.php.

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

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

◆ test_with_title()

ChartBarTest::test_with_title ( )

Definition at line 143 of file ChartBarTest.php.

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

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

◆ test_with_title_invisible()

ChartBarTest::test_with_title_invisible ( )

Definition at line 159 of file ChartBarTest.php.

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

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

◆ test_with_tooltips_invisible()

ChartBarTest::test_with_tooltips_invisible ( )

Definition at line 175 of file ChartBarTest.php.

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

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

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