ILIAS  release_8 Revision v8.24
ExpandableTreeTest Class Reference

Tests for the Expandable Tree. More...

+ Inheritance diagram for ExpandableTreeTest:
+ Collaboration diagram for ExpandableTreeTest:

Public Member Functions

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

 getInnerTreePart ()
 
- 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

C Tree Tree $tree
 

Detailed Description

Tests for the Expandable Tree.

Definition at line 66 of file ExpandableTreeTest.php.

Member Function Documentation

◆ brutallyTrimHTML()

ExpandableTreeTest::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 95 of file ExpandableTreeTest.php.

95 : string
96 {
97 $html = str_replace(["\n", "\r", "\t"], "", $html);
98 $html = preg_replace('# {2,}#', " ", $html);
99 return trim($html);
100 }

Referenced by testRendering(), and testRenderingAsSubTree().

+ Here is the caller graph for this function:

◆ getInnerTreePart()

ExpandableTreeTest::getInnerTreePart ( )
protected

Definition at line 128 of file ExpandableTreeTest.php.

128 : string
129 {
130 return '<li id="" class="il-tree-node node-simple expandable" role="treeitem" aria-expanded="false">
131 <span class="node-line"><span class="node-label">1</span></span>
132
133 <ul role="group">
134 <li id="" class="il-tree-node node-simple" role="treeitem">
135 <span class="node-line"><span class="node-label">1.1</span></span>
136 </li>
137 <li id="" class="il-tree-node node-simple expandable" role="treeitem" aria-expanded="false">
138 <span class="node-line"><span class="node-label">1.2</span></span>
139
140 <ul role="group">
141 <li id="" class="il-tree-node node-simple" role="treeitem">
142 <span class="node-line"><span class="node-label">1.2.1</span></span>
143 </li>
144 </ul>
145 </li>
146 </ul>
147 </li>
148 <li id="" class="il-tree-node node-simple" role="treeitem">
149 <span class="node-line"><span class="node-label">2</span></span>
150 </li>';
151 }

Referenced by testRendering(), and testRenderingAsSubTree().

+ Here is the caller graph for this function:

◆ getUIFactory()

ExpandableTreeTest::getUIFactory ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 70 of file ExpandableTreeTest.php.

71 {
72 return new class () extends NoUIFactory {
73 public function tree(): C\Tree\Factory
74 {
75 return new I\Tree\Factory();
76 }
77 };
78 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Referenced by setUp().

+ Here is the caller graph for this function:

◆ setUp()

ExpandableTreeTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 80 of file ExpandableTreeTest.php.

80 : void
81 {
82 $n11 = new DataNode('1.1');
83 $n12 = new DataNode('1.2', array(new DataNode('1.2.1')));
84 $n1 = new DataNode('1', [$n11, $n12]);
85 $n2 = new DataNode('2');
86 $data = [$n1, $n2];
87
88 $label = "label";
89 $recursion = new Recursion();
90 $f = $this->getUIFactory();
91 $this->tree = $f->tree()->expandable($label, $recursion)
92 ->withData($data);
93 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $data, Vendor\Package\$f, and getUIFactory().

+ Here is the call graph for this function:

◆ testRendering()

ExpandableTreeTest::testRendering ( )

Definition at line 102 of file ExpandableTreeTest.php.

102 : void
103 {
104 $r = $this->getDefaultRenderer();
105 $html = $r->render($this->tree);
106
107 $expected = '<ul id="id_1" class="il-tree" role="tree" aria-label="label">' . $this->getInnerTreePart() . '</ul>';
108
109 $this->assertEquals(
110 $this->brutallyTrimHTML($expected),
111 $this->brutallyTrimHTML($html)
112 );
113 }
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355

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

+ Here is the call graph for this function:

◆ testRenderingAsSubTree()

ExpandableTreeTest::testRenderingAsSubTree ( )

Definition at line 115 of file ExpandableTreeTest.php.

115 : void
116 {
117 $r = $this->getDefaultRenderer();
118 $html = $r->render($this->tree->withIsSubTree(true));
119
120 $expected = $this->getInnerTreePart();
121
122 $this->assertEquals(
123 $this->brutallyTrimHTML($expected),
124 $this->brutallyTrimHTML($html)
125 );
126 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $tree

C Tree Tree ExpandableTreeTest::$tree
protected

Definition at line 68 of file ExpandableTreeTest.php.


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