ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML (string $html)
 
 assertHTMLEquals (string $expected_html_as_string, string $html_as_string)
 

Protected Member Functions

 getButton ()
 
 getSlate ()
 
- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML (string $html)
 A more radical version of normalizeHTML. More...
 
 brutallyTrimSignals (string $html)
 A naive replacement of all il_signal-ids with dots to ease comparisons of rendered output. More...
 

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.

Referenced by testRendering().

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  }
+ Here is the caller graph for this function:

◆ getButton()

MetaBarTest::getButton ( )
protected

Definition at line 70 of file MetaBarTest.php.

Referenced by testAddEntry(), 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:

◆ getSlate()

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

Definition at line 79 of file MetaBarTest.php.

Referenced by testAddEntry().

80  {
81  $mock = $this->getMockBuilder(Legacy::class)
82  ->disableOriginalConstructor()
83  ->getMock();
84 
85  return $mock;
86  }
+ Here is the caller graph for this function:

◆ getUIFactory()

MetaBarTest::getUIFactory ( )

Definition at line 111 of file MetaBarTest.php.

References $button_factory, $counter_factory, and $factory.

111  : NoUIFactory
112  {
113  $factory = new class () extends NoUIFactory {
114  public C\Button\Factory $button_factory;
115  public C\MainControls\Factory $mc_factory;
116  public C\Counter\Factory $counter_factory;
117 
118  public function button(): C\Button\Factory
119  {
120  return $this->button_factory;
121  }
122  public function mainControls(): C\MainControls\Factory
123  {
124  return $this->mc_factory;
125  }
126  public function symbol(): C\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(): C\Counter\Factory
135  {
136  return $this->counter_factory;
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  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
I Component Button Factory $button_factory
Definition: MetaBarTest.php:35
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21
I Component Counter Factory $counter_factory
Definition: MetaBarTest.php:37
I Component MainControls Factory $factory
Definition: MetaBarTest.php:38

◆ 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  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ testAcceptsBulkyLinkAsEntry()

MetaBarTest::testAcceptsBulkyLinkAsEntry ( )

Definition at line 202 of file MetaBarTest.php.

References ILIAS_UI_TestBase\getDefaultRenderer().

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  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
Class Factory.
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ testAddEntry()

MetaBarTest::testAddEntry ( )

Definition at line 88 of file MetaBarTest.php.

References getButton(), and getSlate().

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  }
+ 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.

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

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  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
brutallyTrimHTML(string $html)
+ 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: