ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
SimpleNodeTest Class Reference

Tests for the SimpleNode. More...

+ Inheritance diagram for SimpleNodeTest:
+ Collaboration diagram for SimpleNodeTest:

Public Member Functions

 setUp ()
 
 brutallyTrimHTML (string $html)
 
 testConstruction ()
 
 testWrongConstruction ()
 
 testConstructionWithIcon ()
 
 testConstructionWithIconAndDifferentLabels ()
 
 testGetDifferentLabels (C\Tree\Node\Simple $node)
 
 testGetLabel (C\Tree\Node\Simple $node)
 
 testGetIcon (C\Tree\Node\Simple $node)
 
 testDefaultAsyncLoading (C\Tree\Node\Simple $node)
 
 testWithAsyncURL (C\Tree\Node\Simple $node)
 
 testRendering (C\Tree\Node\Simple $node)
 
 testRenderingWithAsync (C\Tree\Node\Simple $node)
 
 testRenderingWithIcon (C\Tree\Node\Simple $node)
 
 testRenderingWithIconAndAltAttribute (C\Tree\Node\Simple $node)
 This test is successfull if the icon label differs from the node label. More...
 

Private Attributes

I Tree Node Factory $node_factory
 
C Symbol Icon Standard $icon
 

Detailed Description

Tests for the SimpleNode.

Definition at line 30 of file SimpleNodeTest.php.

Member Function Documentation

◆ brutallyTrimHTML()

SimpleNodeTest::brutallyTrimHTML ( string  $html)

Definition at line 42 of file SimpleNodeTest.php.

Referenced by testRendering(), testRenderingWithAsync(), testRenderingWithIcon(), and testRenderingWithIconAndAltAttribute().

42  : string
43  {
44  $html = str_replace(["\n", "\r", "\t"], "", $html);
45  $html = preg_replace('# {2,}#', " ", $html);
46  return trim($html);
47  }
+ Here is the caller graph for this function:

◆ setUp()

SimpleNodeTest::setUp ( )

Definition at line 35 of file SimpleNodeTest.php.

35  : void
36  {
37  $this->node_factory = new I\Tree\Node\Factory();
38  $icon_factory = new I\Symbol\Icon\Factory();
39  $this->icon = $icon_factory->standard("", '');
40  }

◆ testConstruction()

SimpleNodeTest::testConstruction ( )

Definition at line 49 of file SimpleNodeTest.php.

49  : C\Tree\Node\Simple
50  {
51  $node = $this->node_factory->simple('simple');
52  $this->assertInstanceOf(
53  "ILIAS\\UI\\Component\\Tree\\Node\\Simple",
54  $node
55  );
56  return $node;
57  }

◆ testConstructionWithIcon()

SimpleNodeTest::testConstructionWithIcon ( )

Definition at line 65 of file SimpleNodeTest.php.

65  : C\Tree\Node\Simple
66  {
67  $node = $this->node_factory->simple('label', $this->icon);
68  $this->assertInstanceOf(
69  "ILIAS\\UI\\Component\\Tree\\Node\\Simple",
70  $node
71  );
72  return $node;
73  }

◆ testConstructionWithIconAndDifferentLabels()

SimpleNodeTest::testConstructionWithIconAndDifferentLabels ( )

Definition at line 74 of file SimpleNodeTest.php.

74  : C\Tree\Node\Simple
75  {
76  $this->icon->setLabel('Different Icon Label');
77  $node = $this->node_factory->simple('label', $this->icon);
78  $this->assertInstanceOf(
79  "ILIAS\\UI\\Component\\Tree\\Node\\Simple",
80  $node
81  );
82  return $node;
83  }

◆ testDefaultAsyncLoading()

SimpleNodeTest::testDefaultAsyncLoading ( C\Tree\Node\Simple  $node)

Definition at line 105 of file SimpleNodeTest.php.

105  : void
106  {
107  $this->assertFalse($node->getAsyncLoading());
108  }

◆ testGetDifferentLabels()

SimpleNodeTest::testGetDifferentLabels ( C\Tree\Node\Simple  $node)

Definition at line 86 of file SimpleNodeTest.php.

86  : void
87  {
88  $this->assertNotEquals($this->icon->getLabel(), $node->getLabel());
89  }

◆ testGetIcon()

SimpleNodeTest::testGetIcon ( C\Tree\Node\Simple  $node)

Definition at line 98 of file SimpleNodeTest.php.

98  : C\Tree\Node\Simple
99  {
100  $this->assertEquals($this->icon, $node->getIcon());
101  return $node;
102  }

◆ testGetLabel()

SimpleNodeTest::testGetLabel ( C\Tree\Node\Simple  $node)

Definition at line 92 of file SimpleNodeTest.php.

92  : void
93  {
94  $this->assertEquals("label", $node->getLabel());
95  }

◆ testRendering()

SimpleNodeTest::testRendering ( C\Tree\Node\Simple  $node)

Definition at line 121 of file SimpleNodeTest.php.

References $r, brutallyTrimHTML(), and ILIAS\UI\examples\MainControls\SystemInfo\simple().

121  : void
122  {
123  $r = $this->getDefaultRenderer();
124  $html = $r->render($node);
125 
126  $expected = <<<EOT
127  <li class="c-tree__node c-tree__node--simple" role="treeitem">
128  <span class="c-tree__node__line">
129  <span class="c-tree__node__label">simple</span>
130  </span>
131  </li>
132 EOT;
133 
134  $this->assertEquals(
135  $this->brutallyTrimHTML($expected),
136  $this->brutallyTrimHTML($html)
137  );
138  }
simple()
description: > This example show how the UI-Elements itself looks like.
Definition: simple.php:37
brutallyTrimHTML(string $html)
$r
+ Here is the call graph for this function:

◆ testRenderingWithAsync()

SimpleNodeTest::testRenderingWithAsync ( C\Tree\Node\Simple  $node)

Definition at line 141 of file SimpleNodeTest.php.

References $r, brutallyTrimHTML(), and ILIAS\UI\examples\MainControls\SystemInfo\simple().

141  : void
142  {
143  $r = $this->getDefaultRenderer();
144  $html = $r->render($node);
145 
146  $expected = <<<EOT
147  <li class="c-tree__node c-tree__node--simple expandable"
148  role="treeitem" aria-expanded="false"
149  data-async_url="something.de" data-async_loaded="false">
150  <span class="c-tree__node__line">
151  <span class="c-tree__node__label">simple</span>
152  </span>
153  <ul role="group"></ul>
154  </li>
155 EOT;
156 
157  $this->assertEquals(
158  $this->brutallyTrimHTML($expected),
159  $this->brutallyTrimHTML($html)
160  );
161  }
simple()
description: > This example show how the UI-Elements itself looks like.
Definition: simple.php:37
brutallyTrimHTML(string $html)
$r
+ Here is the call graph for this function:

◆ testRenderingWithIcon()

SimpleNodeTest::testRenderingWithIcon ( C\Tree\Node\Simple  $node)

Definition at line 164 of file SimpleNodeTest.php.

References $r, and brutallyTrimHTML().

164  : void
165  {
166  $r = $this->getDefaultRenderer();
167  $html = $r->render($node);
168 
169  $expected = <<<EOT
170  <li class="c-tree__node c-tree__node--simple" role="treeitem">
171  <span class="c-tree__node__line">
172  <span class="c-tree__node__label">
173  <img class="icon small" src="./assets/images/standard/icon_default.svg" alt=""/>
174  label
175  </span>
176  </span>
177  </li>
178 EOT;
179 
180  $this->assertEquals(
181  $this->brutallyTrimHTML($expected),
182  $this->brutallyTrimHTML($html)
183  );
184  }
brutallyTrimHTML(string $html)
$r
+ Here is the call graph for this function:

◆ testRenderingWithIconAndAltAttribute()

SimpleNodeTest::testRenderingWithIconAndAltAttribute ( C\Tree\Node\Simple  $node)

This test is successfull if the icon label differs from the node label.

As a result the alt attribute will get the icon's label as content. Else the alt attribute will be empty (see testRenderingWithIcon).

Definition at line 191 of file SimpleNodeTest.php.

References $r, and brutallyTrimHTML().

191  : void
192  {
193  $r = $this->getDefaultRenderer();
194  $html = $r->render($node);
195 
196  $expected = <<<EOT
197  <li class="c-tree__node c-tree__node--simple" role="treeitem">
198  <span class="c-tree__node__line">
199  <span class="c-tree__node__label">
200  <img class="icon small" src="./assets/images/standard/icon_default.svg" alt="Different Icon Label"/>
201  label
202  </span>
203  </span>
204  </li>
205 EOT;
206 
207  $this->assertEquals(
208  $this->brutallyTrimHTML($expected),
209  $this->brutallyTrimHTML($html)
210  );
211  }
brutallyTrimHTML(string $html)
$r
+ Here is the call graph for this function:

◆ testWithAsyncURL()

SimpleNodeTest::testWithAsyncURL ( C\Tree\Node\Simple  $node)

Definition at line 111 of file SimpleNodeTest.php.

References $url.

111  : C\Tree\Node\Simple
112  {
113  $url = 'something.de';
114  $node = $node->withAsyncURL($url);
115  $this->assertTrue($node->getAsyncLoading());
116  $this->assertEquals($url, $node->getAsyncURL());
117  return $node;
118  }
$url
Definition: shib_logout.php:68

◆ testWrongConstruction()

SimpleNodeTest::testWrongConstruction ( )

Definition at line 59 of file SimpleNodeTest.php.

59  : void
60  {
61  $this->expectException(ArgumentCountError::class);
62  $this->node_factory->simple();
63  }

Field Documentation

◆ $icon

C Symbol Icon Standard SimpleNodeTest::$icon
private

Definition at line 33 of file SimpleNodeTest.php.

◆ $node_factory

I Tree Node Factory SimpleNodeTest::$node_factory
private

Definition at line 32 of file SimpleNodeTest.php.


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