ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
MessageBoxTest Class Reference

Test on Message Box implementation. More...

+ Inheritance diagram for MessageBoxTest:
+ Collaboration diagram for MessageBoxTest:

Public Member Functions

 getMessageBoxFactory ()
 
 getButtonFactory ()
 
 getLinkFactory ()
 
 getUIFactory ()
 
 testImplementsFactoryInterface (string $factory_method)
 
 testMessageboxTypes (string $factory_method)
 
 testMessageboxMessagetext (string $factory_method)
 
 testWithButtons (string $factory_method)
 
 testWithLinks (string $factory_method)
 
 testWithButtonsAndLinks (string $factory_method)
 
 testRenderSimple (string $factory_method)
 
 testRenderWithButtons (string $factory_method)
 
 testRenderWithLinks (string $factory_method)
 
 testRenderWithButtonsAndLinks (string $factory_method)
 

Static Public Member Functions

static getMessageboxTypeProvider ()
 

Static Public Attributes

static array $canonical_css_classes
 
static array $canonical_role_types
 

Detailed Description

Test on Message Box implementation.

Definition at line 30 of file MessageBoxTest.php.

Member Function Documentation

◆ getButtonFactory()

MessageBoxTest::getButtonFactory ( )

Definition at line 36 of file MessageBoxTest.php.

36 : IC\Button\Factory
37 {
38 return new IC\Button\Factory();
39 }

Referenced by testRenderWithButtons(), testRenderWithButtonsAndLinks(), testWithButtons(), and testWithButtonsAndLinks().

+ Here is the caller graph for this function:

◆ getLinkFactory()

MessageBoxTest::getLinkFactory ( )

Definition at line 40 of file MessageBoxTest.php.

40 : IC\Link\Factory
41 {
42 return new IC\Link\Factory();
43 }

Referenced by testRenderWithButtonsAndLinks(), testRenderWithLinks(), testWithButtonsAndLinks(), and testWithLinks().

+ Here is the caller graph for this function:

◆ getMessageBoxFactory()

MessageBoxTest::getMessageBoxFactory ( )

Definition at line 32 of file MessageBoxTest.php.

32 : IC\MessageBox\Factory
33 {
34 return new IC\MessageBox\Factory();
35 }

Referenced by testImplementsFactoryInterface(), testMessageboxMessagetext(), testMessageboxTypes(), testRenderSimple(), testRenderWithButtons(), testRenderWithButtonsAndLinks(), testRenderWithLinks(), testWithButtons(), testWithButtonsAndLinks(), and testWithLinks().

+ Here is the caller graph for this function:

◆ getMessageboxTypeProvider()

static MessageBoxTest::getMessageboxTypeProvider ( )
static

Definition at line 45 of file MessageBoxTest.php.

45 : array
46 {
47 return array( array(C\MessageBox\MessageBox::FAILURE)
48 , array(C\MessageBox\MessageBox::SUCCESS)
49 , array(C\MessageBox\MessageBox::INFO)
50 , array(C\MessageBox\MessageBox::CONFIRMATION)
51 );
52 }
@ FAILURE
The progress of the process/task cannot be calculated (yet), but it has started processing.
Definition: Status.php:42

References ILIAS\UI\Implementation\Component\Progress\State\Bar\FAILURE.

◆ getUIFactory()

MessageBoxTest::getUIFactory ( )

Definition at line 66 of file MessageBoxTest.php.

67 {
68 return new class () extends NoUIFactory {
69 public function listing(): IC\Listing\Factory
70 {
71 return new IC\Listing\Factory(
72 new IC\Listing\Workflow\Factory(),
73 new IC\Listing\CharacteristicValue\Factory(),
74 new IC\Listing\Entity\Factory(),
75 );
76 }
77 };
78 }

References ILIAS\Repository\listing().

+ Here is the call graph for this function:

◆ testImplementsFactoryInterface()

MessageBoxTest::testImplementsFactoryInterface ( string  $factory_method)

Definition at line 81 of file MessageBoxTest.php.

81 : void
82 {
83 $f = $this->getMessageBoxFactory();
84
85 $this->assertInstanceOf("ILIAS\\UI\\Component\\MessageBox\\Factory", $f);
86 $this->assertInstanceOf("ILIAS\\UI\\Component\\MessageBox\\MessageBox", $f->$factory_method("Lorem ipsum dolor sit amet."));
87 }

References Vendor\Package\$f, and getMessageBoxFactory().

+ Here is the call graph for this function:

◆ testMessageboxMessagetext()

MessageBoxTest::testMessageboxMessagetext ( string  $factory_method)

Definition at line 100 of file MessageBoxTest.php.

100 : void
101 {
102 $f = $this->getMessageBoxFactory();
103 $g = $f->$factory_method("Lorem ipsum dolor sit amet.");
104
105 $this->assertNotNull($g);
106 $this->assertEquals("Lorem ipsum dolor sit amet.", $g->getMessageText());
107 }

References Vendor\Package\$f, and getMessageBoxFactory().

+ Here is the call graph for this function:

◆ testMessageboxTypes()

MessageBoxTest::testMessageboxTypes ( string  $factory_method)

Definition at line 90 of file MessageBoxTest.php.

90 : void
91 {
92 $f = $this->getMessageBoxFactory();
93 $g = $f->$factory_method("Lorem ipsum dolor sit amet.");
94
95 $this->assertNotNull($g);
96 $this->assertEquals($factory_method, $g->getType());
97 }

References Vendor\Package\$f, and getMessageBoxFactory().

+ Here is the call graph for this function:

◆ testRenderSimple()

MessageBoxTest::testRenderSimple ( string  $factory_method)

Definition at line 160 of file MessageBoxTest.php.

160 : void
161 {
162 $f = $this->getMessageBoxFactory();
163 $r = $this->getDefaultRenderer();
164 $g = $f->$factory_method("Lorem ipsum dolor sit amet.");
165 $css_classes = self::$canonical_css_classes[$factory_method];
166 $role_type = self::$canonical_role_types[$factory_method];
167
168 $html = $this->normalizeHTML($r->render($g));
169 $expected = "<div class=\"alert $css_classes\" role=\"$role_type\">" .
170 "<div class=\"ilAccHeadingHidden\"><a name=\"il_message_focus\">" .
171 $g->getType() . "_message</a></div>Lorem ipsum dolor sit amet.</div>";
172 $this->assertHTMLEquals($expected, $html);
173 }

References Vendor\Package\$f, and getMessageBoxFactory().

+ Here is the call graph for this function:

◆ testRenderWithButtons()

MessageBoxTest::testRenderWithButtons ( string  $factory_method)

Definition at line 176 of file MessageBoxTest.php.

176 : void
177 {
178 $f = $this->getMessageBoxFactory();
179 $bf = $this->getButtonFactory();
180 $r = $this->getDefaultRenderer();
181 $css_classes = self::$canonical_css_classes[$factory_method];
182 $role_type = self::$canonical_role_types[$factory_method];
183
184 $buttons = [$bf->standard("Confirm", "#"), $bf->standard("Cancel", "#")];
185
186 $g = $f->$factory_method("Lorem ipsum dolor sit amet.")->withButtons($buttons);
187
188 $html = $this->normalizeHTML($r->render($g));
189 $expected = "<div class=\"alert $css_classes\" role=\"$role_type\">" .
190 "<div class=\"ilAccHeadingHidden\"><a name=\"il_message_focus\">" .
191 $g->getType() . "_message</a></div>Lorem ipsum dolor sit amet." .
192 "<div><button class=\"btn btn-default\" data-action=\"#\" id=\"id_1\">Confirm</button>" .
193 "<button class=\"btn btn-default\" data-action=\"#\" id=\"id_2\">Cancel</button></div></div>";
194 $this->assertHTMLEquals($expected, $html);
195 }

References Vendor\Package\$f, getButtonFactory(), and getMessageBoxFactory().

+ Here is the call graph for this function:

◆ testRenderWithButtonsAndLinks()

MessageBoxTest::testRenderWithButtonsAndLinks ( string  $factory_method)

Definition at line 223 of file MessageBoxTest.php.

223 : void
224 {
225 $f = $this->getMessageBoxFactory();
226 $bf = $this->getButtonFactory();
227 $lf = $this->getLinkFactory();
228 $r = $this->getDefaultRenderer();
229 $css_classes = self::$canonical_css_classes[$factory_method];
230 $role_type = self::$canonical_role_types[$factory_method];
231
232 $buttons = [$bf->standard("Confirm", "#"), $bf->standard("Cancel", "#")];
233 $links = [
234 $lf->standard("Open Exercise Assignment", "#"),
235 $lf->standard("Open other screen", "#"),
236 ];
237
238 $g = $f->$factory_method("Lorem ipsum dolor sit amet.")->withButtons($buttons)->withLinks($links);
239
240 $html = $this->normalizeHTML($r->render($g));
241 $expected = "<div class=\"alert $css_classes\" role=\"$role_type\">" .
242 "<div class=\"ilAccHeadingHidden\"><a name=\"il_message_focus\">" .
243 $g->getType() . "_message</a></div>Lorem ipsum dolor sit amet." .
244 "<div><button class=\"btn btn-default\" data-action=\"#\" id=\"id_1\">Confirm</button>" .
245 "<button class=\"btn btn-default\" data-action=\"#\" id=\"id_2\">Cancel</button></div>" .
246 "<ul><li><a href=\"#\" >Open Exercise Assignment</a></li>" .
247 "<li><a href=\"#\" >Open other screen</a></li></ul></div>";
248 $this->assertHTMLEquals($expected, $html);
249 }

References Vendor\Package\$f, getButtonFactory(), getLinkFactory(), and getMessageBoxFactory().

+ Here is the call graph for this function:

◆ testRenderWithLinks()

MessageBoxTest::testRenderWithLinks ( string  $factory_method)

Definition at line 198 of file MessageBoxTest.php.

198 : void
199 {
200 $f = $this->getMessageBoxFactory();
201 $lf = $this->getLinkFactory();
202 $r = $this->getDefaultRenderer();
203 $css_classes = self::$canonical_css_classes[$factory_method];
204 $role_type = self::$canonical_role_types[$factory_method];
205
206 $links = [
207 $lf->standard("Open Exercise Assignment", "#"),
208 $lf->standard("Open other screen", "#"),
209 ];
210
211 $g = $f->$factory_method("Lorem ipsum dolor sit amet.")->withLinks($links);
212
213 $html = $this->normalizeHTML($r->render($g));
214 $expected = "<div class=\"alert $css_classes\" role=\"$role_type\">" .
215 "<div class=\"ilAccHeadingHidden\"><a name=\"il_message_focus\">" .
216 $g->getType() . "_message</a></div>Lorem ipsum dolor sit amet." .
217 "<ul><li><a href=\"#\" >Open Exercise Assignment</a></li>" .
218 "<li><a href=\"#\" >Open other screen</a></li></ul></div>";
219 $this->assertHTMLEquals($expected, $html);
220 }

References Vendor\Package\$f, getLinkFactory(), and getMessageBoxFactory().

+ Here is the call graph for this function:

◆ testWithButtons()

MessageBoxTest::testWithButtons ( string  $factory_method)

Definition at line 110 of file MessageBoxTest.php.

110 : void
111 {
112 $f = $this->getMessageBoxFactory();
113 $bf = $this->getButtonFactory();
114 $g = $f->$factory_method("Lorem ipsum dolor sit amet.");
115
116 $buttons = [$bf->standard("Confirm", "#"), $bf->standard("Cancel", "#")];
117 $g2 = $g->withButtons($buttons);
118
119 $this->assertEmpty($g->getButtons());
120 $this->assertNotEmpty($g2->getButtons());
121 }

References Vendor\Package\$f, getButtonFactory(), and getMessageBoxFactory().

+ Here is the call graph for this function:

◆ testWithButtonsAndLinks()

MessageBoxTest::testWithButtonsAndLinks ( string  $factory_method)

Definition at line 141 of file MessageBoxTest.php.

141 : void
142 {
143 $f = $this->getMessageBoxFactory();
144 $bf = $this->getButtonFactory();
145 $lf = $this->getLinkFactory();
146 $g = $f->$factory_method("Lorem ipsum dolor sit amet.");
147
148 $buttons = [$bf->standard("Confirm", "#"), $bf->standard("Cancel", "#")];
149 $links = [
150 $lf->standard("Open Exercise Assignment", "#"),
151 $lf->standard("Open other screen", "#"),
152 ];
153 $g2 = $g->withButtons($buttons)->withLinks($links);
154
155 $this->assertFalse(count($g->getButtons()) > 0 && count($g->getLinks()) > 0);
156 $this->assertTrue(count($g2->getButtons()) > 0 && count($g2->getLinks()) > 0);
157 }

References Vendor\Package\$f, getButtonFactory(), getLinkFactory(), and getMessageBoxFactory().

+ Here is the call graph for this function:

◆ testWithLinks()

MessageBoxTest::testWithLinks ( string  $factory_method)

Definition at line 124 of file MessageBoxTest.php.

124 : void
125 {
126 $f = $this->getMessageBoxFactory();
127 $lf = $this->getLinkFactory();
128 $g = $f->$factory_method("Lorem ipsum dolor sit amet.");
129
130 $links = [
131 $lf->standard("Open Exercise Assignment", "#"),
132 $lf->standard("Open other screen", "#"),
133 ];
134 $g2 = $g->withLinks($links);
135
136 $this->assertEmpty($g->getLinks());
137 $this->assertNotEmpty($g2->getLinks());
138 }

References Vendor\Package\$f, getLinkFactory(), and getMessageBoxFactory().

+ Here is the call graph for this function:

Field Documentation

◆ $canonical_css_classes

array MessageBoxTest::$canonical_css_classes
static
Initial value:
= array( C\MessageBox\MessageBox::FAILURE => "alert-danger"
, C\MessageBox\MessageBox::SUCCESS => "alert-success"
, C\MessageBox\MessageBox::INFO => "alert-info"
, C\MessageBox\MessageBox::CONFIRMATION => "alert-warning"
)

Definition at line 54 of file MessageBoxTest.php.

◆ $canonical_role_types

array MessageBoxTest::$canonical_role_types
static
Initial value:
= array( C\MessageBox\MessageBox::FAILURE => "alert"
, C\MessageBox\MessageBox::SUCCESS => "status"
, C\MessageBox\MessageBox::INFO => "status"
, C\MessageBox\MessageBox::CONFIRMATION => "status"
)

Definition at line 60 of file MessageBoxTest.php.


The documentation for this class was generated from the following file: