ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
FooterTest.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2019 Nils Haagen <nils.haagen@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4 
5 require_once("libs/composer/vendor/autoload.php");
6 require_once(__DIR__ . "/../../Base.php");
7 
8 use \ILIAS\UI\Component as C;
9 use \ILIAS\UI\Implementation\Component as I;
10 
15 {
16  public function setUp() : void
17  {
18  $f = new I\Link\Factory();
19  $this->links = [
20  $f->standard("Goto ILIAS", "http://www.ilias.de"),
21  $f->standard("go up", "#")
22  ];
23  $this->text = 'footer text';
24  $this->perm_url = 'http://www.ilias.de/goto.php?target=xxx_123';
25  }
26 
27  protected function getFactory()
28  {
29  $sig_gen = new I\SignalGenerator();
30  $sig_gen = new I\SignalGenerator();
31  $counter_factory = new I\Counter\Factory();
32  $slate_factory = new I\MainControls\Slate\Factory(
33  $sig_gen,
34  $counter_factory,
35  new I\Symbol\Factory(
36  new I\Symbol\Icon\Factory(),
37  new I\Symbol\Glyph\Factory(),
38  new I\Symbol\Avatar\Factory()
39  )
40  );
41  $factory = new I\MainControls\Factory($sig_gen, $slate_factory);
42  return $factory;
43  }
44 
45  public function testConstruction()
46  {
47  $footer = $this->getFactory()->footer($this->links, $this->text);
48  $this->assertInstanceOf(
49  "ILIAS\\UI\\Component\\MainControls\\Footer",
50  $footer
51  );
52  return $footer;
53  }
54 
55  public function testConstructionNoLinks()
56  {
57  $footer = $this->getFactory()->footer([], $this->text);
58  $this->assertInstanceOf(
59  "ILIAS\\UI\\Component\\MainControls\\Footer",
60  $footer
61  );
62  return $footer;
63  }
64 
68  public function testGetLinks($footer)
69  {
70  $this->assertEquals(
71  $this->links,
72  $footer->getLinks()
73  );
74  }
75 
79  public function testGetText($footer)
80  {
81  $this->assertEquals(
82  $this->text,
83  $footer->getText()
84  );
85  }
86 
90  public function testPermanentURL($footer)
91  {
92  $df = new \ILIAS\Data\Factory();
93  $footer = $footer->withPermanentURL($df->uri($this->perm_url));
94  $perm_url = $footer->getPermanentURL();
95  $this->assertInstanceOf("\\ILIAS\\Data\\URI", $perm_url);
96  $this->assertEquals(
97  $perm_url->getBaseURI() . '?' . $perm_url->getQuery(),
98  $this->perm_url
99  );
100  return $footer;
101  }
102 
103  public function getUIFactory()
104  {
105  $factory = new class extends NoUIFactory {
106  public function listing()
107  {
108  return new I\Listing\Factory();
109  }
110  };
111  return $factory;
112  }
113 
117  public function testRendering($footer)
118  {
119  $r = $this->getDefaultRenderer();
120  $html = $r->render($footer);
121 
122  $expected = <<<EOT
123  <div class="il-maincontrols-footer">
124  <div class="il-footer-content">
125  <div class="il-footer-text">
126  footer text
127  </div>
128 
129  <div class="il-footer-links">
130  <ul>
131  <li><a href="http://www.ilias.de" >Goto ILIAS</a></li>
132  <li><a href="#" >go up</a></li>
133  </ul>
134  </div>
135  </div>
136  </div>
137 EOT;
138 
139  $this->assertEquals(
140  $this->brutallyTrimHTML($expected),
141  $this->brutallyTrimHTML($html)
142  );
143  }
144 
148  public function testRenderingNoLinks($footer)
149  {
150  $r = $this->getDefaultRenderer();
151  $html = $r->render($footer);
152 
153  $expected = <<<EOT
154  <div class="il-maincontrols-footer">
155  <div class="il-footer-content">
156  <div class="il-footer-text">
157  footer text
158  </div>
159  </div>
160  </div>
161 EOT;
162 
163  $this->assertEquals(
164  $this->brutallyTrimHTML($expected),
165  $this->brutallyTrimHTML($html)
166  );
167  }
168 
172  public function testRenderingPermUrl($footer)
173  {
174  $r = $this->getDefaultRenderer();
175  $html = $r->render($footer);
176 
177  $expected = <<<EOT
178  <div class="il-maincontrols-footer">
179  <div class="il-footer-content">
180  <div class="il-footer-permanent-url"><label for="current_perma_link">perma_link</label><input id="current_perma_link" type="text" value="http://www.ilias.de/goto.php?target=xxx_123" readonly="readOnly">
181  </div>
182 
183  <div class="il-footer-text">footer text</div>
184 
185  <div class="il-footer-links">
186  <ul>
187  <li><a href="http://www.ilias.de" >Goto ILIAS</a></li>
188  <li><a href="#" >go up</a></li>
189  </ul>
190  </div>
191  </div>
192  </div>
193 EOT;
194 
195  $this->assertEquals(
196  $this->brutallyTrimHTML($expected),
197  $this->brutallyTrimHTML($html)
198  );
199  }
200 }
testGetText($footer)
testConstruction
Definition: FooterTest.php:79
testRendering($footer)
testConstruction
Definition: FooterTest.php:117
testGetLinks($footer)
testConstruction
Definition: FooterTest.php:68
Class ChatMainBarProvider .
up()
Definition: up.php:2
Tests for the Footer.
Definition: FooterTest.php:14
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
testRenderingPermUrl($footer)
testPermanentURL
Definition: FooterTest.php:172
testConstructionNoLinks()
Definition: FooterTest.php:55
Provides common functionality for UI tests.
Definition: Base.php:224
testRenderingNoLinks($footer)
testConstructionNoLinks
Definition: FooterTest.php:148
testConstruction()
Definition: FooterTest.php:45
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:346
testPermanentURL($footer)
testConstruction
Definition: FooterTest.php:90
$factory
Definition: metadata.php:58