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

Tests for the Expandable Tree. More...

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

Public Member Functions

 getUIFactory ()
 
 setUp ()
 
 brutallyTrimHTML ($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 ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Protected Member Functions

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

Detailed Description

Tests for the Expandable Tree.

Definition at line 47 of file ExpandableTreeTest.php.

Member Function Documentation

◆ brutallyTrimHTML()

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

76 {
77 $html = str_replace(["\n", "\r", "\t"], "", $html);
78 $html = preg_replace('# {2,}#', " ", $html);
79 return trim($html);
80 }

Referenced by testRendering(), and testRenderingAsSubTree().

+ Here is the caller graph for this function:

◆ getInnerTreePart()

ExpandableTreeTest::getInnerTreePart ( )
protected

Definition at line 108 of file ExpandableTreeTest.php.

109 {
110 return '<li id="" class="il-tree-node node-simple expandable" role="treeitem" aria-expanded="false">
111 <span class="node-line"><span class="node-label">1</span></span>
112
113 <ul role="group">
114 <li id="" class="il-tree-node node-simple" role="treeitem">
115 <span class="node-line"><span class="node-label">1.1</span></span>
116 </li>
117 <li id="" class="il-tree-node node-simple expandable" role="treeitem" aria-expanded="false">
118 <span class="node-line"><span class="node-label">1.2</span></span>
119
120 <ul role="group">
121 <li id="" class="il-tree-node node-simple" role="treeitem">
122 <span class="node-line"><span class="node-label">1.2.1</span></span>
123 </li>
124 </ul>
125 </li>
126 </ul>
127 </li>
128 <li id="" class="il-tree-node node-simple" role="treeitem">
129 <span class="node-line"><span class="node-label">2</span></span>
130 </li>';
131 }

Referenced by testRendering(), and testRenderingAsSubTree().

+ Here is the caller graph for this function:

◆ getUIFactory()

ExpandableTreeTest::getUIFactory ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 49 of file ExpandableTreeTest.php.

50 {
51 $factory = new class extends NoUIFactory {
52 public function tree()
53 {
54 return new I\Tree\Factory();
55 }
56 };
57 return $factory;
58 }
$factory
Definition: metadata.php:58

References $factory.

Referenced by setUp().

+ Here is the caller graph for this function:

◆ setUp()

ExpandableTreeTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 60 of file ExpandableTreeTest.php.

60 : void
61 {
62 $n11 = new DataNode('1.1');
63 $n12 = new DataNode('1.2', array(new DataNode('1.2.1')));
64 $n1 = new DataNode('1', [$n11, $n12]);
65 $n2 = new DataNode('2');
66 $data = [$n1, $n2];
67
68 $label = "label";
69 $recursion = new Recursion();
70 $f = $this->getUIFactory();
71 $this->tree = $f->tree()->expandable($label, $recursion)
72 ->withData($data);
73 }
$data
Definition: storeScorm.php:23

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

+ Here is the call graph for this function:

◆ testRendering()

ExpandableTreeTest::testRendering ( )

Definition at line 82 of file ExpandableTreeTest.php.

83 {
84 $r = $this->getDefaultRenderer();
85 $html = $r->render($this->tree);
86
87 $expected = '<ul id="id_1" class="il-tree" role="tree" aria-label="label">' . $this->getInnerTreePart() . '</ul>';
88
89 $this->assertEquals(
90 $this->brutallyTrimHTML($expected),
91 $this->brutallyTrimHTML($html)
92 );
93 }
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311

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

+ Here is the call graph for this function:

◆ testRenderingAsSubTree()

ExpandableTreeTest::testRenderingAsSubTree ( )

Definition at line 95 of file ExpandableTreeTest.php.

96 {
97 $r = $this->getDefaultRenderer();
98 $html = $r->render($this->tree->withIsSubTree(true));
99
100 $expected = $this->getInnerTreePart();
101
102 $this->assertEquals(
103 $this->brutallyTrimHTML($expected),
104 $this->brutallyTrimHTML($html)
105 );
106 }

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

+ Here is the call graph for this function:

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