ILIAS  release_7 Revision v7.30-3-g800a261c036
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;
9use \ILIAS\UI\Implementation as I;
10
15{
16
20 public function getFactory()
21 {
22 return new I\Component\Panel\Listing\Factory();
23 }
24
26 {
27 $f = $this->getFactory();
28
29 $std_list = $f->standard("List Title", array(
30 new I\Component\Item\Group("Subtitle 1", array(
31 new I\Component\Item\Standard("title1"),
32 new I\Component\Item\Standard("title2")
33 )),
34 new I\Component\Item\Group("Subtitle 2", array(
35 new I\Component\Item\Standard("title3")
36 ))
37 ));
38
39 $this->assertInstanceOf("ILIAS\\UI\\Component\\Panel\\Listing\\Standard", $std_list);
40 }
41
42 public function test_get_title_get_groups()
43 {
44 $f = $this->getFactory();
45
46 $groups = array(
47 new I\Component\Item\Group("Subtitle 1", array(
48 new I\Component\Item\Standard("title1"),
49 new I\Component\Item\Standard("title2")
50 )),
51 new I\Component\Item\Group("Subtitle 2", array(
52 new I\Component\Item\Standard("title3")
53 ))
54 );
55
56 $c = $f->standard("title", $groups);
57
58 $this->assertEquals($c->getTitle(), "title");
59 $this->assertEquals($c->getItemGroups(), $groups);
60 }
61
62 public function test_with_actions()
63 {
64 $f = $this->getFactory();
65
66 $actions = new I\Component\Dropdown\Standard(array(
67 new I\Component\Button\Shy("ILIAS", "https://www.ilias.de"),
68 new I\Component\Button\Shy("GitHub", "https://www.github.com")
69 ));
70
71 $groups = array();
72
73 $c = $f->standard("title", $groups)
74 ->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 $groups = array(
85 new I\Component\Item\Group("Subtitle 1", array(
86 new I\Component\Item\Standard("title1"),
87 new I\Component\Item\Standard("title2")
88 )),
89 new I\Component\Item\Group("Subtitle 2", array(
90 new I\Component\Item\Standard("title3")
91 ))
92 );
93
94 $c = $f->standard("title", $groups);
95
96 $html = $r->render($c);
97
98 $expected = <<<EOT
99<div class="panel il-panel-listing-std-container clearfix">
100 <h2>title</h2>
101 <div class="il-item-group">
102 <h3>Subtitle 1</h3>
103 <div class="il-item-group-items">
104 <div class="il-std-item-container"><div class="il-item il-std-item ">
105 <div class="il-item-title">title1</div>
106 </div></div><div class="il-std-item-container"><div class="il-item il-std-item ">
107 <div class="il-item-title">title2</div>
108 </div></div>
109 </div>
110 </div><div class="il-item-group">
111 <h3>Subtitle 2</h3>
112 <div class="il-item-group-items">
113 <div class="il-std-item-container"><div class="il-item il-std-item ">
114 <div class="il-item-title">title3</div>
115 </div></div>
116 </div>
117</div>
118</div>
119EOT;
120 $this->assertHTMLEquals(
121 $this->brutallyTrimHTML($expected),
122 $this->brutallyTrimHTML($html)
123 );
124 }
125
126 public function test_render_with_actions()
127 {
128 $f = $this->getFactory();
129 $r = $this->getDefaultRenderer();
130
131 $groups = array();
132
133 $actions = new I\Component\Dropdown\Standard(array(
134 new I\Component\Button\Shy("ILIAS", "https://www.ilias.de"),
135 new I\Component\Button\Shy("GitHub", "https://www.github.com")
136 ));
137
138 $c = $f->standard("title", $groups)
139 ->withActions($actions);
140
141 $html = $r->render($c);
142
143 $expected = <<<EOT
144<div class="panel il-panel-listing-std-container clearfix">
145<h2>title</h2><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>
146<ul class="dropdown-menu">
147 <li><button class="btn btn-link" data-action="https://www.ilias.de" id="id_1">ILIAS</button></li>
148 <li><button class="btn btn-link" data-action="https://www.github.com" id="id_2">GitHub</button></li>
149</ul>
150</div>
151</div>
152EOT;
153 $this->assertHTMLEquals($expected, $html);
154 }
155}
An exception for terminatinating execution or to throw for unit testing.
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
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
Test listing panels.
$c
Definition: cli.php:37
Class ChatMainBarProvider \MainMenu\Provider.