ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ItemGroupTest.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 
5 require_once(__DIR__ . "/../../../../libs/composer/vendor/autoload.php");
6 require_once(__DIR__ . "/../../Base.php");
7 
8 use \ILIAS\UI\Component as C;
9 
14 {
15 
19  public function getFactory()
20  {
21  return new \ILIAS\UI\Implementation\Factory();
22  }
23 
25  {
26  $f = $this->getFactory();
27 
28  $group = $f->item()->group("group", array(
29  $f->item()->standard("title1"),
30  $f->item()->standard("title2")
31  ));
32 
33  $this->assertInstanceOf("ILIAS\\UI\\Component\\Item\\Group", $group);
34  }
35 
36  public function test_get_title()
37  {
38  $f = $this->getFactory();
39  $c = $f->item()->group("group", array(
40  $f->item()->standard("title1"),
41  $f->item()->standard("title2")
42  ));
43 
44  $this->assertEquals($c->getTitle(), "group");
45  }
46 
47  public function test_get_items()
48  {
49  $f = $this->getFactory();
50 
51  $items = array(
52  $f->item()->standard("title1"),
53  $f->item()->standard("title2")
54  );
55 
56  $c = $f->item()->group("group", $items);
57 
58  $this->assertEquals($c->getItems(), $items);
59  }
60 
61  public function test_with_actions()
62  {
63  $f = $this->getFactory();
64 
65  $actions = $f->dropdown()->standard(array(
66  $f->button()->shy("ILIAS", "https://www.ilias.de"),
67  $f->button()->shy("GitHub", "https://www.github.com")
68  ));
69  $items = array(
70  $f->item()->standard("title1"),
71  $f->item()->standard("title2")
72  );
73 
74  $c = $f->item()->group("group", $items)->withActions($actions);
75 
76  $this->assertEquals($c->getActions(), $actions);
77  }
78 
79  public function test_render_base()
80  {
81  $f = $this->getFactory();
82  $r = $this->getDefaultRenderer();
83 
84  $items = array(
85  $f->item()->standard("title1"),
86  $f->item()->standard("title2")
87  );
88 
89  $c = $f->item()->group("group", $items);
90 
91  $html = $r->render($c);
92 
93  $expected = <<<EOT
94 <div class="il-item-group">
95  <h4>group</h4>
96  <div class="il-item-group-items">
97  <div class="il-panel-listing-std-item-container"><div class="il-item il-std-item ">
98  <h5>title1</h5>
99  </div></div><div class="il-panel-listing-std-item-container"><div class="il-item il-std-item ">
100  <h5>title2</h5>
101  </div></div>
102  </div>
103 </div>
104 EOT;
105  $this->assertHTMLEquals($expected, $html);
106  }
107 
108  public function test_render_with_actions()
109  {
110  $f = $this->getFactory();
111  $r = $this->getDefaultRenderer();
112 
113  $actions = $f->dropdown()->standard(array(
114  $f->button()->shy("ILIAS", "https://www.ilias.de"),
115  $f->button()->shy("GitHub", "https://www.github.com")
116  ));
117  $items = array(
118  $f->item()->standard("title1"),
119  $f->item()->standard("title2")
120  );
121 
122  $c = $f->item()->group("group", $items)->withActions($actions);
123 
124  $html = $r->render($c);
125 
126  $expected = <<<EOT
127 <div class="il-item-group">
128 <h4>group</h4><div class="dropdown"><button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <span class="caret"></span></button>
129  <ul class="dropdown-menu">
130  <li><a class="btn btn-link" href="https://www.ilias.de" data-action="https://www.ilias.de">ILIAS</a></li>
131  <li><a class="btn btn-link" href="https://www.github.com" data-action="https://www.github.com">GitHub</a></li>
132  </ul>
133  </div>
134  <div class="il-item-group-items">
135  <div class="il-panel-listing-std-item-container"><div class="il-item il-std-item ">
136  <h5>title1</h5>
137  </div></div><div class="il-panel-listing-std-item-container"><div class="il-item il-std-item ">
138  <h5>title2</h5>
139  </div></div>
140  </div>
141 </div>
142 EOT;
143  $this->assertHTMLEquals($expected, $html);
144  }
145 }
Add some data
Test items groups.
Class BaseForm.
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:216
$r
Definition: example_031.php:79
Provides common functionality for UI tests.
Definition: Base.php:177
test_implements_factory_interface()
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:252
Create styles array
The data for the language used.
$html
Definition: example_001.php:87