ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
DrilldownTest Class Reference

Tests for the Drilldown. More...

+ Inheritance diagram for DrilldownTest:
+ Collaboration diagram for DrilldownTest:

Public Member Functions

 getUIFactory ()
 
 setUp ()
 
 testConstruction ()
 
 testGetLabel ($menu)
 @depends testConstruction More...
 
 testWithLabel ($menu)
 @depends testConstruction More...
 
 testWithClickableLabel ($menu)
 @depends testConstruction More...
 
 testGetItems ($menu)
 @depends testConstruction More...
 
 testWithEntries ()
 
 testWithWrongLabel ()
 
 testWithWrongEntry ()
 
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 
 testRendering ($menu)
 @depends testWithEntries More...
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Additional Inherited Members

 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 

Detailed Description

Tests for the Drilldown.

Definition at line 15 of file DrilldownTest.php.

Member Function Documentation

◆ brutallyTrimHTML()

DrilldownTest::brutallyTrimHTML (   $html)

A more radical version of normalizeHTML.

Use if hard to tackle issues occur by asserting due string outputs produce an equal DOM

Parameters
$html
Returns
string

Reimplemented from ILIAS_UI_TestBase.

Definition at line 147 of file DrilldownTest.php.

148 {
149 $html = str_replace(["\n", "\t"], "", $html);
150 $html = preg_replace('# {2,}#', " ", $html);
151 return trim($html);
152 }

Referenced by testRendering().

+ Here is the caller graph for this function:

◆ getUIFactory()

DrilldownTest::getUIFactory ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 17 of file DrilldownTest.php.

18 {
19 $factory = new class extends NoUIFactory {
20 public function menu() : C\Menu\Factory
21 {
22 return new Menu\Factory();
23 }
24 public function button()
25 {
26 return new I\Button\Factory();
27 }
28 public function legacy($content)
29 {
30 return new I\Legacy\Legacy($content, new I\SignalGenerator());
31 }
32 };
33 return $factory;
34 }
This describes a Menu Control.
Definition: Menu.php:14
legacy()
Definition: legacy.php:3
$factory
Definition: metadata.php:58

References $factory, and legacy().

Referenced by setUp(), testConstruction(), testWithEntries(), testWithWrongEntry(), and testWithWrongLabel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setUp()

DrilldownTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 36 of file DrilldownTest.php.

36 : void
37 {
38 $icon_factory = new I\Symbol\Icon\Factory();
39 $glyph_factory = new I\Symbol\Glyph\Factory();
40 $button_factory = new I\Button\Factory();
41 $divider_factory = new I\Divider\Factory();
42 $this->icon = $icon_factory->standard('', '');
43 $this->glyph = $glyph_factory->user('');
44 $this->button = $button_factory->standard('', '');
45 $this->divider = $divider_factory->horizontal();
46 $this->legacy = $this->getUIFactory()->legacy('');
47 }

References getUIFactory(), and legacy().

+ Here is the call graph for this function:

◆ testConstruction()

DrilldownTest::testConstruction ( )

Definition at line 49 of file DrilldownTest.php.

50 {
51 $f = $this->getUIFactory();
52 $menu = $f->menu()->drilldown('root', []);
53 $this->assertInstanceOf(
54 "ILIAS\\UI\\Component\\Menu\\Menu",
55 $menu
56 );
57 $this->assertInstanceOf(
58 "ILIAS\\UI\\Component\\Menu\\LabeledMenu",
59 $menu
60 );
61 $this->assertInstanceOf(
62 "ILIAS\\UI\\Component\\Menu\\Drilldown",
63 $menu
64 );
65
66 return $menu;
67 }

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

+ Here is the call graph for this function:

◆ testGetItems()

DrilldownTest::testGetItems (   $menu)

@depends testConstruction

Definition at line 105 of file DrilldownTest.php.

106 {
107 $this->assertEquals(
108 [],
109 $menu->getItems()
110 );
111 }

◆ testGetLabel()

DrilldownTest::testGetLabel (   $menu)

@depends testConstruction

Definition at line 72 of file DrilldownTest.php.

73 {
74 $this->assertEquals(
75 'root',
76 $menu->getLabel()
77 );
78 }

◆ testRendering()

DrilldownTest::testRendering (   $menu)

@depends testWithEntries

Definition at line 157 of file DrilldownTest.php.

158 {
159 $r = $this->getDefaultRenderer();
160 $html = $r->render($menu);
161 $expected = <<<EOT
162 <div class="il-drilldown" id="id_3">
163 <ul class="il-drilldown-structure">
164 <li class="il-menu-item" id="id_1">
165 <span class="il-menu-item-label">
166 <button class="btn btn-link" data-action="">root</button>
167 </span>
168
169 <ul class="il-menu-level">
170 <li class="il-menu-item" id="id_2">
171 <span class="il-menu-item-label">
172 <button class="btn btn-link" data-action="">sub</button>
173 </span>
174
175 <ul class="il-menu-level">
176 <li class="il-menu-item" id="">
177 <span class="il-menu-item-label">
178 <button class="btn btn-default" data-action=""></button>
179 </span>
180 </li>
181 </ul>
182
183 <ul class="il-menu-level">
184 <li class="il-menu-item" id="">
185 <span class="il-menu-item-label">
186 <a class="glyph" href="" aria-label="show_who_is_online"><span class="glyphicon glyphicon-user" aria-hidden="true"></span></a>
187 </span>
188 </li>
189 </ul>
190 </li>
191 </ul>
192 <ul class="il-menu-level">
193 <li class="il-menu-item" id="">
194 <span class="il-menu-item-label">
195 <hr />
196 </span>
197 </li>
198 </ul>
199
200 <ul class="il-menu-level">
201 <li class="il-menu-item" id="">
202 <span class="il-menu-item-label">
203 <button class="btn btn-default" data-action=""></button>
204 </span>
205 </li>
206 </ul>
207 </li>
208 </ul>
209
210 <ul class="il-drilldown-backlink"></ul>
211 <ul class="il-drilldown-current"></ul>
212 <ul class="il-drilldown-visible"></ul>
213 </div>
214EOT;
215
216 $this->assertEquals(
217 $this->brutallyTrimHTML($expected),
218 $this->brutallyTrimHTML($html)
219 );
220 }
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268

References brutallyTrimHTML(), and ILIAS_UI_TestBase\getDefaultRenderer().

+ Here is the call graph for this function:

◆ testWithClickableLabel()

DrilldownTest::testWithClickableLabel (   $menu)

@depends testConstruction

Definition at line 94 of file DrilldownTest.php.

95 {
96 $this->assertEquals(
97 $this->button,
98 $menu->withLabel($this->button)->getLabel()
99 );
100 }

◆ testWithEntries()

DrilldownTest::testWithEntries ( )

Definition at line 113 of file DrilldownTest.php.

114 {
115 $f = $this->getUIFactory();
116 $items = array(
117 $f->menu()->sub('sub', [
118 $this->button,
119 $this->glyph
120 ]),
121 $this->divider,
122 $this->button
123 );
124 $menu = $f->menu()->drilldown('root', $items);
125 $this->assertEquals(
126 $items,
127 $menu->getItems()
128 );
129 return $menu;
130 }

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

+ Here is the call graph for this function:

◆ testWithLabel()

DrilldownTest::testWithLabel (   $menu)

@depends testConstruction

Definition at line 83 of file DrilldownTest.php.

84 {
85 $this->assertEquals(
86 'new label',
87 $menu->withLabel('new label')->getLabel()
88 );
89 }

◆ testWithWrongEntry()

DrilldownTest::testWithWrongEntry ( )

Definition at line 139 of file DrilldownTest.php.

140 {
141 $this->expectException(\InvalidArgumentException::class);
142 $f = $this->getUIFactory();
143 $menu = $f->menu()->drilldown('label', [$this->legacy]);
144 }

References Vendor\Package\$f, getUIFactory(), and legacy().

+ Here is the call graph for this function:

◆ testWithWrongLabel()

DrilldownTest::testWithWrongLabel ( )

Definition at line 132 of file DrilldownTest.php.

133 {
134 $this->expectException(\InvalidArgumentException::class);
135 $f = $this->getUIFactory();
136 $menu = $f->menu()->drilldown($this->divider, []);
137 }

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

+ Here is the call graph for this function:

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