ILIAS  release_8 Revision v8.23
MessageBoxTest Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 getMessageBoxFactory ()
 
 getButtonFactory ()
 
 getLinkFactory ()
 
 messagebox_type_provider ()
 
 getUIFactory ()
 
 test_implements_factory_interface (string $factory_method)
 messagebox_type_provider More...
 
 test_messagebox_types (string $factory_method)
 messagebox_type_provider More...
 
 test_messagebox_messagetext (string $factory_method)
 messagebox_type_provider More...
 
 test_with_buttons (string $factory_method)
 messagebox_type_provider More...
 
 test_with_links (string $factory_method)
 messagebox_type_provider More...
 
 test_with_buttons_and_links (string $factory_method)
 messagebox_type_provider More...
 
 test_render_simple (string $factory_method)
 messagebox_type_provider More...
 
 test_render_with_buttons (string $factory_method)
 messagebox_type_provider More...
 
 test_render_with_links (string $factory_method)
 messagebox_type_provider More...
 
 test_render_with_buttons_and_links (string $factory_method)
 messagebox_type_provider More...
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML (string $html)
 
 assertHTMLEquals (string $expected_html_as_string, string $html_as_string)
 

Static Public Attributes

static array $canonical_css_classes
 
static array $canonical_role_types
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML (string $html)
 A more radical version of normalizeHTML. More...
 
 brutallyTrimSignals (string $html)
 A naive replacement of all il_signal-ids with dots to ease comparisons of rendered output. More...
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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.

Referenced by test_render_with_buttons(), test_render_with_buttons_and_links(), test_with_buttons(), and test_with_buttons_and_links().

36  : IC\Button\Factory
37  {
38  return new IC\Button\Factory();
39  }
+ Here is the caller graph for this function:

◆ getLinkFactory()

MessageBoxTest::getLinkFactory ( )

Definition at line 40 of file MessageBoxTest.php.

Referenced by test_render_with_buttons_and_links(), test_render_with_links(), test_with_buttons_and_links(), and test_with_links().

40  : IC\Link\Factory
41  {
42  return new IC\Link\Factory();
43  }
+ Here is the caller graph for this function:

◆ getMessageBoxFactory()

MessageBoxTest::getMessageBoxFactory ( )

Definition at line 32 of file MessageBoxTest.php.

Referenced by test_implements_factory_interface(), test_messagebox_messagetext(), test_messagebox_types(), test_render_simple(), test_render_with_buttons(), test_render_with_buttons_and_links(), test_render_with_links(), test_with_buttons(), test_with_buttons_and_links(), and test_with_links().

32  : IC\MessageBox\Factory
33  {
34  return new IC\MessageBox\Factory();
35  }
+ Here is the caller graph for this function:

◆ getUIFactory()

MessageBoxTest::getUIFactory ( )

Definition at line 66 of file MessageBoxTest.php.

66  : NoUIFactory
67  {
68  return new class () extends NoUIFactory {
69  public function listing(): IC\Listing\Factory
70  {
71  return new IC\Listing\Factory();
72  }
73  };
74  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ messagebox_type_provider()

MessageBoxTest::messagebox_type_provider ( )

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  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ test_implements_factory_interface()

MessageBoxTest::test_implements_factory_interface ( string  $factory_method)

messagebox_type_provider

Definition at line 79 of file MessageBoxTest.php.

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

79  : void
80  {
81  $f = $this->getMessageBoxFactory();
82 
83  $this->assertInstanceOf("ILIAS\\UI\\Component\\MessageBox\\Factory", $f);
84  $this->assertInstanceOf("ILIAS\\UI\\Component\\MessageBox\\MessageBox", $f->$factory_method("Lorem ipsum dolor sit amet."));
85  }
+ Here is the call graph for this function:

◆ test_messagebox_messagetext()

MessageBoxTest::test_messagebox_messagetext ( string  $factory_method)

messagebox_type_provider

Definition at line 102 of file MessageBoxTest.php.

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

102  : void
103  {
104  $f = $this->getMessageBoxFactory();
105  $g = $f->$factory_method("Lorem ipsum dolor sit amet.");
106 
107  $this->assertNotNull($g);
108  $this->assertEquals("Lorem ipsum dolor sit amet.", $g->getMessageText());
109  }
+ Here is the call graph for this function:

◆ test_messagebox_types()

MessageBoxTest::test_messagebox_types ( string  $factory_method)

messagebox_type_provider

Definition at line 90 of file MessageBoxTest.php.

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

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  }
+ Here is the call graph for this function:

◆ test_render_simple()

MessageBoxTest::test_render_simple ( string  $factory_method)

messagebox_type_provider

Definition at line 170 of file MessageBoxTest.php.

References Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\getDefaultRenderer(), getMessageBoxFactory(), and ILIAS_UI_TestBase\normalizeHTML().

170  : void
171  {
172  $f = $this->getMessageBoxFactory();
173  $r = $this->getDefaultRenderer();
174  $g = $f->$factory_method("Lorem ipsum dolor sit amet.");
175  $css_classes = self::$canonical_css_classes[$factory_method];
176  $role_type = self::$canonical_role_types[$factory_method];
177 
178  $html = $this->normalizeHTML($r->render($g));
179  $expected = "<div class=\"alert $css_classes\" role=\"$role_type\">" .
180  "<div class=\"ilAccHeadingHidden\"><a id=\"il_message_focus\" name=\"il_message_focus\">" .
181  $g->getType() . "_message</a></div>Lorem ipsum dolor sit amet.</div>";
182  $this->assertHTMLEquals($expected, $html);
183  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
normalizeHTML(string $html)
Definition: Base.php:422
+ Here is the call graph for this function:

◆ test_render_with_buttons()

MessageBoxTest::test_render_with_buttons ( string  $factory_method)

messagebox_type_provider

Definition at line 188 of file MessageBoxTest.php.

References Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), getButtonFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), getMessageBoxFactory(), and ILIAS_UI_TestBase\normalizeHTML().

188  : void
189  {
190  $f = $this->getMessageBoxFactory();
191  $bf = $this->getButtonFactory();
192  $r = $this->getDefaultRenderer();
193  $css_classes = self::$canonical_css_classes[$factory_method];
194  $role_type = self::$canonical_role_types[$factory_method];
195 
196  $buttons = [$bf->standard("Confirm", "#"), $bf->standard("Cancel", "#")];
197 
198  $g = $f->$factory_method("Lorem ipsum dolor sit amet.")->withButtons($buttons);
199 
200  $html = $this->normalizeHTML($r->render($g));
201  $expected = "<div class=\"alert $css_classes\" role=\"$role_type\">" .
202  "<div class=\"ilAccHeadingHidden\"><a id=\"il_message_focus\" name=\"il_message_focus\">" .
203  $g->getType() . "_message</a></div>Lorem ipsum dolor sit amet." .
204  "<div><button class=\"btn btn-default\" data-action=\"#\" id=\"id_1\">Confirm</button>" .
205  "<button class=\"btn btn-default\" data-action=\"#\" id=\"id_2\">Cancel</button></div></div>";
206  $this->assertHTMLEquals($expected, $html);
207  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
normalizeHTML(string $html)
Definition: Base.php:422
+ Here is the call graph for this function:

◆ test_render_with_buttons_and_links()

MessageBoxTest::test_render_with_buttons_and_links ( string  $factory_method)

messagebox_type_provider

Definition at line 239 of file MessageBoxTest.php.

References Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), getButtonFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), getLinkFactory(), getMessageBoxFactory(), and ILIAS_UI_TestBase\normalizeHTML().

239  : void
240  {
241  $f = $this->getMessageBoxFactory();
242  $bf = $this->getButtonFactory();
243  $lf = $this->getLinkFactory();
244  $r = $this->getDefaultRenderer();
245  $css_classes = self::$canonical_css_classes[$factory_method];
246  $role_type = self::$canonical_role_types[$factory_method];
247 
248  $buttons = [$bf->standard("Confirm", "#"), $bf->standard("Cancel", "#")];
249  $links = [
250  $lf->standard("Open Exercise Assignment", "#"),
251  $lf->standard("Open other screen", "#"),
252  ];
253 
254  $g = $f->$factory_method("Lorem ipsum dolor sit amet.")->withButtons($buttons)->withLinks($links);
255 
256  $html = $this->normalizeHTML($r->render($g));
257  $expected = "<div class=\"alert $css_classes\" role=\"$role_type\">" .
258  "<div class=\"ilAccHeadingHidden\"><a id=\"il_message_focus\" name=\"il_message_focus\">" .
259  $g->getType() . "_message</a></div>Lorem ipsum dolor sit amet." .
260  "<div><button class=\"btn btn-default\" data-action=\"#\" id=\"id_1\">Confirm</button>" .
261  "<button class=\"btn btn-default\" data-action=\"#\" id=\"id_2\">Cancel</button></div>" .
262  "<ul><li><a href=\"#\" >Open Exercise Assignment</a></li>" .
263  "<li><a href=\"#\" >Open other screen</a></li></ul></div>";
264  $this->assertHTMLEquals($expected, $html);
265  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
normalizeHTML(string $html)
Definition: Base.php:422
+ Here is the call graph for this function:

◆ test_render_with_links()

MessageBoxTest::test_render_with_links ( string  $factory_method)

messagebox_type_provider

Definition at line 212 of file MessageBoxTest.php.

References Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\getDefaultRenderer(), getLinkFactory(), getMessageBoxFactory(), and ILIAS_UI_TestBase\normalizeHTML().

212  : void
213  {
214  $f = $this->getMessageBoxFactory();
215  $lf = $this->getLinkFactory();
216  $r = $this->getDefaultRenderer();
217  $css_classes = self::$canonical_css_classes[$factory_method];
218  $role_type = self::$canonical_role_types[$factory_method];
219 
220  $links = [
221  $lf->standard("Open Exercise Assignment", "#"),
222  $lf->standard("Open other screen", "#"),
223  ];
224 
225  $g = $f->$factory_method("Lorem ipsum dolor sit amet.")->withLinks($links);
226 
227  $html = $this->normalizeHTML($r->render($g));
228  $expected = "<div class=\"alert $css_classes\" role=\"$role_type\">" .
229  "<div class=\"ilAccHeadingHidden\"><a id=\"il_message_focus\" name=\"il_message_focus\">" .
230  $g->getType() . "_message</a></div>Lorem ipsum dolor sit amet." .
231  "<ul><li><a href=\"#\" >Open Exercise Assignment</a></li>" .
232  "<li><a href=\"#\" >Open other screen</a></li></ul></div>";
233  $this->assertHTMLEquals($expected, $html);
234  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
normalizeHTML(string $html)
Definition: Base.php:422
+ Here is the call graph for this function:

◆ test_with_buttons()

MessageBoxTest::test_with_buttons ( string  $factory_method)

messagebox_type_provider

Definition at line 114 of file MessageBoxTest.php.

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

114  : void
115  {
116  $f = $this->getMessageBoxFactory();
117  $bf = $this->getButtonFactory();
118  $g = $f->$factory_method("Lorem ipsum dolor sit amet.");
119 
120  $buttons = [$bf->standard("Confirm", "#"), $bf->standard("Cancel", "#")];
121  $g2 = $g->withButtons($buttons);
122 
123  $this->assertEmpty($g->getButtons());
124  $this->assertNotEmpty($g2->getButtons());
125  }
+ Here is the call graph for this function:

◆ test_with_buttons_and_links()

MessageBoxTest::test_with_buttons_and_links ( string  $factory_method)

messagebox_type_provider

Definition at line 149 of file MessageBoxTest.php.

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

149  : void
150  {
151  $f = $this->getMessageBoxFactory();
152  $bf = $this->getButtonFactory();
153  $lf = $this->getLinkFactory();
154  $g = $f->$factory_method("Lorem ipsum dolor sit amet.");
155 
156  $buttons = [$bf->standard("Confirm", "#"), $bf->standard("Cancel", "#")];
157  $links = [
158  $lf->standard("Open Exercise Assignment", "#"),
159  $lf->standard("Open other screen", "#"),
160  ];
161  $g2 = $g->withButtons($buttons)->withLinks($links);
162 
163  $this->assertFalse(count($g->getButtons()) > 0 && count($g->getLinks()) > 0);
164  $this->assertTrue(count($g2->getButtons()) > 0 && count($g2->getLinks()) > 0);
165  }
+ Here is the call graph for this function:

◆ test_with_links()

MessageBoxTest::test_with_links ( string  $factory_method)

messagebox_type_provider

Definition at line 130 of file MessageBoxTest.php.

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

130  : void
131  {
132  $f = $this->getMessageBoxFactory();
133  $lf = $this->getLinkFactory();
134  $g = $f->$factory_method("Lorem ipsum dolor sit amet.");
135 
136  $links = [
137  $lf->standard("Open Exercise Assignment", "#"),
138  $lf->standard("Open other screen", "#"),
139  ];
140  $g2 = $g->withLinks($links);
141 
142  $this->assertEmpty($g->getLinks());
143  $this->assertNotEmpty($g2->getLinks());
144  }
+ 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: