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

Tests for the SimpleNode. More...

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

Public Member Functions

 setUp ()
 
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 
 testConstruction ()
 
 testWrongConstruction ()
 
 testConstructionWithIcon ()
 
 testGetLabel ($node)
 @depends testConstructionWithIcon More...
 
 testGetIcon ($node)
 @depends testConstructionWithIcon More...
 
 testDefaultAsyncLoading ($node)
 @depends testConstruction More...
 
 testWithAsyncURL ($node)
 @depends testConstruction More...
 
 testRendering ($node)
 @depends testConstruction More...
 
 testRenderingWithAsync ($node)
 @depends testWithAsyncURL More...
 
 testRenderingWithIcon ($node)
 @depends testConstructionWithIcon More...
 
- 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)
 

Additional Inherited Members

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

Detailed Description

Tests for the SimpleNode.

Definition at line 14 of file SimpleNodeTest.php.

Member Function Documentation

◆ brutallyTrimHTML()

SimpleNodeTest::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 23 of file SimpleNodeTest.php.

24 {
25 $html = str_replace(["\n", "\r", "\t"], "", $html);
26 $html = preg_replace('# {2,}#', " ", $html);
27 return trim($html);
28 }

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

+ Here is the caller graph for this function:

◆ setUp()

SimpleNodeTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 16 of file SimpleNodeTest.php.

16 : void
17 {
18 $this->node_factory = new I\Tree\Node\Factory();
19 $icon_factory = new I\Symbol\Icon\Factory();
20 $this->icon = $icon_factory->standard("", '');
21 }

◆ testConstruction()

SimpleNodeTest::testConstruction ( )

Definition at line 30 of file SimpleNodeTest.php.

31 {
32 $node = $this->node_factory->simple('simple');
33 $this->assertInstanceOf(
34 "ILIAS\\UI\\Component\\Tree\\Node\\Simple",
35 $node
36 );
37 return $node;
38 }

◆ testConstructionWithIcon()

SimpleNodeTest::testConstructionWithIcon ( )

Definition at line 46 of file SimpleNodeTest.php.

47 {
48 $node = $this->node_factory->simple('label', $this->icon);
49 $this->assertInstanceOf(
50 "ILIAS\\UI\\Component\\Tree\\Node\\Simple",
51 $node
52 );
53 return $node;
54 }

◆ testDefaultAsyncLoading()

SimpleNodeTest::testDefaultAsyncLoading (   $node)

@depends testConstruction

Definition at line 82 of file SimpleNodeTest.php.

83 {
84 $this->assertFalse(
85 $node->getAsyncLoading()
86 );
87 }

◆ testGetIcon()

SimpleNodeTest::testGetIcon (   $node)

@depends testConstructionWithIcon

Definition at line 70 of file SimpleNodeTest.php.

71 {
72 $this->assertEquals(
73 $this->icon,
74 $node->getIcon()
75 );
76 return $node;
77 }

◆ testGetLabel()

SimpleNodeTest::testGetLabel (   $node)

@depends testConstructionWithIcon

Definition at line 59 of file SimpleNodeTest.php.

60 {
61 $this->assertEquals(
62 "label",
63 $node->getLabel()
64 );
65 }

◆ testRendering()

SimpleNodeTest::testRendering (   $node)

@depends testConstruction

Definition at line 109 of file SimpleNodeTest.php.

110 {
111 $r = $this->getDefaultRenderer();
112 $html = $r->render($node);
113
114 $expected = <<<EOT
115 <li id="" class="il-tree-node node-simple" role="none">
116 <span class="node-line">
117 <span class="node-label">simple</span>
118 </span>
119 </li>
120EOT;
121
122 $this->assertEquals(
123 $this->brutallyTrimHTML($expected),
124 $this->brutallyTrimHTML($html)
125 );
126 }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
simple()
Definition: simple.php:2

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

+ Here is the call graph for this function:

◆ testRenderingWithAsync()

SimpleNodeTest::testRenderingWithAsync (   $node)

@depends testWithAsyncURL

Definition at line 131 of file SimpleNodeTest.php.

132 {
133 $r = $this->getDefaultRenderer();
134 $html = $r->render($node);
135
136 $expected = <<<EOT
137 <li id=""
138 class="il-tree-node node-simple expandable"
139 role="treeitem" aria-expanded="false"
140 data-async_url="something.de" data-async_loaded="false">
141 <span class="node-line">
142 <span class="node-label">simple</span>
143 </span>
144 </li>
145EOT;
146
147 $this->assertEquals(
148 $this->brutallyTrimHTML($expected),
149 $this->brutallyTrimHTML($html)
150 );
151 }

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

+ Here is the call graph for this function:

◆ testRenderingWithIcon()

SimpleNodeTest::testRenderingWithIcon (   $node)

@depends testConstructionWithIcon

Definition at line 156 of file SimpleNodeTest.php.

157 {
158 $r = $this->getDefaultRenderer();
159 $html = $r->render($node);
160
161 $expected = <<<EOT
162 <li id="" class="il-tree-node node-simple" role="none">
163 <span class="node-line">
164 <span class="node-label"><div class="icon small" aria-label=""></div>label</span>
165 </span>
166 </li>
167EOT;
168
169 $this->assertEquals(
170 $this->brutallyTrimHTML($expected),
171 $this->brutallyTrimHTML($html)
172 );
173 }

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

+ Here is the call graph for this function:

◆ testWithAsyncURL()

SimpleNodeTest::testWithAsyncURL (   $node)

@depends testConstruction

Definition at line 92 of file SimpleNodeTest.php.

93 {
94 $url = 'something.de';
95 $node = $node->withAsyncURL($url);
96 $this->assertTrue(
97 $node->getAsyncLoading()
98 );
99 $this->assertEquals(
100 $url,
101 $node->getAsyncURL()
102 );
103 return $node;
104 }
$url

References $url.

◆ testWrongConstruction()

SimpleNodeTest::testWrongConstruction ( )

Definition at line 40 of file SimpleNodeTest.php.

41 {
42 $this->expectException(\ArgumentCountError::class);
43 $node = $this->node_factory->simple();
44 }

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