ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
PanelListingTest.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;
9
14{
15
19 public function getFactory()
20 {
21 return new \ILIAS\UI\Implementation\Factory();
22 }
23
25 {
26 $f = $this->getFactory();
27
28 $std_list = $f->panel()->listing()->standard("List Title", array(
29 $f->item()->group("Subtitle 1", array(
30 $f->item()->standard("title1"),
31 $f->item()->standard("title2")
32 )),
33 $f->item()->group("Subtitle 2", array(
34 $f->item()->standard("title3")
35 ))
36 ));
37
38 $this->assertInstanceOf("ILIAS\\UI\\Component\\Panel\\Listing\\Standard", $std_list);
39 }
40
41 public function test_get_title_get_groups()
42 {
43 $f = $this->getFactory();
44
45 $groups = array(
46 $f->item()->group("Subtitle 1", array(
47 $f->item()->standard("title1"),
48 $f->item()->standard("title2")
49 )),
50 $f->item()->group("Subtitle 2", array(
51 $f->item()->standard("title3")
52 ))
53 );
54
55 $c = $f->panel()->listing()->standard("title", $groups);
56
57 $this->assertEquals($c->getTitle(), "title");
58 $this->assertEquals($c->getItemGroups(), $groups);
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
70 $groups = array();
71
72 $c = $f->panel()->listing()->standard("title", $groups)
73 ->withActions($actions);
74
75 $this->assertEquals($c->getActions(), $actions);
76 }
77
78 public function test_render_base()
79 {
80 $f = $this->getFactory();
81 $r = $this->getDefaultRenderer();
82
83 $groups = array(
84 $f->item()->group("Subtitle 1", array(
85 $f->item()->standard("title1"),
86 $f->item()->standard("title2")
87 )),
88 $f->item()->group("Subtitle 2", array(
89 $f->item()->standard("title3")
90 ))
91 );
92
93 $c = $f->panel()->listing()->standard("title", $groups);
94
95 $html = $r->render($c);
96
97 $expected = <<<EOT
98<div class="il-panel-listing-std-container clearfix">
99 <h3>title</h3>
100 <div class="il-item-group">
101 <h4>Subtitle 1</h4>
102 <div class="il-item-group-items">
103 <div class="il-panel-listing-std-item-container"><div class="il-item il-std-item ">
104 <h5>title1</h5>
105 </div></div><div class="il-panel-listing-std-item-container"><div class="il-item il-std-item ">
106 <h5>title2</h5>
107 </div></div>
108 </div>
109 </div><div class="il-item-group">
110 <h4>Subtitle 2</h4>
111 <div class="il-item-group-items">
112 <div class="il-panel-listing-std-item-container"><div class="il-item il-std-item ">
113 <h5>title3</h5>
114 </div></div>
115 </div>
116</div>
117</div>
118EOT;
119 $this->assertHTMLEquals($expected, $html);
120 }
121
122 public function test_render_with_actions()
123 {
124 $f = $this->getFactory();
125 $r = $this->getDefaultRenderer();
126
127 $groups = array();
128
129 $actions = $f->dropdown()->standard(array(
130 $f->button()->shy("ILIAS", "https://www.ilias.de"),
131 $f->button()->shy("GitHub", "https://www.github.com")
132 ));
133
134 $c = $f->panel()->listing()->standard("title", $groups)
135 ->withActions($actions);
136
137 $html = $r->render($c);
138
139 $expected = <<<EOT
140<div class="il-panel-listing-std-container clearfix">
141<h3>title</h3><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>
142<ul class="dropdown-menu">
143 <li><a class="btn btn-link" href="https://www.ilias.de" data-action="https://www.ilias.de">ILIAS</a></li>
144 <li><a class="btn btn-link" href="https://www.github.com" data-action="https://www.github.com">GitHub</a></li>
145</ul>
146</div>
147</div>
148EOT;
149 $this->assertHTMLEquals($expected, $html);
150 }
151}
An exception for terminatinating execution or to throw for unit testing.
Provides common functionality for UI tests.
Definition: Base.php:178
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:252
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:216
Test listing panels.
$html
Definition: example_001.php:87
$r
Definition: example_031.php:79
Class BaseForm.
$this data['403_header']