ILIAS  release_7 Revision v7.30-3-g800a261c036
ModeInfoTest.php
Go to the documentation of this file.
1<?php
2
7
8require_once("libs/composer/vendor/autoload.php");
9require_once(__DIR__ . "/../../Base.php");
10
17{
18
22 private $sig_gen;
23
24
25 public function setUp() : void
26 {
27 parent::setUp();
28 $this->sig_gen = new SignalGenerator();
29 }
30
31
32 public function testRendering()
33 {
34 $mode_title = 'That\'s one small step for [a] man';
35 $uri_string = 'http://one_giant_leap?for=mankind';
36 $mode_info = new ModeInfo($mode_title, new URI($uri_string));
37
38 $r = $this->getDefaultRenderer();
39 $html = $r->render($mode_info);
40
41 $expected = <<<EOT
42 <div class="il-mode-info">
43 <span class="il-mode-info-content">$mode_title<a class="glyph" href="$uri_string" aria-label="close"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a>
44 </span>
45 </div>
46EOT;
47
48 $this->assertEquals(
49 $this->brutallyTrimHTML($expected),
50 $this->brutallyTrimHTML($html)
51 );
52 }
53
54
55 public function testData()
56 {
57 $mode_title = 'That\'s one small step for [a] man';
58 $uri_string = 'http://one_giant_leap?for=mankind';
59
60 $mode_info = $this->getUIFactory()->mainControls()->modeInfo($mode_title, new URI($uri_string));
61
62 $this->assertInstanceOf(\ILIAS\UI\Component\MainControls\ModeInfo::class, $mode_info);
63 $this->assertEquals($mode_title, $mode_info->getModeTitle());
64 $this->assertEquals($uri_string, $mode_info->getCloseAction()->getBaseURI() . '?' . $mode_info->getCloseAction()->getQuery());
65 }
66
67
68 public function getUIFactory()
69 {
70 $factory = new class() extends NoUIFactory {
71
75 public function __construct()
76 {
77 $this->sig_gen = new SignalGenerator();
78 }
79
80
81 public function symbol() : ILIAS\UI\Component\Symbol\Factory
82 {
83 return new Factory(
84 new \ILIAS\UI\Implementation\Component\Symbol\Icon\Factory(),
85 new \ILIAS\UI\Implementation\Component\Symbol\Glyph\Factory(),
86 new \ILIAS\UI\Implementation\Component\Symbol\Avatar\Factory()
87 );
88 }
89
90
91 public function mainControls() : \ILIAS\UI\Component\MainControls\Factory
92 {
93 return new \ILIAS\UI\Implementation\Component\MainControls\Factory(
94 $this->sig_gen,
95 new \ILIAS\UI\Implementation\Component\MainControls\Slate\Factory(
96 $this->sig_gen,
97 new \ILIAS\UI\Implementation\Component\Counter\Factory(),
98 $this->symbol()
99 )
100 );
101 }
102 };
103 $factory->sig_gen = $this->sig_gen;
104
105 return $factory;
106 }
107}
An exception for terminatinating execution or to throw for unit testing.
Builds a Color from either hex- or rgb values.
Definition: Factory.php:14
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:18
Provides common functionality for UI tests.
Definition: Base.php:263
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
Class ModeInfoTest.
$factory
Definition: metadata.php:58
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.