ILIAS  release_7 Revision v7.30-3-g800a261c036
CombinedSlateTest Class Reference

Tests for the Slate. More...

+ Inheritance diagram for CombinedSlateTest:
+ Collaboration diagram for CombinedSlateTest:

Public Member Functions

 setUp ()
 
 getUIFactory ()
 
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 
 testRendering ()
 
 testRenderingWithAriaRole ()
 
 testRenderingWithSubDivider ()
 
 testRenderingWithSubslateAndButton ()
 
- 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)
 

Additional Inherited Members

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

Detailed Description

Tests for the Slate.

Definition at line 15 of file CombinedSlateTest.php.

Member Function Documentation

◆ brutallyTrimHTML()

CombinedSlateTest::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 52 of file CombinedSlateTest.php.

53 {
54 $html = str_replace(["\n", "\r", "\t"], "", $html);
55 $html = preg_replace('# {2,}#', " ", $html);
56 return trim($html);
57 }

Referenced by testRendering(), testRenderingWithAriaRole(), testRenderingWithSubDivider(), and testRenderingWithSubslateAndButton().

+ Here is the caller graph for this function:

◆ getUIFactory()

CombinedSlateTest::getUIFactory ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 25 of file CombinedSlateTest.php.

26 {
27 $factory = new class extends NoUIFactory {
28 public function button()
29 {
30 return $this->button_factory;
31 }
32 public function glyph()
33 {
34 return new I\Symbol\Glyph\Factory();
35 }
36
37 public function divider()
38 {
39 return new I\Divider\Factory();
40 }
41
42 public function mainControls() : C\MainControls\Factory
43 {
44 return new I\MainControls\Factory($this->sig_gen);
45 }
46 };
47 $factory->button_factory = $this->button_factory;
48 $factory->sig_gen = $this->sig_gen;
49 return $factory;
50 }
$factory
Definition: metadata.php:58

References $factory.

◆ setUp()

CombinedSlateTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 17 of file CombinedSlateTest.php.

17 : void
18 {
19 $this->sig_gen = new I\SignalGenerator();
20 $this->button_factory = new I\Button\Factory($this->sig_gen);
21 $this->divider_factory = new I\Divider\Factory();
22 $this->icon_factory = new I\Symbol\Icon\Factory();
23 }

◆ testRendering()

CombinedSlateTest::testRendering ( )

Definition at line 59 of file CombinedSlateTest.php.

60 {
61 $name = 'name';
62 $icon = $this->icon_factory->custom('', '');
63 $slate = new Combined($this->sig_gen, $name, $icon);
64
65 $r = $this->getDefaultRenderer();
66 $html = $r->render($slate);
67
68 $expected = '<div class="il-maincontrols-slate disengaged" id="id_1"><div class="il-maincontrols-slate-content" data-replace-marker="content"></div></div>';
69 $this->assertEquals(
70 $expected,
71 $this->brutallyTrimHTML($html)
72 );
73 }
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
if($format !==null) $name
Definition: metadata.php:230

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

+ Here is the call graph for this function:

◆ testRenderingWithAriaRole()

CombinedSlateTest::testRenderingWithAriaRole ( )

Definition at line 75 of file CombinedSlateTest.php.

76 {
77 $name = 'name';
78 $icon = $this->icon_factory->custom('', '');
79 $slate = new Combined($this->sig_gen, $name, $icon);
80 $slate = $slate->withAriaRole(Combined::MENU);
81
82 $r = $this->getDefaultRenderer();
83 $html = $r->render($slate);
84
85 $expected = '<div class="il-maincontrols-slate disengaged" id="id_1" role="menu"><div class="il-maincontrols-slate-content" data-replace-marker="content"></div></div>';
86 $this->assertEquals(
87 $expected,
88 $this->brutallyTrimHTML($html)
89 );
90 }

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

+ Here is the call graph for this function:

◆ testRenderingWithSubDivider()

CombinedSlateTest::testRenderingWithSubDivider ( )

Definition at line 92 of file CombinedSlateTest.php.

93 {
94 $name = 'name';
95 $icon = $this->icon_factory->custom('', '');
96 $subdivider = new I\Divider\Horizontal();
97 $subdivider_with_text = new I\Divider\Horizontal();
98 $subdivider_with_text = $subdivider_with_text->withLabel('Title');
99 $slate = new Combined($this->sig_gen, $name, $icon);
100 $slate = $slate
101 ->withAdditionalEntry($subdivider_with_text)
102 ->withAdditionalEntry($subdivider);
103
104 $r = $this->getDefaultRenderer();
105 $html = $r->render($slate);
106
107 $expected = <<<EOT
108 <div class="il-maincontrols-slate disengaged" id="id_1">
109 <div class="il-maincontrols-slate-content" data-replace-marker="content">
110 <hr class="il-divider-with-label" />
111 <h4 class="il-divider">Title</h4>
112 <hr /></div></div>
113EOT;
114 $this->assertEquals(
115 $this->brutallyTrimHTML($expected),
116 $this->brutallyTrimHTML($html)
117 );
118 }
Title class.
Definition: Title.php:37

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

+ Here is the call graph for this function:

◆ testRenderingWithSubslateAndButton()

CombinedSlateTest::testRenderingWithSubslateAndButton ( )

Definition at line 120 of file CombinedSlateTest.php.

121 {
122 $name = 'name';
123 $icon = $this->icon_factory->custom('', '');
124 $subslate = new Combined($this->sig_gen, $name, $icon);
125 $subbutton = $this->button_factory->bulky($icon, '', '');
126 $slate = new Combined($this->sig_gen, $name, $icon);
127 $slate = $slate
128 ->withAdditionalEntry($subslate)
129 ->withAdditionalEntry($subbutton);
130
131 $r = $this->getDefaultRenderer();
132 $html = $r->render($slate);
133
134 $expected = <<<EOT
135 <div class="il-maincontrols-slate disengaged" id="id_3">
136 <div class="il-maincontrols-slate-content" data-replace-marker="content">
137
138 <button class="btn btn-bulky" id="id_1" >
139 <img class="icon custom small" src="" alt=""/>
140 <span class="bulky-label">name</span>
141 </button>
142 <div class="il-maincontrols-slate disengaged" id="id_2">
143 <div class="il-maincontrols-slate-content" data-replace-marker="content">
144 </div>
145 </div>
146
147 <button class="btn btn-bulky" data-action="" >
148 <img class="icon custom small" src="" alt=""/>
149 <span class="bulky-label"></span>
150 </button>
151
152 </div>
153 </div>
154EOT;
155 $this->assertEquals(
156 $this->brutallyTrimHTML($expected),
157 $this->brutallyTrimHTML($html)
158 );
159 }

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

+ Here is the call graph for this function:

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