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

Tests for the Meta Bar. More...

+ Inheritance diagram for MetaBarTest:
+ Collaboration diagram for MetaBarTest:

Public Member Functions

 setUp ()
 
 testConstruction ()
 
 testAddEntry ()
 
 testDisallowedEntry ()
 
 testSignalsPresent ()
 
 getUIFactory ()
 
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 
 testRendering ()
 
- 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)
 

Protected Member Functions

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

Detailed Description

Tests for the Meta Bar.

Definition at line 16 of file MetaBarTest.php.

Member Function Documentation

◆ brutallyTrimHTML()

MetaBarTest::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 117 of file MetaBarTest.php.

118 {
119 $html = str_replace(["\n", "\r", "\t"], "", $html);
120 $html = preg_replace('# {2,}#', " ", $html);
121 $html = preg_replace('/<!--(.|\s)*?-->/', '', $html);
122 return trim($html);
123 }

Referenced by testRendering().

+ Here is the caller graph for this function:

◆ getButton()

MetaBarTest::getButton ( )
protected

Definition at line 47 of file MetaBarTest.php.

48 {
49 $symbol = $this->icon_factory->custom('', '');
50 return $this->button_factory->bulky($symbol, 'TestEntry', '#');
51 }

Referenced by testAddEntry(), and testRendering().

+ Here is the caller graph for this function:

◆ getSlate()

MetaBarTest::getSlate ( )
protected

Definition at line 53 of file MetaBarTest.php.

54 {
55 $mock = $this->getMockBuilder(Legacy::class)
56 ->disableOriginalConstructor()
57 ->setMethods(["transformToLegacyComponent"])
58 ->getMock();
59
60 $mock->method('transformToLegacyComponent')->willReturn('content');
61 return $mock;
62 }

Referenced by testAddEntry(), and testRendering().

+ Here is the caller graph for this function:

◆ getUIFactory()

MetaBarTest::getUIFactory ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 87 of file MetaBarTest.php.

88 {
89 $factory = new class extends NoUIFactory {
90 public function button()
91 {
92 return $this->button_factory;
93 }
94 public function mainControls() : C\MainControls\Factory
95 {
96 return $this->mc_factory;
97 }
98 public function symbol() : C\Symbol\Factory
99 {
100 return new I\Component\Symbol\Factory(
101 new I\Component\Symbol\Icon\Factory(),
102 new I\Component\Symbol\Glyph\Factory(),
103 new I\Component\Symbol\Avatar\Factory()
104 );
105 }
106 public function counter() : C\Counter\Factory
107 {
108 return $this->counter_factory;
109 }
110 };
111 $factory->button_factory = $this->button_factory;
112 $factory->mc_factory = $this->factory;
113 $factory->counter_factory = $this->counter_factory;
114 return $factory;
115 }
$factory
Definition: metadata.php:58

References $factory.

◆ setUp()

MetaBarTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 18 of file MetaBarTest.php.

18 : void
19 {
20 $sig_gen = new I\Component\SignalGenerator();
21 $this->button_factory = new I\Component\Button\Factory($sig_gen);
22 $this->icon_factory = new I\Component\Symbol\Icon\Factory();
23 $this->counter_factory = new I\Component\Counter\Factory();
24
25 $slate_factory = new I\Component\MainControls\Slate\Factory(
26 $sig_gen,
27 $this->counter_factory,
28 new I\Component\Symbol\Factory(
29 new I\Component\Symbol\Icon\Factory(),
30 new I\Component\Symbol\Glyph\Factory(),
31 new I\Component\Symbol\Avatar\Factory()
32 )
33 );
34
35 $this->factory = new I\Component\MainControls\Factory($sig_gen, $slate_factory);
36 $this->metabar = $this->factory->metabar();
37 }
metabar()
Definition: metabar.php:2

References metabar().

+ Here is the call graph for this function:

◆ testAddEntry()

MetaBarTest::testAddEntry ( )

Definition at line 64 of file MetaBarTest.php.

65 {
66 $button = $this->getButton();
67 $slate = $this->getSlate();
68 $mb = $this->metabar
69 ->withAdditionalEntry('button', $button)
70 ->withAdditionalEntry('slate', $slate);
71 $entries = $mb->getEntries();
72 $this->assertEquals($button, $entries['button']);
73 $this->assertEquals($slate, $entries['slate']);
74 }

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

+ Here is the call graph for this function:

◆ testConstruction()

MetaBarTest::testConstruction ( )

Definition at line 39 of file MetaBarTest.php.

40 {
41 $this->assertInstanceOf(
42 "ILIAS\\UI\\Component\\MainControls\\MetaBar",
43 $this->metabar
44 );
45 }

References metabar().

+ Here is the call graph for this function:

◆ testDisallowedEntry()

MetaBarTest::testDisallowedEntry ( )

Definition at line 76 of file MetaBarTest.php.

77 {
78 $this->expectException(\InvalidArgumentException::class);
79 $mb = $this->metabar->withAdditionalEntry('test', 'wrong_param');
80 }

References metabar().

+ Here is the call graph for this function:

◆ testRendering()

MetaBarTest::testRendering ( )

Definition at line 125 of file MetaBarTest.php.

126 {
127 $r = $this->getDefaultRenderer();
128
129 $button = $this->getButton();
130 $slate = $this->getSlate();
131 $mb = $this->metabar
132 ->withAdditionalEntry('button', $button)
133 ->withAdditionalEntry('button2', $button);
134
135 $html = $r->render($mb);
136
137 $expected = <<<EOT
138<div class="il-maincontrols-metabar" id="id_5" role="menubar" aria-label="metabar_aria_label">
139 <div class="il-metabar-entries" style="visibility: hidden">
140 <button class="btn btn-bulky" data-action="#" id="id_1" >
141 <div class="icon custom small" aria-label="">
142 <img src="" />
143 </div>
144 <span class="bulky-label">TestEntry</span>
145 </button>
146 <button class="btn btn-bulky" data-action="#" id="id_2" >
147 <div class="icon custom small" aria-label="">
148 <img src="" />
149 </div>
150 <span class="bulky-label">TestEntry</span>
151 </button>
152 <button class="btn btn-bulky" id="id_3" role="menuitem" aria-haspopup="true" aria-pressed="false" >
153 <span class="glyph" aria-label="disclose">
154 <span class="glyphicon glyphicon-option-vertical" aria-hidden="true"></span>
155 <span class="il-counter">
156 <span class="badge badge-notify il-counter-status" style="display:none">0</span>
157 </span>
158 <span class="il-counter">
159 <span class="badge badge-notify il-counter-novelty" style="display:none">0</span>
160 </span>
161 </span>
162 <span class="bulky-label">more</span>
163 </button>
164 </div>
165 <div class="il-metabar-slates">
166 <div class="il-maincontrols-slate disengaged" id="id_4" role="menu">
167 <div class="il-maincontrols-slate-content" data-replace-marker="content"></div>
168 </div>
169 </div>
170</div>
171EOT;
172
173 $this->assertEquals(
174 $this->brutallyTrimHTML($expected),
175 $this->brutallyTrimHTML($html)
176 );
177 }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
more()
Definition: more.php:2

References brutallyTrimHTML(), getButton(), ILIAS_UI_TestBase\getDefaultRenderer(), getSlate(), metabar(), and more().

+ Here is the call graph for this function:

◆ testSignalsPresent()

MetaBarTest::testSignalsPresent ( )

Definition at line 82 of file MetaBarTest.php.

83 {
84 $this->assertInstanceOf(Signal::class, $this->metabar->getEntryClickSignal());
85 }

References metabar().

+ Here is the call graph for this function:

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