ILIAS  release_8 Revision v8.24
BylineNodeTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21require_once("libs/composer/vendor/autoload.php");
22require_once(__DIR__ . "../../../../Base.php");
23
26
31{
32 private I\Tree\Node\Factory $node_factory;
34
35 public function setUp(): 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 }
41
42 public function testCreateBylineNode(): void
43 {
44 $node = $this->node_factory->bylined('My Label', 'This is my byline', $this->icon);
45 $this->assertEquals('My Label', $node->getLabel());
46 $this->assertEquals('This is my byline', $node->getByline());
47 $this->assertEquals($this->icon, $node->getIcon());
48 }
49
50 public function testRendering(): void
51 {
52 $node = $this->node_factory->bylined('My Label', 'This is my byline');
53
54 $r = $this->getDefaultRenderer();
55 $html = $r->render($node);
56
57 $expected = <<<EOT
58 <li id="" class="il-tree-node node-simple" role="treeitem">
59 <span class="node-line">
60 <span class="node-label">My Label</span>
61 <span class="node-byline">This is my byline</span>
62 </span>
63 </li>
64EOT;
65
66 $this->assertEquals(
67 $this->brutallyTrimHTML($expected),
68 $this->brutallyTrimHTML($html)
69 );
70 }
71
72 public function testRenderingWithIcon(): void
73 {
74 $node = $this->node_factory->bylined('My Label', 'This is my byline', $this->icon);
75
76 $r = $this->getDefaultRenderer();
77 $html = $r->render($node);
78
79 $expected = <<<EOT
80 <li id="" class="il-tree-node node-simple" role="treeitem">
81 <span class="node-line">
82 <span class="node-label">
83 <img class="icon small" src="./templates/default/images/icon_default.svg" alt=""/>
84 My Label
85 </span>
86 <span class="node-byline">This is my byline</span>
87 </span>
88 </li>
89EOT;
90
91 $this->assertEquals(
92 $this->brutallyTrimHTML($expected),
93 $this->brutallyTrimHTML($html)
94 );
95 }
96
97 public function testRenderingWithAsync(): void
98 {
99 $node = $this->node_factory->bylined('My Label', 'This is my byline');
100 $node = $node->withAsyncURL('something.de');
101
102 $r = $this->getDefaultRenderer();
103 $html = $r->render($node);
104
105 $expected = <<<EOT
106 <li id=""
107 class="il-tree-node node-simple expandable"
108 role="treeitem" aria-expanded="false"
109 data-async_url="something.de" data-async_loaded="false">
110 <span class="node-line">
111 <span class="node-label">My Label</span>
112 <span class="node-byline">This is my byline</span>
113 </span>
114 <ul role="group"></ul>
115 </li>
116EOT;
117
118 $this->assertEquals(
119 $this->brutallyTrimHTML($expected),
120 $this->brutallyTrimHTML($html)
121 );
122 }
123
124 public function testRenderingExpanded(): void
125 {
126 $node = $this->node_factory->bylined('My Label', 'This is my byline');
127 $node = $node->withAsyncURL('something.de')->withExpanded(true);
128
129 $r = $this->getDefaultRenderer();
130 $html = $r->render($node);
131
132 $expected = <<<EOT
133 <li id=""
134 class="il-tree-node node-simple expandable"
135 role="treeitem" aria-expanded="true"
136 data-async_url="something.de" data-async_loaded="false">
137 <span class="node-line">
138 <span class="node-label">My Label</span>
139 <span class="node-byline">This is my byline</span>
140 </span>
141 <ul role="group"></ul>
142 </li>
143EOT;
144
145 $this->assertEquals(
146 $this->brutallyTrimHTML($expected),
147 $this->brutallyTrimHTML($html)
148 );
149 }
150}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
I Tree Node Factory $node_factory
C Symbol Icon Standard $icon
Provides common functionality for UI tests.
Definition: Base.php:299
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:444
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...