ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ChartScaleBarTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
21 require_once(__DIR__ . "/../../../../libs/composer/vendor/autoload.php");
22 require_once(__DIR__ . "/../../Base.php");
23 
24 use ILIAS\UI\Component as C;
26 
31 {
32  protected function getFactory(): C\Chart\Factory
33  {
34  return new I\Component\Chart\Factory(
35  $this->createMock(C\Chart\ProgressMeter\Factory::class),
36  $this->createMock(C\Chart\Bar\Factory::class)
37  );
38  }
39 
40  public function test_implements_factory_interface(): void
41  {
42  $f = $this->getFactory();
43 
44  $this->assertInstanceOf("ILIAS\\UI\\Component\\Chart\\ScaleBar", $f->scaleBar(array("1" => false)));
45  }
46 
47  public function test_get_items(): void
48  {
49  $f = $this->getFactory();
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  $this->assertEquals($c->getItems(), $items);
61  }
62 
63  public function test_render(): void
64  {
65  $f = $this->getFactory();
66  $r = $this->getDefaultRenderer();
67 
68  $items = array(
69  "None" => false,
70  "Low" => false,
71  "Medium" => true,
72  "High" => false
73  );
74 
75  $c = $f->scaleBar($items);
76 
77  $html = $r->render($c);
78 
79  $expected_html = <<<EOT
80 <ul class="il-chart-scale-bar">
81  <li style="width:25%">
82  <div class="il-chart-scale-bar-item ">
83  None
84  </div>
85  </li>
86  <li style="width:25%">
87  <div class="il-chart-scale-bar-item ">
88  Low
89  </div>
90  </li>
91  <li style="width:25%">
92  <div class="il-chart-scale-bar-item il-chart-scale-bar-active">
93  Medium <span class="sr-only">(active)</span>
94  </div>
95  </li>
96  <li style="width:25%">
97  <div class="il-chart-scale-bar-item ">
98  High
99  </div>
100  </li>
101 </ul>
102 EOT;
103 
104  $this->assertHTMLEquals($expected_html, $html);
105  }
106 }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
$c
Definition: cli.php:38
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...
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
Provides common functionality for UI tests.
Definition: Base.php:298
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...