ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ModeInfoTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25
26require_once("vendor/composer/vendor/autoload.php");
27require_once(__DIR__ . "/../../Base.php");
28
34class ModeInfoTest extends ILIAS_UI_TestBase
35{
36 private SignalGenerator $sig_gen;
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="c-mode-info__pageframe"></div>
56 <div class="c-mode-info">
57 <div class="c-mode-info__content">
58 <div class="c-mode-info__label">$mode_title</div>
59
60 <div class="c-mode-info__close">
61 <a tabindex="0" class="glyph" href="$uri_string" aria-label="close"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a>
62 </div>
63
64 </div>
65 </div>
66 <div class="c-mode-info__mobile-padding"></div>
67 EOT;
68
69 $this->assertEquals(
70 $this->brutallyTrimHTML($expected),
71 $this->brutallyTrimHTML($html)
72 );
73 }
74
75 public function testData(): void
76 {
77 $mode_title = 'That\'s one small step for [a] man';
78 $uri_string = 'http://one_giant_leap?for=mankind';
79
80 $mode_info = $this->getUIFactory()->mainControls()->modeInfo($mode_title, new URI($uri_string));
81
82 $this->assertInstanceOf(\ILIAS\UI\Component\MainControls\ModeInfo::class, $mode_info);
83 $this->assertEquals($mode_title, $mode_info->getModeTitle());
84 $this->assertEquals(
85 $uri_string,
86 $mode_info->getCloseAction()->getBaseURI() . '?' . $mode_info->getCloseAction()->getQuery()
87 );
88 }
89
90 public function getUIFactory(): NoUIFactory
91 {
92 $factory = new class () extends NoUIFactory {
93 public SignalGenerator $sig_gen;
94
95 public function __construct()
96 {
97 $this->sig_gen = new SignalGenerator();
98 }
99
100 public function symbol(): ILIAS\UI\Implementation\Component\Symbol\Factory
101 {
102 return new Factory(
103 new \ILIAS\UI\Implementation\Component\Symbol\Icon\Factory(),
104 new \ILIAS\UI\Implementation\Component\Symbol\Glyph\Factory(),
105 new \ILIAS\UI\Implementation\Component\Symbol\Avatar\Factory()
106 );
107 }
108
109 public function mainControls(): \ILIAS\UI\Implementation\Component\MainControls\Factory
110 {
111 return new \ILIAS\UI\Implementation\Component\MainControls\Factory(
112 $this->sig_gen,
113 new \ILIAS\UI\Implementation\Component\MainControls\Slate\Factory(
114 $this->sig_gen,
115 new \ILIAS\UI\Implementation\Component\Counter\Factory(),
116 $this->symbol()
117 )
118 );
119 }
120 };
121 $factory->sig_gen = $this->sig_gen;
122
123 return $factory;
124 }
125}
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:337
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.