ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
MessageBoxTest Class Reference

Test on Message Box implementation. More...

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

Public Member Functions

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

Static Public Attributes

static $canonical_css_classes
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 

Detailed Description

Test on Message Box implementation.

Definition at line 14 of file MessageBoxTest.php.

Member Function Documentation

◆ getButtonFactory()

MessageBoxTest::getButtonFactory ( )

Definition at line 20 of file MessageBoxTest.php.

21 {
22 return new \ILIAS\UI\Implementation\Component\Button\Factory();
23 }

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

+ Here is the caller graph for this function:

◆ getLinkFactory()

MessageBoxTest::getLinkFactory ( )

Definition at line 24 of file MessageBoxTest.php.

25 {
26 return new \ILIAS\UI\Implementation\Component\Link\Factory();
27 }

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

+ Here is the caller graph for this function:

◆ getMessageBoxFactory()

MessageBoxTest::getMessageBoxFactory ( )

Definition at line 16 of file MessageBoxTest.php.

17 {
18 return new \ILIAS\UI\Implementation\Component\MessageBox\Factory();
19 }

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().

+ Here is the caller graph for this function:

◆ getUIFactory()

MessageBoxTest::getUIFactory ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 44 of file MessageBoxTest.php.

45 {
46 $factory = new class extends NoUIFactory {
47 public function listing()
48 {
49 return new IC\Listing\Factory();
50 }
51 };
52 return $factory;
53 }
$factory
Definition: metadata.php:58

References $factory.

◆ messagebox_type_provider()

MessageBoxTest::messagebox_type_provider ( )

Definition at line 29 of file MessageBoxTest.php.

30 {
31 return array( array(C\MessageBox\MessageBox::FAILURE)
32 , array(C\MessageBox\MessageBox::SUCCESS)
33 , array(C\MessageBox\MessageBox::INFO)
34 , array(C\MessageBox\MessageBox::CONFIRMATION)
35 );
36 }

◆ test_implements_factory_interface()

MessageBoxTest::test_implements_factory_interface (   $factory_method)

@dataProvider messagebox_type_provider

Definition at line 58 of file MessageBoxTest.php.

59 {
60 $f = $this->getMessageBoxFactory();
61
62 $this->assertInstanceOf("ILIAS\\UI\\Component\\MessageBox\\Factory", $f);
63 $this->assertInstanceOf("ILIAS\\UI\\Component\\MessageBox\\MessageBox", $f->$factory_method("Lorem ipsum dolor sit amet."));
64 }

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

+ Here is the call graph for this function:

◆ test_messagebox_messagetext()

MessageBoxTest::test_messagebox_messagetext (   $factory_method)

@dataProvider messagebox_type_provider

Definition at line 81 of file MessageBoxTest.php.

82 {
83 $f = $this->getMessageBoxFactory();
84 $g = $f->$factory_method("Lorem ipsum dolor sit amet.");
85
86 $this->assertNotNull($g);
87 $this->assertEquals("Lorem ipsum dolor sit amet.", $g->getMessageText());
88 }

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

+ Here is the call graph for this function:

◆ test_messagebox_types()

MessageBoxTest::test_messagebox_types (   $factory_method)

@dataProvider messagebox_type_provider

Definition at line 69 of file MessageBoxTest.php.

70 {
71 $f = $this->getMessageBoxFactory();
72 $g = $f->$factory_method("Lorem ipsum dolor sit amet.");
73
74 $this->assertNotNull($g);
75 $this->assertEquals($factory_method, $g->getType());
76 }

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

+ Here is the call graph for this function:

◆ test_render_simple()

MessageBoxTest::test_render_simple (   $factory_method)

@dataProvider messagebox_type_provider

Definition at line 149 of file MessageBoxTest.php.

150 {
151 $f = $this->getMessageBoxFactory();
152 $r = $this->getDefaultRenderer();
153 $g = $f->$factory_method("Lorem ipsum dolor sit amet.");
154 $css_classes = self::$canonical_css_classes[$factory_method];
155
156 $html = $this->normalizeHTML($r->render($g));
157 $expected = "<div class=\"alert $css_classes\" role=\"alert\">" .
158 "<h5 class=\"ilAccHeadingHidden\"><a id=\"il_message_focus\" name=\"il_message_focus\">" .
159 $g->getType() . "_message</a></h5>Lorem ipsum dolor sit amet.</div>";
160 $this->assertHTMLEquals($expected, $html);
161 }
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317

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

+ Here is the call graph for this function:

◆ test_render_with_buttons()

MessageBoxTest::test_render_with_buttons (   $factory_method)

@dataProvider messagebox_type_provider

Definition at line 166 of file MessageBoxTest.php.

167 {
168 $f = $this->getMessageBoxFactory();
169 $bf = $this->getButtonFactory();
170 $r = $this->getDefaultRenderer();
171 $css_classes = self::$canonical_css_classes[$factory_method];
172
173 $buttons = [$bf->standard("Confirm", "#"), $bf->standard("Cancel", "#")];
174
175 $g = $f->$factory_method("Lorem ipsum dolor sit amet.")->withButtons($buttons);
176
177 $html = $this->normalizeHTML($r->render($g));
178 $expected = "<div class=\"alert $css_classes\" role=\"alert\">" .
179 "<h5 class=\"ilAccHeadingHidden\"><a id=\"il_message_focus\" name=\"il_message_focus\">" .
180 $g->getType() . "_message</a></h5>Lorem ipsum dolor sit amet." .
181 "<div><button class=\"btn btn-default\" data-action=\"#\" id=\"id_1\">Confirm</button>" .
182 "<button class=\"btn btn-default\" data-action=\"#\" id=\"id_2\">Cancel</button></div></div>";
183 $this->assertHTMLEquals($expected, $html);
184 }

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

+ Here is the call graph for this function:

◆ test_render_with_buttons_and_links()

MessageBoxTest::test_render_with_buttons_and_links (   $factory_method)

@dataProvider messagebox_type_provider

Definition at line 215 of file MessageBoxTest.php.

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

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

+ Here is the call graph for this function:

◆ test_render_with_links()

MessageBoxTest::test_render_with_links (   $factory_method)

@dataProvider messagebox_type_provider

Definition at line 189 of file MessageBoxTest.php.

190 {
191 $f = $this->getMessageBoxFactory();
192 $lf = $this->getLinkFactory();
193 $r = $this->getDefaultRenderer();
194 $css_classes = self::$canonical_css_classes[$factory_method];
195
196 $links = [
197 $lf->standard("Open Exercise Assignment", "#"),
198 $lf->standard("Open other screen", "#"),
199 ];
200
201 $g = $f->$factory_method("Lorem ipsum dolor sit amet.")->withLinks($links);
202
203 $html = $this->normalizeHTML($r->render($g));
204 $expected = "<div class=\"alert $css_classes\" role=\"alert\">" .
205 "<h5 class=\"ilAccHeadingHidden\"><a id=\"il_message_focus\" name=\"il_message_focus\">" .
206 $g->getType() . "_message</a></h5>Lorem ipsum dolor sit amet." .
207 "<ul><li><a href=\"#\" >Open Exercise Assignment</a></li>" .
208 "<li><a href=\"#\" >Open other screen</a></li></ul></div>";
209 $this->assertHTMLEquals($expected, $html);
210 }

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

+ Here is the call graph for this function:

◆ test_with_buttons()

MessageBoxTest::test_with_buttons (   $factory_method)

@dataProvider messagebox_type_provider

Definition at line 93 of file MessageBoxTest.php.

94 {
95 $f = $this->getMessageBoxFactory();
96 $bf = $this->getButtonFactory();
97 $g = $f->$factory_method("Lorem ipsum dolor sit amet.");
98
99 $buttons = [$bf->standard("Confirm", "#"), $bf->standard("Cancel", "#")];
100 $g2 = $g->withButtons($buttons);
101
102 $this->assertFalse(count($g->getButtons()) > 0);
103 $this->assertTrue(count($g2->getButtons()) > 0);
104 }

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

+ Here is the call graph for this function:

◆ test_with_buttons_and_links()

MessageBoxTest::test_with_buttons_and_links (   $factory_method)

@dataProvider messagebox_type_provider

Definition at line 128 of file MessageBoxTest.php.

129 {
130 $f = $this->getMessageBoxFactory();
131 $bf = $this->getButtonFactory();
132 $lf = $this->getLinkFactory();
133 $g = $f->$factory_method("Lorem ipsum dolor sit amet.");
134
135 $buttons = [$bf->standard("Confirm", "#"), $bf->standard("Cancel", "#")];
136 $links = [
137 $lf->standard("Open Exercise Assignment", "#"),
138 $lf->standard("Open other screen", "#"),
139 ];
140 $g2 = $g->withButtons($buttons)->withLinks($links);
141
142 $this->assertFalse(count($g->getButtons()) > 0 && count($g->getLinks()) > 0);
143 $this->assertTrue(count($g2->getButtons()) > 0 && count($g2->getLinks()) > 0);
144 }

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

+ Here is the call graph for this function:

◆ test_with_links()

MessageBoxTest::test_with_links (   $factory_method)

@dataProvider messagebox_type_provider

Definition at line 109 of file MessageBoxTest.php.

110 {
111 $f = $this->getMessageBoxFactory();
112 $lf = $this->getLinkFactory();
113 $g = $f->$factory_method("Lorem ipsum dolor sit amet.");
114
115 $links = [
116 $lf->standard("Open Exercise Assignment", "#"),
117 $lf->standard("Open other screen", "#"),
118 ];
119 $g2 = $g->withLinks($links);
120
121 $this->assertFalse(count($g->getLinks()) > 0);
122 $this->assertTrue(count($g2->getLinks()) > 0);
123 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $canonical_css_classes

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 38 of file MessageBoxTest.php.


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