ILIAS  release_8 Revision v8.24
ImageTest Class Reference

Test on button implementation. More...

+ Inheritance diagram for ImageTest:
+ Collaboration diagram for ImageTest:

Public Member Functions

 getImageFactory ()
 
 test_implements_factory_interface ()
 
 test_get_type ()
 
 test_get_source ()
 
 test_get_alt ()
 
 test_set_source ()
 
 test_set_alt ()
 
 test_set_string_action ()
 
 test_set_signal_action ()
 
 test_invalid_source ()
 
 test_invalid_alt ()
 
 test_render_standard ()
 
 test_render_responsive ()
 
 test_render_alt_escaping ()
 
 test_render_with_string_action ()
 
 test_render_with_signal_action ()
 
 test_with_empty_action_and_no_additional_on_load_code ()
 
 test_with_additional_on_load_code ()
 
- 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)
 

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

Test on button implementation.

Definition at line 31 of file ImageTest.php.

Member Function Documentation

◆ getImageFactory()

◆ test_get_alt()

ImageTest::test_get_alt ( )

Definition at line 67 of file ImageTest.php.

67 : void
68 {
69 $f = $this->getImageFactory();
70 $i = $f->standard("source", "alt");
71
72 $this->assertEquals("alt", $i->getAlt());
73 }
getImageFactory()
Definition: ImageTest.php:36
$i
Definition: metadata.php:41

References Vendor\Package\$f, $i, and getImageFactory().

+ Here is the call graph for this function:

◆ test_get_source()

ImageTest::test_get_source ( )

Definition at line 59 of file ImageTest.php.

59 : void
60 {
61 $f = $this->getImageFactory();
62 $i = $f->standard("source", "alt");
63
64 $this->assertEquals("source", $i->getSource());
65 }

References Vendor\Package\$f, $i, and getImageFactory().

+ Here is the call graph for this function:

◆ test_get_type()

ImageTest::test_get_type ( )

Definition at line 51 of file ImageTest.php.

51 : void
52 {
53 $f = $this->getImageFactory();
54 $i = $f->standard("source", "alt");
55
56 $this->assertEquals($i::STANDARD, $i->getType());
57 }

References Vendor\Package\$f, $i, and getImageFactory().

+ Here is the call graph for this function:

◆ test_implements_factory_interface()

ImageTest::test_implements_factory_interface ( )

Definition at line 42 of file ImageTest.php.

42 : void
43 {
44 $f = $this->getImageFactory();
45
46 $this->assertInstanceOf("ILIAS\\UI\\Component\\Image\\Factory", $f);
47 $this->assertInstanceOf("ILIAS\\UI\\Component\\Image\\Image", $f->standard("source", "alt"));
48 $this->assertInstanceOf("ILIAS\\UI\\Component\\Image\\Image", $f->responsive("source", "alt"));
49 }

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

+ Here is the call graph for this function:

◆ test_invalid_alt()

ImageTest::test_invalid_alt ( )

Definition at line 115 of file ImageTest.php.

115 : void
116 {
117 $this->expectException(TypeError::class);
118 $f = $this->getImageFactory();
119 $f->standard("source", 1);
120 }

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

+ Here is the call graph for this function:

◆ test_invalid_source()

ImageTest::test_invalid_source ( )

Definition at line 108 of file ImageTest.php.

108 : void
109 {
110 $this->expectException(TypeError::class);
111 $f = $this->getImageFactory();
112 $f->standard(1, "alt");
113 }

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

+ Here is the call graph for this function:

◆ test_render_alt_escaping()

ImageTest::test_render_alt_escaping ( )

Definition at line 148 of file ImageTest.php.

148 : void
149 {
150 $f = $this->getImageFactory();
151 $r = $this->getDefaultRenderer();
152 $i = $f->responsive("source", "\"=test;\")(blah\"");
153
154 $html = $this->normalizeHTML($r->render($i));
155
156 $expected = "<img src=\"source\" class=\"img-responsive\" alt=\"&quot;=test;&quot;)(blah&quot;\" />";
157
158 $this->assertEquals($expected, $html);
159 }
normalizeHTML(string $html)
Definition: Base.php:422
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355

References Vendor\Package\$f, $i, ILIAS_UI_TestBase\getDefaultRenderer(), getImageFactory(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_render_responsive()

ImageTest::test_render_responsive ( )

Definition at line 135 of file ImageTest.php.

135 : void
136 {
137 $f = $this->getImageFactory();
138 $r = $this->getDefaultRenderer();
139 $i = $f->responsive("source", "alt");
140
141 $html = $this->normalizeHTML($r->render($i));
142
143 $expected = "<img src=\"source\" class=\"img-responsive\" alt=\"alt\" />";
144
145 $this->assertEquals($expected, $html);
146 }

References Vendor\Package\$f, $i, ILIAS_UI_TestBase\getDefaultRenderer(), getImageFactory(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_render_standard()

ImageTest::test_render_standard ( )

Definition at line 122 of file ImageTest.php.

122 : void
123 {
124 $f = $this->getImageFactory();
125 $r = $this->getDefaultRenderer();
126 $i = $f->standard("source", "alt");
127
128 $html = $this->normalizeHTML($r->render($i));
129
130 $expected = "<img src=\"source\" class=\"img-standard\" alt=\"alt\" />";
131
132 $this->assertEquals($expected, $html);
133 }

References Vendor\Package\$f, $i, ILIAS_UI_TestBase\getDefaultRenderer(), getImageFactory(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_render_with_signal_action()

ImageTest::test_render_with_signal_action ( )

Definition at line 174 of file ImageTest.php.

174 : void
175 {
176 $f = $this->getImageFactory();
177 $r = $this->getDefaultRenderer();
178 $signal = $this->createMock(Signal::class);
179
180 $i = $f->standard("source", "alt")->withAction($signal);
181
182 $html = $this->normalizeHTML($r->render($i));
183
184 $expected = "<a href=\"#\" id=\"id_1\"><img src=\"source\" class=\"img-standard\" alt=\"alt\" /></a>";
185
186 $this->assertEquals($expected, $html);
187 }

References Vendor\Package\$f, $i, ILIAS_UI_TestBase\getDefaultRenderer(), getImageFactory(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_render_with_string_action()

ImageTest::test_render_with_string_action ( )

Definition at line 161 of file ImageTest.php.

161 : void
162 {
163 $f = $this->getImageFactory();
164 $r = $this->getDefaultRenderer();
165 $i = $f->standard("source", "alt")->withAction("action");
166
167 $html = $this->normalizeHTML($r->render($i));
168
169 $expected = "<a href=\"action\"><img src=\"source\" class=\"img-standard\" alt=\"alt\" /></a>";
170
171 $this->assertEquals($expected, $html);
172 }

References Vendor\Package\$f, $i, ILIAS_UI_TestBase\getDefaultRenderer(), getImageFactory(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_set_alt()

ImageTest::test_set_alt ( )

Definition at line 83 of file ImageTest.php.

83 : void
84 {
85 $f = $this->getImageFactory();
86 $i = $f->standard("source", "alt");
87 $i = $i->withAlt("newAlt");
88 $this->assertEquals("newAlt", $i->getAlt());
89 }

References Vendor\Package\$f, $i, and getImageFactory().

+ Here is the call graph for this function:

◆ test_set_signal_action()

ImageTest::test_set_signal_action ( )

Definition at line 99 of file ImageTest.php.

99 : void
100 {
101 $f = $this->getImageFactory();
102 $signal = $this->createMock(C\Signal::class);
103 $i = $f->standard("source", "alt");
104 $i = $i->withAction($signal);
105 $this->assertEquals([$signal], $i->getAction());
106 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References Vendor\Package\$f, $i, and getImageFactory().

+ Here is the call graph for this function:

◆ test_set_source()

ImageTest::test_set_source ( )

Definition at line 75 of file ImageTest.php.

75 : void
76 {
77 $f = $this->getImageFactory();
78 $i = $f->standard("source", "alt");
79 $i = $i->withSource("newSource");
80 $this->assertEquals("newSource", $i->getSource());
81 }

References Vendor\Package\$f, $i, and getImageFactory().

+ Here is the call graph for this function:

◆ test_set_string_action()

ImageTest::test_set_string_action ( )

Definition at line 91 of file ImageTest.php.

91 : void
92 {
93 $f = $this->getImageFactory();
94 $i = $f->standard("source", "alt");
95 $i = $i->withAction("newAction");
96 $this->assertEquals("newAction", $i->getAction());
97 }

References Vendor\Package\$f, $i, and getImageFactory().

+ Here is the call graph for this function:

◆ test_with_additional_on_load_code()

ImageTest::test_with_additional_on_load_code ( )

Definition at line 203 of file ImageTest.php.

203 : void
204 {
205 $f = $this->getImageFactory();
206 $r = $this->getDefaultRenderer();
207
208 $i = $f->standard("source", "alt")->withAction("#")->withOnLoadCode(function ($id) {
209 return "Something";
210 });
211
212 $html = $this->normalizeHTML($r->render($i));
213
214 $expected = "<a href=\"#\"><img src=\"source\" class=\"img-standard\" id='id_1' alt=\"alt\" /></a>";
215
216 $this->assertEquals($expected, $html);
217 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References Vendor\Package\$f, $i, $id, ILIAS_UI_TestBase\getDefaultRenderer(), getImageFactory(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_with_empty_action_and_no_additional_on_load_code()

ImageTest::test_with_empty_action_and_no_additional_on_load_code ( )

Definition at line 189 of file ImageTest.php.

189 : void
190 {
191 $f = $this->getImageFactory();
192 $r = $this->getDefaultRenderer();
193
194 $i = $f->standard("source", "alt")->withAction("#");
195
196 $html = $this->normalizeHTML($r->render($i));
197
198 $expected = "<a href=\"#\"><img src=\"source\" class=\"img-standard\" alt=\"alt\" /></a>";
199
200 $this->assertEquals($expected, $html);
201 }

References Vendor\Package\$f, $i, ILIAS_UI_TestBase\getDefaultRenderer(), getImageFactory(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

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