ILIAS  release_8 Revision v8.24
SimpleNodeTest Class Reference

Tests for the SimpleNode. More...

+ Inheritance diagram for SimpleNodeTest:
+ Collaboration diagram for SimpleNodeTest:

Public Member Functions

 setUp ()
 
 brutallyTrimHTML (string $html)
 A more radical version of normalizeHTML. More...
 
 testConstruction ()
 
 testWrongConstruction ()
 
 testConstructionWithIcon ()
 
 testConstructionWithIconAndDifferentLabels ()
 
 testGetDifferentLabels (C\Tree\Node\Simple $node)
 @depends testConstructionWithIconAndDifferentLabels More...
 
 testGetLabel (C\Tree\Node\Simple $node)
 @depends testConstructionWithIcon More...
 
 testGetIcon (C\Tree\Node\Simple $node)
 @depends testConstructionWithIcon More...
 
 testDefaultAsyncLoading (C\Tree\Node\Simple $node)
 @depends testConstruction More...
 
 testWithAsyncURL (C\Tree\Node\Simple $node)
 @depends testConstruction More...
 
 testRendering (C\Tree\Node\Simple $node)
 @depends testConstruction More...
 
 testRenderingWithAsync (C\Tree\Node\Simple $node)
 @depends testWithAsyncURL More...
 
 testRenderingWithIcon (C\Tree\Node\Simple $node)
 @depends testConstructionWithIcon More...
 
 testRenderingWithIconAndAltAttribute (C\Tree\Node\Simple $node)
 This test is successfull if the icon label differs from the node label. More...
 
- 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)
 

Private Attributes

I Tree Node Factory $node_factory
 
C Symbol Icon Standard $icon
 

Additional Inherited Members

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

Detailed Description

Tests for the SimpleNode.

Definition at line 30 of file SimpleNodeTest.php.

Member Function Documentation

◆ brutallyTrimHTML()

SimpleNodeTest::brutallyTrimHTML ( string  $html)

A more radical version of normalizeHTML.

Use if hard to tackle issues occur by asserting due string outputs produce an equal DOM

Reimplemented from ILIAS_UI_TestBase.

Definition at line 42 of file SimpleNodeTest.php.

42 : string
43 {
44 $html = str_replace(["\n", "\r", "\t"], "", $html);
45 $html = preg_replace('# {2,}#', " ", $html);
46 return trim($html);
47 }

Referenced by testRendering(), testRenderingWithAsync(), testRenderingWithIcon(), and testRenderingWithIconAndAltAttribute().

+ Here is the caller graph for this function:

◆ setUp()

SimpleNodeTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 35 of file SimpleNodeTest.php.

35 : void
36 {
37 $this->node_factory = new I\Tree\Node\Factory();
38 $icon_factory = new I\Symbol\Icon\Factory();
39 $this->icon = $icon_factory->standard("", '');
40 }

◆ testConstruction()

SimpleNodeTest::testConstruction ( )

Definition at line 49 of file SimpleNodeTest.php.

49 : C\Tree\Node\Simple
50 {
51 $node = $this->node_factory->simple('simple');
52 $this->assertInstanceOf(
53 "ILIAS\\UI\\Component\\Tree\\Node\\Simple",
54 $node
55 );
56 return $node;
57 }

◆ testConstructionWithIcon()

SimpleNodeTest::testConstructionWithIcon ( )

Definition at line 65 of file SimpleNodeTest.php.

65 : C\Tree\Node\Simple
66 {
67 $node = $this->node_factory->simple('label', $this->icon);
68 $this->assertInstanceOf(
69 "ILIAS\\UI\\Component\\Tree\\Node\\Simple",
70 $node
71 );
72 return $node;
73 }

◆ testConstructionWithIconAndDifferentLabels()

SimpleNodeTest::testConstructionWithIconAndDifferentLabels ( )

Definition at line 74 of file SimpleNodeTest.php.

74 : C\Tree\Node\Simple
75 {
76 $this->icon->setLabel('Different Icon Label');
77 $node = $this->node_factory->simple('label', $this->icon);
78 $this->assertInstanceOf(
79 "ILIAS\\UI\\Component\\Tree\\Node\\Simple",
80 $node
81 );
82 return $node;
83 }

◆ testDefaultAsyncLoading()

SimpleNodeTest::testDefaultAsyncLoading ( C\Tree\Node\Simple  $node)

@depends testConstruction

Definition at line 113 of file SimpleNodeTest.php.

113 : void
114 {
115 $this->assertFalse($node->getAsyncLoading());
116 }

◆ testGetDifferentLabels()

SimpleNodeTest::testGetDifferentLabels ( C\Tree\Node\Simple  $node)

@depends testConstructionWithIconAndDifferentLabels

Definition at line 88 of file SimpleNodeTest.php.

88 : void
89 {
90 $this->assertNotEquals($this->icon->getLabel(), $node->getLabel());
91 }

◆ testGetIcon()

SimpleNodeTest::testGetIcon ( C\Tree\Node\Simple  $node)

@depends testConstructionWithIcon

Definition at line 104 of file SimpleNodeTest.php.

104 : C\Tree\Node\Simple
105 {
106 $this->assertEquals($this->icon, $node->getIcon());
107 return $node;
108 }

◆ testGetLabel()

SimpleNodeTest::testGetLabel ( C\Tree\Node\Simple  $node)

@depends testConstructionWithIcon

Definition at line 96 of file SimpleNodeTest.php.

96 : void
97 {
98 $this->assertEquals("label", $node->getLabel());
99 }

◆ testRendering()

SimpleNodeTest::testRendering ( C\Tree\Node\Simple  $node)

@depends testConstruction

Definition at line 133 of file SimpleNodeTest.php.

133 : void
134 {
135 $r = $this->getDefaultRenderer();
136 $html = $r->render($node);
137
138 $expected = <<<EOT
139 <li id="" class="il-tree-node node-simple" role="treeitem">
140 <span class="node-line">
141 <span class="node-label">simple</span>
142 </span>
143 </li>
144EOT;
145
146 $this->assertEquals(
147 $this->brutallyTrimHTML($expected),
148 $this->brutallyTrimHTML($html)
149 );
150 }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.

References brutallyTrimHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS\UI\examples\MainControls\SystemInfo\simple().

+ Here is the call graph for this function:

◆ testRenderingWithAsync()

SimpleNodeTest::testRenderingWithAsync ( C\Tree\Node\Simple  $node)

@depends testWithAsyncURL

Definition at line 155 of file SimpleNodeTest.php.

155 : void
156 {
157 $r = $this->getDefaultRenderer();
158 $html = $r->render($node);
159
160 $expected = <<<EOT
161 <li id=""
162 class="il-tree-node node-simple expandable"
163 role="treeitem" aria-expanded="false"
164 data-async_url="something.de" data-async_loaded="false">
165 <span class="node-line">
166 <span class="node-label">simple</span>
167 </span>
168 <ul role="group"></ul>
169 </li>
170EOT;
171
172 $this->assertEquals(
173 $this->brutallyTrimHTML($expected),
174 $this->brutallyTrimHTML($html)
175 );
176 }

References brutallyTrimHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS\UI\examples\MainControls\SystemInfo\simple().

+ Here is the call graph for this function:

◆ testRenderingWithIcon()

SimpleNodeTest::testRenderingWithIcon ( C\Tree\Node\Simple  $node)

@depends testConstructionWithIcon

Definition at line 181 of file SimpleNodeTest.php.

181 : void
182 {
183 $r = $this->getDefaultRenderer();
184 $html = $r->render($node);
185
186 $expected = <<<EOT
187 <li id="" class="il-tree-node node-simple" role="treeitem">
188 <span class="node-line">
189 <span class="node-label">
190 <img class="icon small" src="./templates/default/images/icon_default.svg" alt=""/>
191 label
192 </span>
193 </span>
194 </li>
195EOT;
196
197 $this->assertEquals(
198 $this->brutallyTrimHTML($expected),
199 $this->brutallyTrimHTML($html)
200 );
201 }

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

+ Here is the call graph for this function:

◆ testRenderingWithIconAndAltAttribute()

SimpleNodeTest::testRenderingWithIconAndAltAttribute ( C\Tree\Node\Simple  $node)

This test is successfull if the icon label differs from the node label.

As a result the alt attribute will get the icon's label as content. Else the alt attribute will be empty (see testRenderingWithIcon).

@depends testConstructionWithIconAndDifferentLabels

Definition at line 209 of file SimpleNodeTest.php.

209 : void
210 {
211 $r = $this->getDefaultRenderer();
212 $html = $r->render($node);
213
214 $expected = <<<EOT
215 <li id="" class="il-tree-node node-simple" role="treeitem">
216 <span class="node-line">
217 <span class="node-label">
218 <img class="icon small" src="./templates/default/images/icon_default.svg" alt="Different Icon Label"/>
219 label
220 </span>
221 </span>
222 </li>
223EOT;
224
225 $this->assertEquals(
226 $this->brutallyTrimHTML($expected),
227 $this->brutallyTrimHTML($html)
228 );
229 }

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

+ Here is the call graph for this function:

◆ testWithAsyncURL()

SimpleNodeTest::testWithAsyncURL ( C\Tree\Node\Simple  $node)

@depends testConstruction

Definition at line 121 of file SimpleNodeTest.php.

121 : C\Tree\Node\Simple
122 {
123 $url = 'something.de';
124 $node = $node->withAsyncURL($url);
125 $this->assertTrue($node->getAsyncLoading());
126 $this->assertEquals($url, $node->getAsyncURL());
127 return $node;
128 }
$url

References $url.

◆ testWrongConstruction()

SimpleNodeTest::testWrongConstruction ( )

Definition at line 59 of file SimpleNodeTest.php.

59 : void
60 {
61 $this->expectException(ArgumentCountError::class);
62 $this->node_factory->simple();
63 }

Field Documentation

◆ $icon

C Symbol Icon Standard SimpleNodeTest::$icon
private

Definition at line 33 of file SimpleNodeTest.php.

◆ $node_factory

I Tree Node Factory SimpleNodeTest::$node_factory
private

Definition at line 32 of file SimpleNodeTest.php.


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