ILIAS  release_7 Revision v7.30-3-g800a261c036
ChartScaleBarTest.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2017 Alex Killing <killing@leifos.de> Extended GPL, see docs/LICENSE */
4
5require_once(__DIR__ . "/../../../../libs/composer/vendor/autoload.php");
6require_once(__DIR__ . "/../../Base.php");
7
8use \ILIAS\UI\Component as C;
9use \ILIAS\UI\Implementation as I;
10
15{
16 protected function getFactory()
17 {
18 return new I\Component\Chart\Factory(
19 $this->createMock(C\Chart\ProgressMeter\Factory::class)
20 );
21 }
22
24 {
25 $f = $this->getFactory();
26
27 $this->assertInstanceOf("ILIAS\\UI\\Component\\Chart\\ScaleBar", $f->scaleBar(array("1" => false)));
28 }
29
30 public function test_get_items()
31 {
32 $f = $this->getFactory();
33
34 $items = array(
35 "None" => false,
36 "Low" => false,
37 "Medium" => true,
38 "High" => false
39 );
40
41 $c = $f->scaleBar($items);
42
43 $this->assertEquals($c->getItems(), $items);
44 }
45
46 public function test_render()
47 {
48 $f = $this->getFactory();
49 $r = $this->getDefaultRenderer();
50
51 $items = array(
52 "None" => false,
53 "Low" => false,
54 "Medium" => true,
55 "High" => false
56 );
57
58 $c = $f->scaleBar($items);
59
60 $html = $r->render($c);
61
62 $expected_html = <<<EOT
63<ul class="il-chart-scale-bar">
64 <li style="width:25%">
65 <div class="il-chart-scale-bar-item ">
66 None
67 </div>
68 </li>
69 <li style="width:25%">
70 <div class="il-chart-scale-bar-item ">
71 Low
72 </div>
73 </li>
74 <li style="width:25%">
75 <div class="il-chart-scale-bar-item il-chart-scale-bar-active">
76 Medium <span class="sr-only">(active)</span>
77 </div>
78 </li>
79 <li style="width:25%">
80 <div class="il-chart-scale-bar-item ">
81 High
82 </div>
83 </li>
84</ul>
85EOT;
86
87 $this->assertHTMLEquals($expected_html, $html);
88 }
89}
An exception for terminatinating execution or to throw for unit testing.
Test scale bar charts.
Provides common functionality for UI tests.
Definition: Base.php:263
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:372
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
$c
Definition: cli.php:37