ILIAS  release_7 Revision v7.30-3-g800a261c036
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 ()
 
 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 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="treeitem">
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 }
simple()
Definition: simple.php:5
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
brutallyTrimHTML($html)
A more radical version of normalizeHTML.

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 <ul role="group"></ul>
145 </li>
146EOT;
147
148 $this->assertEquals(
149 $this->brutallyTrimHTML($expected),
150 $this->brutallyTrimHTML($html)
151 );
152 }

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

158 {
159 $r = $this->getDefaultRenderer();
160 $html = $r->render($node);
161
162 $expected = <<<EOT
163 <li id="" class="il-tree-node node-simple" role="treeitem">
164 <span class="node-line">
165 <span class="node-label">
166 <img class="icon small" src="./templates/default/images/icon_default.svg" alt=""/>
167 label
168 </span>
169 </span>
170 </li>
171EOT;
172
173 $this->assertEquals(
174 $this->brutallyTrimHTML($expected),
175 $this->brutallyTrimHTML($html)
176 );
177 }

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: