ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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="il-panel-listing-std-container clearfix">
100 <h3>title</h3>
101 <div class="il-item-group">
102 <h4>Subtitle 1</h4>
103 <div class="il-item-group-items">
104 <div class="il-panel-listing-std-item-container"><div class="il-item il-std-item ">
105 <h5>title1</h5>
106 </div></div><div class="il-panel-listing-std-item-container"><div class="il-item il-std-item ">
107 <h5>title2</h5>
108 </div></div>
109 </div>
110 </div><div class="il-item-group">
111 <h4>Subtitle 2</h4>
112 <div class="il-item-group-items">
113 <div class="il-panel-listing-std-item-container"><div class="il-item il-std-item ">
114 <h5>title3</h5>
115 </div></div>
116 </div>
117</div>
118</div>
119EOT;
120 $this->assertHTMLEquals($expected, $html);
121 }
122
123 public function test_render_with_actions()
124 {
125 $f = $this->getFactory();
126 $r = $this->getDefaultRenderer();
127
128 $groups = array();
129
130 $actions = new I\Component\Dropdown\Standard(array(
131 new I\Component\Button\Shy("ILIAS", "https://www.ilias.de"),
132 new I\Component\Button\Shy("GitHub", "https://www.github.com")
133 ));
134
135 $c = $f->standard("title", $groups)
136 ->withActions($actions);
137
138 $html = $r->render($c);
139
140 $expected = <<<EOT
141<div class="il-panel-listing-std-container clearfix">
142<h3>title</h3><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>
143<ul class="dropdown-menu">
144 <li><button class="btn btn-link" data-action="https://www.ilias.de" id="id_1">ILIAS</button></li>
145 <li><button class="btn btn-link" data-action="https://www.github.com" id="id_2">GitHub</button></li>
146</ul>
147</div>
148</div>
149EOT;
150 $this->assertHTMLEquals($expected, $html);
151 }
152}
An exception for terminatinating execution or to throw for unit testing.
Provides common functionality for UI tests.
Definition: Base.php:192
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
Test listing panels.
$html
Definition: example_001.php:87
$r
Definition: example_031.php:79
Class BaseForm.
$this data['403_header']