ILIAS  release_7 Revision v7.30-3-g800a261c036
ItemTest Class Reference

Test items. More...

+ Inheritance diagram for ItemTest:
+ Collaboration diagram for ItemTest:

Public Member Functions

 getFactory ()
 
 test_implements_factory_interface ()
 
 test_get_title ()
 
 test_with_description ()
 
 test_with_properties ()
 
 test_with_actions ()
 
 test_with_color ()
 
 test_with_lead_image ()
 
 test_with_lead_icon ()
 
 test_with_lead_text ()
 
 test_with_no_lead ()
 
 test_render_base ()
 
 test_render_lead_image ()
 
 test_render_lead_icon ()
 
 test_render_lead_text_and_color ()
 
 test_shy_title_and_property ()
 
 test_link_title ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 

Detailed Description

Test items.

Definition at line 14 of file ItemTest.php.

Member Function Documentation

◆ getFactory()

◆ test_get_title()

ItemTest::test_get_title ( )

Definition at line 32 of file ItemTest.php.

33 {
34 $f = $this->getFactory();
35 $c = $f->standard("title");
36
37 $this->assertEquals($c->getTitle(), "title");
38 }
getFactory()
Definition: ItemTest.php:20
$c
Definition: cli.php:37

References $c, Vendor\Package\$f, and getFactory().

+ Here is the call graph for this function:

◆ test_implements_factory_interface()

ItemTest::test_implements_factory_interface ( )

Definition at line 25 of file ItemTest.php.

26 {
27 $f = $this->getFactory();
28
29 $this->assertInstanceOf("ILIAS\\UI\\Component\\Item\\Standard", $f->standard("title"));
30 }

References Vendor\Package\$f, and getFactory().

+ Here is the call graph for this function:

◆ test_link_title()

ItemTest::test_link_title ( )

Definition at line 301 of file ItemTest.php.

302 {
303 $f = $this->getFactory();
304 $r = $this->getDefaultRenderer();
305
306 $c = $f->standard(new I\Component\Link\Standard("ILIAS", "https://www.ilias.de"));
307 $html = $r->render($c);
308
309 $expected = <<<EOT
310<div class="il-item il-std-item "><div class="il-item-title"><a href="https://www.ilias.de">ILIAS</a></div></div>
311EOT;
312
313 $this->assertHTMLEquals($expected, $html);
314 }
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:372
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
Class ChatMainBarProvider \MainMenu\Provider.

References $c, Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\getDefaultRenderer(), and getFactory().

+ Here is the call graph for this function:

◆ test_render_base()

ItemTest::test_render_base ( )

Definition at line 124 of file ItemTest.php.

125 {
126 $f = $this->getFactory();
127 $r = $this->getDefaultRenderer();
128
129 $actions = new I\Component\Dropdown\Standard(array(
130 new I\Component\Button\Shy("ILIAS", "https://www.ilias.de"),
131 new I\Component\Button\Shy("GitHub", "https://www.github.com")
132 ));
133 $c = $f->standard("Item Title")
134 ->withActions($actions)
135 ->withProperties(array(
136 "Origin" => "Course Title 1",
137 "Last Update" => "24.11.2011",
138 "Location" => "Room 123, Main Street 44, 3012 Bern"))
139 ->withDescription("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.");
140
141 $html = $r->render($c);
142
143 $expected = <<<EOT
144<div class="il-item il-std-item ">
145 <div class="il-item-title">Item Title</div>
146 <div class="dropdown"><button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-label="actions" aria-haspopup="true" aria-expanded="false" > <span class="caret"></span></button>
147<ul class="dropdown-menu">
148 <li><button class="btn btn-link" data-action="https://www.ilias.de" id="id_1" >ILIAS</button>
149</li>
150 <li><button class="btn btn-link" data-action="https://www.github.com" id="id_2" >GitHub</button>
151</li>
152</ul>
153</div>
154 <div class="il-item-description">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</div>
155 <hr class="il-item-divider" />
156 <div class="row">
157 <div class="col-md-6 il-multi-line-cap-3">
158 <span class="il-item-property-name">Origin</span><span class="il-item-property-value">Course Title 1</span>
159 </div>
160 <div class="col-md-6 il-multi-line-cap-3">
161 <span class="il-item-property-name">Last Update</span><span class="il-item-property-value">24.11.2011</span>
162 </div>
163 </div>
164 <div class="row">
165 <div class="col-md-6 il-multi-line-cap-3">
166 <span class="il-item-property-name">Location</span><span class="il-item-property-value">Room 123, Main Street 44, 3012 Bern</span>
167 </div>
168 <div class="col-md-6 il-multi-line-cap-3">
169 <span class="il-item-property-name"></span><span class="il-item-property-value"></span>
170 </div>
171 </div>
172</div>
173EOT;
174
175 $this->assertHTMLEquals(
176 $this->brutallyTrimHTML($expected),
177 $this->brutallyTrimHTML($html)
178 );
179 }
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
Title class.
Definition: Title.php:37

References $c, Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\brutallyTrimHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), and getFactory().

+ Here is the call graph for this function:

◆ test_render_lead_icon()

ItemTest::test_render_lead_icon ( )

Definition at line 210 of file ItemTest.php.

211 {
212 $f = $this->getFactory();
213 $r = $this->getDefaultRenderer();
214
215 $icon = new I\Component\Symbol\Icon\Standard("name", "aria_label", "small", false);
216
217 $c = $f->standard("title")->withLeadIcon($icon);
218
219 $html = $r->render($c);
220 $expected = <<<EOT
221<div class="il-item il-std-item ">
222 <div class="media">
223 <div class="media-left">
224 <img class="icon name small" src="./templates/default/images/icon_default.svg" alt="aria_label" />
225 </div>
226 <div class="media-body">
227 <div class="il-item-title">title</div>
228 </div>
229 </div>
230</div>
231EOT;
232
233 $this->assertHTMLEquals(
234 $this->brutallyTrimHTML($expected),
235 $this->brutallyTrimHTML($html)
236 );
237 }

References $c, Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\brutallyTrimHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), and getFactory().

+ Here is the call graph for this function:

◆ test_render_lead_image()

ItemTest::test_render_lead_image ( )

Definition at line 181 of file ItemTest.php.

182 {
183 $f = $this->getFactory();
184 $r = $this->getDefaultRenderer();
185
186 $image = new I\Component\Image\Image("standard", "src", "str");
187
188 $c = $f->standard("title")->withLeadImage($image);
189
190 $html = $r->render($c);
191 $expected = <<<EOT
192<div class="il-item il-std-item ">
193 <div class="row">
194 <div class="col-xs-2 col-sm-3">
195 <img src="src" class="img-standard" alt="str" />
196 </div>
197 <div class="col-xs-10 col-sm-9">
198 <div class="il-item-title">title</div>
199 </div>
200 </div>
201</div>
202EOT;
203
204 $this->assertHTMLEquals(
205 $this->brutallyTrimHTML($expected),
206 $this->brutallyTrimHTML($html)
207 );
208 }

References $c, Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\brutallyTrimHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), and getFactory().

+ Here is the call graph for this function:

◆ test_render_lead_text_and_color()

ItemTest::test_render_lead_text_and_color ( )

Definition at line 239 of file ItemTest.php.

240 {
241 $f = $this->getFactory();
242 $r = $this->getDefaultRenderer();
243 $df = new \ILIAS\Data\Factory();
244
245 $color = $df->color('#ff00ff');
246
247 $c = $f->standard("title")->withColor($color)->withLeadText("lead");
248
249 $html = $r->render($c);
250
251 $expected = <<<EOT
252<div class="il-item il-std-item il-item-marker " style="border-color:#ff00ff">
253 <div class="row">
254 <div class="col-sm-3">
255 lead
256 </div>
257 <div class="col-sm-9">
258 <div class="il-item-title">title</div>
259 </div>
260 </div>
261</div>
262EOT;
263
264 $this->assertHTMLEquals(
265 $this->brutallyTrimHTML($expected),
266 $this->brutallyTrimHTML($html)
267 );
268 }

References $c, Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\brutallyTrimHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), and getFactory().

+ Here is the call graph for this function:

◆ test_shy_title_and_property()

ItemTest::test_shy_title_and_property ( )

Definition at line 270 of file ItemTest.php.

271 {
272 $f = $this->getFactory();
273 $r = $this->getDefaultRenderer();
274 $df = new \ILIAS\Data\Factory();
275
276 $color = $df->color('#ff00ff');
277
278 $c = $f->standard(new I\Component\Button\Shy("ILIAS", "https://www.ilias.de"))
279 ->withProperties(array("test" => new I\Component\Button\Shy("GitHub", "https://www.github.com")));
280
281 $html = $r->render($c);
282 $expected = <<<EOT
283<div class="il-item il-std-item ">
284 <div class="il-item-title"><button class="btn btn-link" data-action="https://www.ilias.de" id="id_1" >ILIAS</button></div>
285
286 <hr class="il-item-divider" />
287 <div class="row">
288 <div class="col-md-6 il-multi-line-cap-3">
289 <span class="il-item-property-name">test</span><span class="il-item-property-value"><button class="btn btn-link" data-action="https://www.github.com" id="id_2" >GitHub</button></span>
290 </div>
291 <div class="col-md-6 il-multi-line-cap-3">
292 <span class="il-item-property-name"></span><span class="il-item-property-value"></span>
293 </div>
294 </div>
295</div>
296EOT;
297
298 $this->assertHTMLEquals($expected, $html);
299 }

References $c, Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\getDefaultRenderer(), and getFactory().

+ Here is the call graph for this function:

◆ test_with_actions()

ItemTest::test_with_actions ( )

Definition at line 59 of file ItemTest.php.

60 {
61 $f = $this->getFactory();
62
63 $actions = new I\Component\Dropdown\Standard(array(
64 new I\Component\Button\Shy("ILIAS", "https://www.ilias.de"),
65 new I\Component\Button\Shy("GitHub", "https://www.github.com")
66 ));
67 $c = $f->standard("title")->withActions($actions);
68
69 $this->assertEquals($c->getActions(), $actions);
70 }

References $c, Vendor\Package\$f, and getFactory().

+ Here is the call graph for this function:

◆ test_with_color()

ItemTest::test_with_color ( )

Definition at line 72 of file ItemTest.php.

73 {
74 $f = $this->getFactory();
75 $df = new \ILIAS\Data\Factory();
76
77 $color = $df->color('#ff00ff');
78
79 $c = $f->standard("title")->withColor($color);
80
81 $this->assertEquals($c->getColor(), $color);
82 }

References $c, Vendor\Package\$f, and getFactory().

+ Here is the call graph for this function:

◆ test_with_description()

ItemTest::test_with_description ( )

Definition at line 40 of file ItemTest.php.

41 {
42 $f = $this->getFactory();
43
44 $c = $f->standard("title")->withDescription("description");
45
46 $this->assertEquals($c->getDescription(), "description");
47 }

References $c, Vendor\Package\$f, and getFactory().

+ Here is the call graph for this function:

◆ test_with_lead_icon()

ItemTest::test_with_lead_icon ( )

Definition at line 95 of file ItemTest.php.

96 {
97 $f = $this->getFactory();
98
99 $icon = new I\Component\Symbol\Icon\Standard("name", "aria_label", "small", false);
100
101 $c = $f->standard("title")->withLeadIcon($icon);
102
103 $this->assertEquals($c->getLead(), $icon);
104 }

References $c, Vendor\Package\$f, and getFactory().

+ Here is the call graph for this function:

◆ test_with_lead_image()

ItemTest::test_with_lead_image ( )

Definition at line 84 of file ItemTest.php.

85 {
86 $f = $this->getFactory();
87
88 $image = new I\Component\Image\Image("standard", "src", "str");
89
90 $c = $f->standard("title")->withLeadImage($image);
91
92 $this->assertEquals($c->getLead(), $image);
93 }

References $c, Vendor\Package\$f, and getFactory().

+ Here is the call graph for this function:

◆ test_with_lead_text()

ItemTest::test_with_lead_text ( )

Definition at line 106 of file ItemTest.php.

107 {
108 $f = $this->getFactory();
109
110 $c = $f->standard("title")->withLeadText("text");
111
112 $this->assertEquals($c->getLead(), "text");
113 }

References $c, Vendor\Package\$f, and getFactory().

+ Here is the call graph for this function:

◆ test_with_no_lead()

ItemTest::test_with_no_lead ( )

Definition at line 115 of file ItemTest.php.

116 {
117 $f = $this->getFactory();
118
119 $c = $f->standard("title")->withLeadText("text")->withNoLead();
120
121 $this->assertEquals($c->getLead(), null);
122 }

References $c, Vendor\Package\$f, and getFactory().

+ Here is the call graph for this function:

◆ test_with_properties()

ItemTest::test_with_properties ( )

Definition at line 49 of file ItemTest.php.

50 {
51 $f = $this->getFactory();
52
53 $props = array("prop1" => "val1", "prop2" => "val2");
54 $c = $f->standard("title")->withProperties($props);
55
56 $this->assertEquals($c->getProperties(), $props);
57 }

References $c, Vendor\Package\$f, and getFactory().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: