ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 (string $html)
 
 testRendering ()
 
 testAcceptsBulkyLinkAsEntry ()
 

Protected Member Functions

 getButton ()
 
 getSlate ()
 

Protected Attributes

I Component Button Factory $button_factory
 
I Component Symbol Icon Factory $icon_factory
 
I Component Counter Factory $counter_factory
 
I Component MainControls Factory $factory
 
C MainControls MetaBar $metabar
 

Detailed Description

Tests for the Meta Bar.

Definition at line 33 of file MetaBarTest.php.

Member Function Documentation

◆ brutallyTrimHTML()

MetaBarTest::brutallyTrimHTML ( string  $html)

Definition at line 145 of file MetaBarTest.php.

145 : string
146 {
147 $html = str_replace(["\n", "\r", "\t"], "", $html);
148 $html = preg_replace('# {2,}#', " ", $html);
149 $html = preg_replace('/<!--(.|\s)*?-->/', '', $html);
150 $html = str_replace('> <', '><', $html);
151 return trim($html);
152 }

Referenced by testRendering().

+ Here is the caller graph for this function:

◆ getButton()

MetaBarTest::getButton ( )
protected

Definition at line 70 of file MetaBarTest.php.

70 : C\Button\Bulky
71 {
72 $symbol = $this->icon_factory->custom('', '');
73 return $this->button_factory->bulky($symbol, 'TestEntry', '#');
74 }

Referenced by testAddEntry(), and testRendering().

+ Here is the caller graph for this function:

◆ getSlate()

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

Definition at line 79 of file MetaBarTest.php.

80 {
81 $mock = $this->getMockBuilder(Legacy::class)
82 ->disableOriginalConstructor()
83 ->getMock();
84
85 return $mock;
86 }

Referenced by testAddEntry().

+ Here is the caller graph for this function:

◆ getUIFactory()

MetaBarTest::getUIFactory ( )

Definition at line 111 of file MetaBarTest.php.

112 {
113 $factory = new class () extends NoUIFactory {
114 public I\Component\Button\Factory $button_factory;
115 public I\Component\MainControls\Factory $mc_factory;
116 public I\Component\Counter\Factory $counter_factory;
117
118 public function button(): I\Component\Button\Factory
119 {
121 }
122 public function mainControls(): I\Component\MainControls\Factory
123 {
124 return $this->mc_factory;
125 }
126 public function symbol(): I\Component\Symbol\Factory
127 {
128 return new I\Component\Symbol\Factory(
129 new I\Component\Symbol\Icon\Factory(),
130 new I\Component\Symbol\Glyph\Factory(),
131 new I\Component\Symbol\Avatar\Factory()
132 );
133 }
134 public function counter(): I\Component\Counter\Factory
135 {
137 }
138 };
139 $factory->button_factory = $this->button_factory;
140 $factory->mc_factory = $this->factory;
141 $factory->counter_factory = $this->counter_factory;
142 return $factory;
143 }
I Component Button Factory $button_factory
Definition: MetaBarTest.php:35
I Component MainControls Factory $factory
Definition: MetaBarTest.php:38
I Component Counter Factory $counter_factory
Definition: MetaBarTest.php:37
button(string $caption, string $cmd)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21

References $button_factory, $counter_factory, $factory, ILIAS\Repository\button(), and ILIAS\Repository\symbol().

+ Here is the call graph for this function:

◆ setUp()

MetaBarTest::setUp ( )

Definition at line 41 of file MetaBarTest.php.

41 : void
42 {
43 $sig_gen = new I\Component\SignalGenerator();
44 $this->button_factory = new I\Component\Button\Factory();
45 $this->icon_factory = new I\Component\Symbol\Icon\Factory();
46 $this->counter_factory = new I\Component\Counter\Factory();
47
48 $slate_factory = new I\Component\MainControls\Slate\Factory(
49 $sig_gen,
50 $this->counter_factory,
51 new I\Component\Symbol\Factory(
52 new I\Component\Symbol\Icon\Factory(),
53 new I\Component\Symbol\Glyph\Factory(),
54 new I\Component\Symbol\Avatar\Factory()
55 )
56 );
57
58 $this->factory = new I\Component\MainControls\Factory($sig_gen, $slate_factory);
59 $this->metabar = $this->factory->metabar();
60 }
factory()

References factory().

+ Here is the call graph for this function:

◆ testAcceptsBulkyLinkAsEntry()

MetaBarTest::testAcceptsBulkyLinkAsEntry ( )

Definition at line 202 of file MetaBarTest.php.

202 : void
203 {
204 $r = $this->getDefaultRenderer();
205
206 $bulky_link = $this->createMock(ILIAS\UI\Component\Link\Bulky::class);
207 $mb = $this->metabar
208 ->withAdditionalEntry('bulky link', $bulky_link);
209
210 $this->assertTrue(true); // Should not throw...
211 }
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

◆ testAddEntry()

MetaBarTest::testAddEntry ( )

Definition at line 88 of file MetaBarTest.php.

88 : void
89 {
90 $button = $this->getButton();
91 $slate = $this->getSlate();
92 $mb = $this->metabar
93 ->withAdditionalEntry('button', $button)
94 ->withAdditionalEntry('slate', $slate);
95 $entries = $mb->getEntries();
96 $this->assertEquals($button, $entries['button']);
97 $this->assertEquals($slate, $entries['slate']);
98 }

References getButton(), and getSlate().

+ Here is the call graph for this function:

◆ testConstruction()

MetaBarTest::testConstruction ( )

Definition at line 62 of file MetaBarTest.php.

62 : void
63 {
64 $this->assertInstanceOf(
65 "ILIAS\\UI\\Component\\MainControls\\MetaBar",
66 $this->metabar
67 );
68 }

◆ testDisallowedEntry()

MetaBarTest::testDisallowedEntry ( )

Definition at line 100 of file MetaBarTest.php.

100 : void
101 {
102 $this->expectException(InvalidArgumentException::class);
103 $this->metabar->withAdditionalEntry('test', 'wrong_param');
104 }

◆ testRendering()

MetaBarTest::testRendering ( )

Definition at line 154 of file MetaBarTest.php.

154 : void
155 {
156 $r = $this->getDefaultRenderer();
157
158 $button = $this->getButton();
159 $mb = $this->metabar
160 ->withAdditionalEntry('button', $button)
161 ->withAdditionalEntry('button2', $button);
162
163 $html = $r->render($mb);
164
165 $expected = '
166 <ul class="il-maincontrols-metabar" role="menubar" style="visibility: hidden" aria-label="metabar_aria_label" id="id_5" >
167 <li role="none">
168 <button class="btn btn-bulky" data-action="#" id="id_1" role="menuitem" >
169 <img class="icon custom small" src="" alt=""/><span class="bulky-label">TestEntry</span>
170 </button>
171 </li>
172 <li role="none">
173 <button class="btn btn-bulky" data-action="#" id="id_2" role="menuitem" >
174 <img class="icon custom small" src="" alt=""/><span class="bulky-label">TestEntry</span>
175 </button>
176 </li>
177 <li role="none">
178 <button class="btn btn-bulky" id="id_3" role="menuitem" aria-haspopup="true" >
179 <span class="glyph" role="img">
180 <span class="glyphicon glyphicon-option-vertical" aria-hidden="true"></span>
181 <span class="il-counter"><span class="badge badge-notify il-counter-status" style="display:none">0</span></span>
182 <span class="il-counter"><span class="badge badge-notify il-counter-novelty" style="display:none">0</span></span>
183 </span>
184 <span class="bulky-label">show_more</span>
185 </button>
186 <div class="il-metabar-slates">
187 <div class="il-maincontrols-slate disengaged" id="id_4" role="menu">
188 <div class="il-maincontrols-slate-content" data-replace-marker="content"></div>
189 </div>
190 </div>
191 </li>
192 </ul>
193';
194
195 $this->assertEquals(
196 $this->brutallyTrimHTML($expected),
197 $this->brutallyTrimHTML($html)
198 );
199 }
brutallyTrimHTML(string $html)

References brutallyTrimHTML(), and getButton().

+ Here is the call graph for this function:

◆ testSignalsPresent()

MetaBarTest::testSignalsPresent ( )

Definition at line 106 of file MetaBarTest.php.

106 : void
107 {
108 $this->assertInstanceOf(Signal::class, $this->metabar->getEntryClickSignal());
109 }

Field Documentation

◆ $button_factory

I Component Button Factory MetaBarTest::$button_factory
protected

Definition at line 35 of file MetaBarTest.php.

Referenced by getUIFactory().

◆ $counter_factory

I Component Counter Factory MetaBarTest::$counter_factory
protected

Definition at line 37 of file MetaBarTest.php.

Referenced by getUIFactory().

◆ $factory

I Component MainControls Factory MetaBarTest::$factory
protected

Definition at line 38 of file MetaBarTest.php.

Referenced by getUIFactory().

◆ $icon_factory

I Component Symbol Icon Factory MetaBarTest::$icon_factory
protected

Definition at line 36 of file MetaBarTest.php.

◆ $metabar

C MainControls MetaBar MetaBarTest::$metabar
protected

Definition at line 39 of file MetaBarTest.php.


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