Test on Bar Chart implementation.
More...
Test on Bar Chart implementation.
Definition at line 30 of file ChartBarTest.php.
◆ getDataFactory()
ChartBarTest::getDataFactory |
( |
| ) |
|
◆ getExtendedDataset()
ChartBarTest::getExtendedDataset |
( |
| ) |
|
|
protected |
Definition at line 68 of file ChartBarTest.php.
69 {
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().
◆ getFactory()
ChartBarTest::getFactory |
( |
| ) |
|
|
protected |
Definition at line 32 of file ChartBarTest.php.
32 : C\Chart\Bar\Factory
33 {
34 return new I\Component\Chart\Bar\Factory();
35 }
Referenced by testEmptyDataset(), testGetInstances(), testImplementsFactoryInterface(), testIndexAxis(), testRenderHorizontal(), testRenderVertical(), testWithBarConfigs(), testWithDataset(), testWithGroupConfigs(), testWithInvalidLegendPosition(), testWithLegendInvisible(), testWithLegendPosition(), testWithTitle(), testWithTitleInvisible(), and testWithTooltipsInvisible().
◆ getSimpleDataset()
ChartBarTest::getSimpleDataset |
( |
| ) |
|
|
protected |
Definition at line 56 of file ChartBarTest.php.
57 {
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().
◆ getUIFactory()
ChartBarTest::getUIFactory |
( |
| ) |
|
◆ testEmptyDataset()
ChartBarTest::testEmptyDataset |
( |
| ) |
|
Definition at line 111 of file ChartBarTest.php.
111 : void
112 {
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().
◆ testGetInstances()
ChartBarTest::testGetInstances |
( |
| ) |
|
Definition at line 89 of file ChartBarTest.php.
89 : void
90 {
92
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().
◆ testImplementsFactoryInterface()
ChartBarTest::testImplementsFactoryInterface |
( |
| ) |
|
◆ testIndexAxis()
ChartBarTest::testIndexAxis |
( |
| ) |
|
Definition at line 310 of file ChartBarTest.php.
310 : void
311 {
314
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().
◆ testRenderHorizontal()
ChartBarTest::testRenderHorizontal |
( |
| ) |
|
Definition at line 332 of file ChartBarTest.php.
332 : void
333 {
334 $r = $this->getDefaultRenderer();
336
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().
◆ testRenderVertical()
ChartBarTest::testRenderVertical |
( |
| ) |
|
Definition at line 365 of file ChartBarTest.php.
365 : void
366 {
367 $r = $this->getDefaultRenderer();
369
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().
◆ testWithBarConfigs()
ChartBarTest::testWithBarConfigs |
( |
| ) |
|
Definition at line 262 of file ChartBarTest.php.
262 : void
263 {
266
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().
◆ testWithDataset()
ChartBarTest::testWithDataset |
( |
| ) |
|
◆ testWithGroupConfigs()
ChartBarTest::testWithGroupConfigs |
( |
| ) |
|
Definition at line 286 of file ChartBarTest.php.
286 : void
287 {
290
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().
◆ testWithInvalidLegendPosition()
ChartBarTest::testWithInvalidLegendPosition |
( |
| ) |
|
Definition at line 228 of file ChartBarTest.php.
228 : void
229 {
231
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().
◆ testWithLegendInvisible()
ChartBarTest::testWithLegendInvisible |
( |
| ) |
|
Definition at line 196 of file ChartBarTest.php.
196 : void
197 {
199
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().
◆ testWithLegendPosition()
ChartBarTest::testWithLegendPosition |
( |
| ) |
|
Definition at line 212 of file ChartBarTest.php.
212 : void
213 {
215
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().
◆ testWithTitle()
ChartBarTest::testWithTitle |
( |
| ) |
|
Definition at line 148 of file ChartBarTest.php.
148 : void
149 {
151
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().
◆ testWithTitleInvisible()
ChartBarTest::testWithTitleInvisible |
( |
| ) |
|
Definition at line 164 of file ChartBarTest.php.
164 : void
165 {
167
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().
◆ testWithTooltipsInvisible()
ChartBarTest::testWithTooltipsInvisible |
( |
| ) |
|
Definition at line 180 of file ChartBarTest.php.
180 : void
181 {
183
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().
The documentation for this class was generated from the following file: