ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 ()
 
- 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 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().

+ 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 = <<<EOT
88 <ul id="id_1" class="il-tree" role="tree" aria-label="label">
89 <li id="" class="il-tree-node node-simple expandable" role="treeitem" aria-expanded="false">
90 <span class="node-line"><span class="node-label">1</span></span>
91
92 <ul role="group">
93 <li id="" class="il-tree-node node-simple" role="none">
94 <span class="node-line"><span class="node-label">1.1</span></span>
95 </li>
96 <li id="" class="il-tree-node node-simple expandable" role="treeitem" aria-expanded="false">
97 <span class="node-line"><span class="node-label">1.2</span></span>
98
99 <ul role="group">
100 <li id="" class="il-tree-node node-simple" role="none">
101 <span class="node-line"><span class="node-label">1.2.1</span></span>
102 </li>
103 </ul>
104 </li>
105 </ul>
106 </li>
107 <li id="" class="il-tree-node node-simple" role="none">
108 <span class="node-line"><span class="node-label">2</span></span>
109 </li>
110 </ul>
111EOT;
112
113 $this->assertEquals(
114 $this->brutallyTrimHTML($expected),
115 $this->brutallyTrimHTML($html)
116 );
117 }
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268

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

+ Here is the call graph for this function:

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