ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)
 testConstructionWithIconAndDifferentLabels More...
 
 testGetLabel (C\Tree\Node\Simple $node)
 testConstructionWithIcon More...
 
 testGetIcon (C\Tree\Node\Simple $node)
 testConstructionWithIcon More...
 
 testDefaultAsyncLoading (C\Tree\Node\Simple $node)
 testConstruction More...
 
 testWithAsyncURL (C\Tree\Node\Simple $node)
 testConstruction More...
 
 testRendering (C\Tree\Node\Simple $node)
 testConstruction More...
 
 testRenderingWithAsync (C\Tree\Node\Simple $node)
 testWithAsyncURL More...
 
 testRenderingWithIcon (C\Tree\Node\Simple $node)
 testConstructionWithIcon More...
 
 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)

testConstruction

Definition at line 113 of file SimpleNodeTest.php.

113  : void
114  {
115  $this->assertFalse($node->getAsyncLoading());
116  }

◆ testGetDifferentLabels()

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

testConstructionWithIconAndDifferentLabels

Definition at line 88 of file SimpleNodeTest.php.

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

◆ testGetIcon()

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

testConstructionWithIcon

Definition at line 104 of file SimpleNodeTest.php.

104  : C\Tree\Node\Simple
105  {
106  $this->assertEquals($this->icon, $node->getIcon());
107  return $node;
108  }

◆ testGetLabel()

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

testConstructionWithIcon

Definition at line 96 of file SimpleNodeTest.php.

96  : void
97  {
98  $this->assertEquals("label", $node->getLabel());
99  }

◆ testRendering()

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

testConstruction

Definition at line 133 of file SimpleNodeTest.php.

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

133  : void
134  {
135  $r = $this->getDefaultRenderer();
136  $html = $r->render($node);
137 
138  $expected = <<<EOT
139  <li class="c-tree__node c-tree__node--simple" role="treeitem">
140  <span class="c-tree__node__line">
141  <span class="c-tree__node__label">simple</span>
142  </span>
143  </li>
144 EOT;
145 
146  $this->assertEquals(
147  $this->brutallyTrimHTML($expected),
148  $this->brutallyTrimHTML($html)
149  );
150  }
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)

testWithAsyncURL

Definition at line 155 of file SimpleNodeTest.php.

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

155  : void
156  {
157  $r = $this->getDefaultRenderer();
158  $html = $r->render($node);
159 
160  $expected = <<<EOT
161  <li class="c-tree__node c-tree__node--simple expandable"
162  role="treeitem" aria-expanded="false"
163  data-async_url="something.de" data-async_loaded="false">
164  <span class="c-tree__node__line">
165  <span class="c-tree__node__label">simple</span>
166  </span>
167  <ul role="group"></ul>
168  </li>
169 EOT;
170 
171  $this->assertEquals(
172  $this->brutallyTrimHTML($expected),
173  $this->brutallyTrimHTML($html)
174  );
175  }
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)

testConstructionWithIcon

Definition at line 180 of file SimpleNodeTest.php.

References $r, and brutallyTrimHTML().

180  : void
181  {
182  $r = $this->getDefaultRenderer();
183  $html = $r->render($node);
184 
185  $expected = <<<EOT
186  <li class="c-tree__node c-tree__node--simple" role="treeitem">
187  <span class="c-tree__node__line">
188  <span class="c-tree__node__label">
189  <img class="icon small" src="./assets/images/standard/icon_default.svg" alt=""/>
190  label
191  </span>
192  </span>
193  </li>
194 EOT;
195 
196  $this->assertEquals(
197  $this->brutallyTrimHTML($expected),
198  $this->brutallyTrimHTML($html)
199  );
200  }
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).

testConstructionWithIconAndDifferentLabels

Definition at line 208 of file SimpleNodeTest.php.

References $r, and brutallyTrimHTML().

208  : void
209  {
210  $r = $this->getDefaultRenderer();
211  $html = $r->render($node);
212 
213  $expected = <<<EOT
214  <li class="c-tree__node c-tree__node--simple" role="treeitem">
215  <span class="c-tree__node__line">
216  <span class="c-tree__node__label">
217  <img class="icon small" src="./assets/images/standard/icon_default.svg" alt="Different Icon Label"/>
218  label
219  </span>
220  </span>
221  </li>
222 EOT;
223 
224  $this->assertEquals(
225  $this->brutallyTrimHTML($expected),
226  $this->brutallyTrimHTML($html)
227  );
228  }
brutallyTrimHTML(string $html)
$r
+ Here is the call graph for this function:

◆ testWithAsyncURL()

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

testConstruction

Definition at line 121 of file SimpleNodeTest.php.

References $url.

121  : C\Tree\Node\Simple
122  {
123  $url = 'something.de';
124  $node = $node->withAsyncURL($url);
125  $this->assertTrue($node->getAsyncLoading());
126  $this->assertEquals($url, $node->getAsyncURL());
127  return $node;
128  }
$url
Definition: shib_logout.php:66

◆ 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: