ILIAS  trunk Revision v11.0_alpha-1702-gfd3ecb7f852
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)
 
 testRendering ()
 
 testRenderingAsSubTree ()
 

Protected Member Functions

 getInnerTreePart ()
 

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)

Definition at line 97 of file ExpandableTreeTest.php.

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

◆ getInnerTreePart()

ExpandableTreeTest::getInnerTreePart ( )
protected

Definition at line 130 of file ExpandableTreeTest.php.

130  : string
131  {
132  return '<li class="c-tree__node c-tree__node--simple expandable" role="treeitem" aria-expanded="false">
133  <span class="c-tree__node__line"><span class="c-tree__node__label">1</span></span>
134 
135  <ul role="group">
136  <li class="c-tree__node c-tree__node--simple" role="treeitem">
137  <span class="c-tree__node__line"><span class="c-tree__node__label">1.1</span></span>
138  </li>
139  <li class="c-tree__node c-tree__node--simple expandable" role="treeitem" aria-expanded="false">
140  <span class="c-tree__node__line"><span class="c-tree__node__label">1.2</span></span>
141 
142  <ul role="group">
143  <li class="c-tree__node c-tree__node--simple" role="treeitem">
144  <span class="c-tree__node__line"><span class="c-tree__node__label">1.2.1</span></span>
145  </li>
146  </ul>
147  </li>
148  </ul>
149  </li>
150  <li class="c-tree__node c-tree__node--simple" role="treeitem">
151  <span class="c-tree__node__line"><span class="c-tree__node__label">2</span></span>
152  </li>';
153  }

◆ getUIFactory()

ExpandableTreeTest::getUIFactory ( )

Definition at line 70 of file ExpandableTreeTest.php.

70  : NoUIFactory
71  {
72  return new class () extends NoUIFactory {
73  public function tree(): I\Tree\Factory
74  {
75  return new I\Tree\Factory(
76  new I\Tree\Node\Factory(),
77  );
78  }
79  };
80  }

◆ setUp()

ExpandableTreeTest::setUp ( )

Definition at line 82 of file ExpandableTreeTest.php.

References $data, Vendor\Package\$f, and DataNode\$label.

82  : void
83  {
84  $n11 = new DataNode('1.1');
85  $n12 = new DataNode('1.2', array(new DataNode('1.2.1')));
86  $n1 = new DataNode('1', [$n11, $n12]);
87  $n2 = new DataNode('2');
88  $data = [$n1, $n2];
89 
90  $label = "label";
91  $recursion = new Recursion();
92  $f = $this->getUIFactory();
93  $this->tree = $f->tree()->expandable($label, $recursion)
94  ->withData($data);
95  }

◆ testRendering()

ExpandableTreeTest::testRendering ( )

Definition at line 104 of file ExpandableTreeTest.php.

References $r.

104  : void
105  {
106  $r = $this->getDefaultRenderer();
107  $html = $r->render($this->tree);
108 
109  $expected = '<ul id="id_1" class="c-tree" role="tree" aria-label="label">' . $this->getInnerTreePart() . '</ul>';
110 
111  $this->assertEquals(
112  $this->brutallyTrimHTML($expected),
113  $this->brutallyTrimHTML($html)
114  );
115  }
brutallyTrimHTML(string $html)
$r

◆ testRenderingAsSubTree()

ExpandableTreeTest::testRenderingAsSubTree ( )

Definition at line 117 of file ExpandableTreeTest.php.

References $r.

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

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: