ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Static Public Attributes

static $canonical_css_classes
 

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 return new \ILIAS\UI\Implementation\Factory(
47 $this->createMock(C\Counter\Factory::class),
48 $this->createMock(C\Glyph\Factory::class),
49 $this->createMock(C\Button\Factory::class),
50 new IC\Listing\Factory(),
51 $this->createMock(C\Image\Factory::class),
52 $this->createMock(C\Panel\Factory::class),
53 $this->createMock(C\Modal\Factory::class),
54 $this->createMock(C\Dropzone\Factory::class),
55 $this->createMock(C\Popover\Factory::class),
56 $this->createMock(C\Divider\Factory::class),
57 $this->createMock(C\Link\Factory::class),
58 $this->createMock(C\Dropdown\Factory::class),
59 $this->createMock(C\Item\Factory::class),
60 $this->createMock(C\Icon\Factory::class),
61 $this->createMock(C\ViewControl\Factory::class),
62 $this->createMock(C\Chart\Factory::class),
63 $this->createMock(C\Input\Factory::class),
64 $this->createMock(C\Table\Factory::class),
65 $this->createMock(C\MessageBox\Factory::class),
66 $this->createMock(C\Card\Factory::class)
67 );
68 }

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

75 {
76 $f = $this->getMessageBoxFactory();
77
78 $this->assertInstanceOf("ILIAS\\UI\\Component\\MessageBox\\Factory", $f);
79 $this->assertInstanceOf("ILIAS\\UI\\Component\\MessageBox\\MessageBox", $f->$factory_method("Lorem ipsum dolor sit amet."));
80 }

References $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 97 of file MessageBoxTest.php.

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

References $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 85 of file MessageBoxTest.php.

86 {
87 $f = $this->getMessageBoxFactory();
88 $g = $f->$factory_method("Lorem ipsum dolor sit amet.");
89
90 $this->assertNotNull($g);
91 $this->assertEquals($factory_method, $g->getType());
92 }

References $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 165 of file MessageBoxTest.php.

166 {
167 $f = $this->getMessageBoxFactory();
168 $r = $this->getDefaultRenderer();
169 $g = $f->$factory_method("Lorem ipsum dolor sit amet.");
170 $css_classes = self::$canonical_css_classes[$factory_method];
171
172 $html = $this->normalizeHTML($r->render($g));
173 $expected = "<div class=\"alert $css_classes\" role=\"alert\">" .
174 "<h5 class=\"ilAccHeadingHidden\"><a id=\"il_message_focus\" name=\"il_message_focus\">" .
175 $g->getType() . "_message</a></h5>Lorem ipsum dolor sit amet.</div>";
176 $this->assertHTMLEquals($expected, $html);
177 }
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
$html
Definition: example_001.php:87
$r
Definition: example_031.php:79

References $f, $html, $r, 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 182 of file MessageBoxTest.php.

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

References $f, $html, $r, 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 231 of file MessageBoxTest.php.

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

References $f, $html, $links, $r, 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 205 of file MessageBoxTest.php.

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

References $f, $html, $links, $r, 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 109 of file MessageBoxTest.php.

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

References $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 144 of file MessageBoxTest.php.

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

References $f, $links, 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 125 of file MessageBoxTest.php.

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

References $f, $links, 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: