ILIAS  release_8 Revision v8.24
ModeInfoTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
25
26require_once("libs/composer/vendor/autoload.php");
27require_once(__DIR__ . "/../../Base.php");
28
35{
37
38
39 public function setUp(): void
40 {
41 parent::setUp();
42 $this->sig_gen = new SignalGenerator();
43 }
44
45 public function testRendering(): void
46 {
47 $mode_title = 'That\'s one small step for [a] man';
48 $uri_string = 'http://one_giant_leap?for=mankind';
49 $mode_info = new ModeInfo($mode_title, new URI($uri_string));
50
51 $r = $this->getDefaultRenderer();
52 $html = $r->render($mode_info);
53
54 $expected = <<<EOT
55 <div class="il-mode-info">
56 <span class="il-mode-info-content">$mode_title<a tabindex="0" class="glyph" href="$uri_string" aria-label="close"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a>
57 </span>
58 </div>
59EOT;
60
61 $this->assertEquals(
62 $this->brutallyTrimHTML($expected),
63 $this->brutallyTrimHTML($html)
64 );
65 }
66
67 public function testData(): void
68 {
69 $mode_title = 'That\'s one small step for [a] man';
70 $uri_string = 'http://one_giant_leap?for=mankind';
71
72 $mode_info = $this->getUIFactory()->mainControls()->modeInfo($mode_title, new URI($uri_string));
73
74 $this->assertInstanceOf(\ILIAS\UI\Component\MainControls\ModeInfo::class, $mode_info);
75 $this->assertEquals($mode_title, $mode_info->getModeTitle());
76 $this->assertEquals(
77 $uri_string,
78 $mode_info->getCloseAction()->getBaseURI() . '?' . $mode_info->getCloseAction()->getQuery()
79 );
80 }
81
82 public function getUIFactory(): NoUIFactory
83 {
84 $factory = new class () extends NoUIFactory {
86
87 public function __construct()
88 {
89 $this->sig_gen = new SignalGenerator();
90 }
91
92 public function symbol(): ILIAS\UI\Component\Symbol\Factory
93 {
94 return new Factory(
95 new \ILIAS\UI\Implementation\Component\Symbol\Icon\Factory(),
96 new \ILIAS\UI\Implementation\Component\Symbol\Glyph\Factory(),
97 new \ILIAS\UI\Implementation\Component\Symbol\Avatar\Factory()
98 );
99 }
100
101 public function mainControls(): \ILIAS\UI\Component\MainControls\Factory
102 {
103 return new \ILIAS\UI\Implementation\Component\MainControls\Factory(
104 $this->sig_gen,
105 new \ILIAS\UI\Implementation\Component\MainControls\Slate\Factory(
106 $this->sig_gen,
107 new \ILIAS\UI\Implementation\Component\Counter\Factory(),
108 $this->symbol()
109 )
110 );
111 }
112 };
113 $factory->sig_gen = $this->sig_gen;
114
115 return $factory;
116 }
117}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:17
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
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
Class ModeInfoTest.
SignalGenerator $sig_gen
$factory
Definition: metadata.php:75
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.