ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
MainBarTest Class Reference

Tests for the Main Bar. More...

+ Inheritance diagram for MainBarTest:
+ Collaboration diagram for MainBarTest:

Public Member Functions

 setUp ()
 
 testConstruction ()
 
 testAddEntry ()
 
 testDisallowedEntry ()
 
 testDouplicateIdEntry ()
 
 testDisallowedToolEntry ()
 
 testAddToolEntryWithoutToolsButton ()
 
 testAddToolEntry ()
 
 testDouplicateIdToolEntry ()
 
 testActive (C\MainControls\MainBar $mb)
 testAddEntry More...
 
 testWithInvalidActive ()
 
 testSignalsPresent ()
 
 testRendering ()
 
- 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)
 

Protected Member Functions

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

Protected Attributes

 $button_factory
 
 $link_factory
 
 $icon_factory
 
 $factory
 
 $mainbar
 

Detailed Description

Tests for the Main Bar.

Definition at line 18 of file MainBarTest.php.

Member Function Documentation

◆ getButton()

MainBarTest::getButton ( )
protected

Definition at line 70 of file MainBarTest.php.

Referenced by testAddEntry(), testAddToolEntry(), testDouplicateIdEntry(), testDouplicateIdToolEntry(), and testRendering().

70  : C\Button\Bulky
71  {
72  $symbol = $this->icon_factory->custom('', '');
73  return $this->button_factory->bulky($symbol, 'TestEntry', '#');
74  }
+ Here is the caller graph for this function:

◆ getLink()

MainBarTest::getLink ( )
protected

Definition at line 76 of file MainBarTest.php.

Referenced by testAddEntry().

76  : C\Link\Bulky
77  {
78  $symbol = $this->icon_factory->custom('', '');
79  $target = new Data\URI("http://www.ilias.de");
80  return $this->link_factory->bulky($symbol, 'TestEntry', $target);
81  }
+ Here is the caller graph for this function:

◆ getSlate()

MainBarTest::getSlate ( )
protected
Returns
Legacy|mixed|MockObject

Definition at line 86 of file MainBarTest.php.

Referenced by testAddToolEntry(), testAddToolEntryWithoutToolsButton(), and testDouplicateIdToolEntry().

87  {
88  $mock = $this->getMockBuilder(Legacy::class)
89  ->disableOriginalConstructor()
90  ->getMock();
91 
92  return $mock;
93  }
+ Here is the caller graph for this function:

◆ setUp()

MainBarTest::setUp ( )

Definition at line 41 of file MainBarTest.php.

References mainbar().

41  : void
42  {
43  $sig_gen = new I\SignalGenerator();
44  $this->button_factory = new I\Button\Factory();
45  $this->link_factory = new I\Link\Factory();
46  $this->icon_factory = new I\Symbol\Icon\Factory();
47  $counter_factory = new I\Counter\Factory();
48  $slate_factory = new I\MainControls\Slate\Factory(
49  $sig_gen,
50  $counter_factory,
51  new I\Symbol\Factory(
52  new I\Symbol\Icon\Factory(),
53  new I\Symbol\Glyph\Factory(),
54  new I\Symbol\Avatar\Factory()
55  )
56  );
57  $this->factory = new I\MainControls\Factory($sig_gen, $slate_factory);
58 
59  $this->mainbar = $this->factory->mainBar();
60  }
Builds data types.
Definition: Factory.php:19
mainbar()
Definition: mainbar.php:2
+ Here is the call graph for this function:

◆ testActive()

MainBarTest::testActive ( C\MainControls\MainBar  $mb)

testAddEntry

Definition at line 163 of file MainBarTest.php.

163  : void
164  {
165  $mb = $mb->withActive('testbtn');
166  $this->assertEquals('testbtn', $mb->getActive());
167  }

◆ testAddEntry()

MainBarTest::testAddEntry ( )

Definition at line 95 of file MainBarTest.php.

References getButton(), getLink(), and mainbar().

95  : C\MainControls\MainBar
96  {
97  $btn = $this->getButton();
98  $lnk = $this->getLink();
99  $mb = $this->mainbar
100  ->withAdditionalEntry('testbtn', $btn)
101  ->withAdditionalEntry('testlnk', $lnk);
102 
103  $entries = $mb->getEntries();
104  $expected = [
105  'testbtn' => $btn,
106  'testlnk' => $lnk,
107  ];
108  $this->assertEquals($expected, $entries);
109  return $mb;
110  }
mainbar()
Definition: mainbar.php:2
+ Here is the call graph for this function:

◆ testAddToolEntry()

MainBarTest::testAddToolEntry ( )

Definition at line 139 of file MainBarTest.php.

References getButton(), getSlate(), and mainbar().

139  : void
140  {
141  $slate = $this->getSlate();
142  $mb = $this->mainbar
143  ->withToolsButton($this->getButton())
144  ->withAdditionalToolEntry('test', $slate);
145  $entries = $mb->getToolEntries();
146  $this->assertEquals($slate, $entries['test']);
147  }
mainbar()
Definition: mainbar.php:2
+ Here is the call graph for this function:

◆ testAddToolEntryWithoutToolsButton()

MainBarTest::testAddToolEntryWithoutToolsButton ( )

Definition at line 133 of file MainBarTest.php.

References getSlate(), and mainbar().

133  : void
134  {
135  $this->expectException(LogicException::class);
136  $this->mainbar->withAdditionalToolEntry('test', $this->getSlate());
137  }
mainbar()
Definition: mainbar.php:2
+ Here is the call graph for this function:

◆ testConstruction()

MainBarTest::testConstruction ( )

Definition at line 62 of file MainBarTest.php.

References mainbar().

62  : void
63  {
64  $this->assertInstanceOf(
65  "ILIAS\\UI\\Component\\MainControls\\MainBar",
66  $this->mainbar
67  );
68  }
mainbar()
Definition: mainbar.php:2
+ Here is the call graph for this function:

◆ testDisallowedEntry()

MainBarTest::testDisallowedEntry ( )

Definition at line 112 of file MainBarTest.php.

References mainbar().

112  : void
113  {
114  $this->expectException(InvalidArgumentException::class);
115  $this->mainbar->withAdditionalEntry('test', 'wrong_param');
116  }
mainbar()
Definition: mainbar.php:2
+ Here is the call graph for this function:

◆ testDisallowedToolEntry()

MainBarTest::testDisallowedToolEntry ( )

Definition at line 127 of file MainBarTest.php.

References mainbar().

127  : void
128  {
129  $this->expectException(\TypeError::class);
130  $this->mainbar->withAdditionalToolEntry('test', 'wrong_param');
131  }
mainbar()
Definition: mainbar.php:2
+ Here is the call graph for this function:

◆ testDouplicateIdEntry()

MainBarTest::testDouplicateIdEntry ( )

Definition at line 118 of file MainBarTest.php.

References getButton(), and mainbar().

118  : void
119  {
120  $this->expectException(InvalidArgumentException::class);
121  $btn = $this->getButton();
122  $this->mainbar
123  ->withAdditionalEntry('test', $btn)
124  ->withAdditionalEntry('test', $btn);
125  }
mainbar()
Definition: mainbar.php:2
+ Here is the call graph for this function:

◆ testDouplicateIdToolEntry()

MainBarTest::testDouplicateIdToolEntry ( )

Definition at line 149 of file MainBarTest.php.

References getButton(), getSlate(), and mainbar().

149  : void
150  {
151  $this->expectException(InvalidArgumentException::class);
152  $btn = $this->getButton();
153  $slate = $this->getSlate();
154  $this->mainbar
155  ->withToolsButton($btn)
156  ->withAdditionalToolEntry('test', $slate)
157  ->withAdditionalToolEntry('test', $slate);
158  }
mainbar()
Definition: mainbar.php:2
+ Here is the call graph for this function:

◆ testRendering()

MainBarTest::testRendering ( )

Definition at line 225 of file MainBarTest.php.

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

225  : void
226  {
227  $r = $this->getDefaultRenderer();
228  $icon = $this->icon_factory->custom('', '');
229 
230  $sf = $this->factory->slate();
231  $slate = $sf->combined('1', $icon)
232  ->withAdditionalEntry(
233  $sf->combined('1.1', $icon)
234  ->withAdditionalEntry(
235  $sf->combined('1.1.1', $icon)
236  )
237  );
238 
239  $toolslate = $sf->legacy('Help', $icon, new I\Legacy\Legacy('Help', new I\SignalGenerator()));
240 
241  $mb = $this->factory->mainBar()
242  ->withAdditionalEntry('test1', $this->getButton())
243  ->withAdditionalEntry('test2', $this->getButton())
244  ->withAdditionalEntry('slate', $slate)
245  ->withToolsButton($this->getButton())
246  ->withAdditionalToolEntry('tool1', $toolslate);
247 
248  $html = $r->render($mb);
249 
250  $expected = <<<EOT
251  <div class="il-maincontrols-mainbar" id="id_16">
252  <nav class="il-mainbar" aria-label="mainbar_aria_label">
253 
254  <div class="il-mainbar-tools-button">
255  <button class="btn btn-bulky" id="id_14"><img class="icon custom small" src="" alt=""/><span class="bulky-label">TestEntry</span></button>
256  </div>
257 
258  <div class="il-mainbar-triggers">
259  <ul class="il-mainbar-entries" role="menubar" style="visibility: hidden">
260  <li role="none"><button class="btn btn-bulky" data-action="#" id="id_1" role="menuitem" ><img class="icon custom small" src="" alt=""/><span class="bulky-label">TestEntry</span></button></li>
261  <li role="none"><button class="btn btn-bulky" data-action="#" id="id_2" role="menuitem" ><img class="icon custom small" src="" alt=""/><span class="bulky-label">TestEntry</span></button></li>
262  <li role="none"><button class="btn btn-bulky" id="id_3" role="menuitem" ><img class="icon custom small" src="" alt=""/><span class="bulky-label">1</span></button></li>
263  <li role="none"><button class="btn btn-bulky" id="id_9" role="menuitem" ><span class="glyph" aria-label="show_more" role="img"><span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span></span><span class="bulky-label">mainbar_more_label</span></button></li>
264  </ul>
265  </div>
266  </nav>
267 
268  <div class="il-mainbar-slates">
269  <div class="il-mainbar-tools-entries">
270  <ul class="il-mainbar-tools-entries-bg" role="menubar">
271  <li class="il-mainbar-tool-trigger-item" role="none">
272  <button class="btn btn-bulky" id="id_11" role="menuitem"><img class="icon custom small" src="" alt=""/><span class="bulky-label">Help</span></button>
273  </li>
274  </ul>
275  </div>
276  <div class="il-maincontrols-slate disengaged" id="id_8" data-depth-level="1" role="menu">
277  <div class="il-maincontrols-slate-content" data-replace-marker="content">
278  <button class="btn btn-bulky" id="id_4" ><img class="icon custom small" src="" alt=""/><span class="bulky-label">1.1</span></button>
279 
280  <div class="il-maincontrols-slate disengaged" id="id_7" data-depth-level="2">
281  <div class="il-maincontrols-slate-content" data-replace-marker="content">
282  <button class="btn btn-bulky" id="id_5" ><img class="icon custom small" src="" alt=""/><span class="bulky-label">1.1.1</span></button>
283 
284  <div class="il-maincontrols-slate disengaged" id="id_6" data-depth-level="3">
285  <div class="il-maincontrols-slate-content" data-replace-marker="content"></div>
286  </div>
287  </div>
288  </div>
289 
290  </div>
291  </div>
292 
293  <div class="il-maincontrols-slate disengaged" id="id_10" data-depth-level="1" role="menu">
294  <div class="il-maincontrols-slate-content" data-replace-marker="content"></div>
295  </div>
296 
297  <div class="il-maincontrols-slate disengaged" id="id_13" data-depth-level="1" role="menu">
298  <div class="il-maincontrols-slate-content" data-replace-marker="content">Help</div>
299  </div>
300 
301 
302  <div class="il-mainbar-close-slates">
303  <button class="btn btn-bulky" id="id_15" >
304  <span class="glyph" aria-label="back" role="img"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></span>
305  <span class="bulky-label">close</span></button>
306  </div>
307  </div>
308  </div>
309 EOT;
310 
311  $this->assertEquals(
312  $this->brutallyTrimHTML($expected),
313  $this->brutallyTrimHTML($html)
314  );
315  }
close()
Definition: close.php:2
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ testSignalsPresent()

MainBarTest::testSignalsPresent ( )

Definition at line 175 of file MainBarTest.php.

References $button_factory, $factory, ILIAS_UI_TestBase\getUIFactory(), legacy(), and mainbar().

175  : void
176  {
177  $this->assertInstanceOf(Signal::class, $this->mainbar->getEntryClickSignal());
178  $this->assertInstanceOf(Signal::class, $this->mainbar->getToolsClickSignal());
179  $this->assertInstanceOf(Signal::class, $this->mainbar->getToolsRemovalSignal());
180  $this->assertInstanceOf(Signal::class, $this->mainbar->getDisengageAllSignal());
181  }
mainbar()
Definition: mainbar.php:2
+ Here is the call graph for this function:

◆ testWithInvalidActive()

MainBarTest::testWithInvalidActive ( )

Definition at line 169 of file MainBarTest.php.

References mainbar().

169  : void
170  {
171  $this->expectException(InvalidArgumentException::class);
172  $this->mainbar->withActive('this-is-not-a-valid-entry');
173  }
mainbar()
Definition: mainbar.php:2
+ Here is the call graph for this function:

Field Documentation

◆ $button_factory

MainBarTest::$button_factory
protected

Definition at line 23 of file MainBarTest.php.

Referenced by testSignalsPresent().

◆ $factory

MainBarTest::$factory
protected

Definition at line 35 of file MainBarTest.php.

Referenced by testSignalsPresent().

◆ $icon_factory

MainBarTest::$icon_factory
protected

Definition at line 31 of file MainBarTest.php.

◆ $link_factory

MainBarTest::$link_factory
protected

Definition at line 27 of file MainBarTest.php.

◆ $mainbar

MainBarTest::$mainbar
protected

Definition at line 39 of file MainBarTest.php.


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