ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Additional Inherited Members

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

Detailed Description

Test on button implementation.

Definition at line 14 of file ImageTest.php.

Member Function Documentation

◆ getImageFactory()

◆ test_get_alt()

ImageTest::test_get_alt ( )

Definition at line 51 of file ImageTest.php.

52 {
53 $f = $this->getImageFactory();
54 $i = $f->standard("source", "alt");
55
56 $this->assertEquals("alt", $i->getAlt());
57 }
getImageFactory()
Definition: ImageTest.php:20
$i
Definition: metadata.php:24

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 43 of file ImageTest.php.

44 {
45 $f = $this->getImageFactory();
46 $i = $f->standard("source", "alt");
47
48 $this->assertEquals("source", $i->getSource());
49 }

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 35 of file ImageTest.php.

36 {
37 $f = $this->getImageFactory();
38 $i = $f->standard("source", "alt");
39
40 $this->assertEquals($i::STANDARD, $i->getType());
41 }

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 26 of file ImageTest.php.

27 {
28 $f = $this->getImageFactory();
29
30 $this->assertInstanceOf("ILIAS\\UI\\Component\\Image\\Factory", $f);
31 $this->assertInstanceOf("ILIAS\\UI\\Component\\Image\\Image", $f->standard("source", "alt"));
32 $this->assertInstanceOf("ILIAS\\UI\\Component\\Image\\Image", $f->responsive("source", "alt"));
33 }

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

+ Here is the call graph for this function:

◆ test_invalid_alt()

ImageTest::test_invalid_alt ( )

Definition at line 100 of file ImageTest.php.

101 {
102 $this->expectException(\InvalidArgumentException::class);
103 $f = $this->getImageFactory();
104 $f->standard("source", 1);
105 }

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

+ Here is the call graph for this function:

◆ test_invalid_source()

ImageTest::test_invalid_source ( )

Definition at line 93 of file ImageTest.php.

94 {
95 $this->expectException(\InvalidArgumentException::class);
96 $f = $this->getImageFactory();
97 $f->standard(1, "alt");
98 }

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 133 of file ImageTest.php.

134 {
135 $f = $this->getImageFactory();
136 $r = $this->getDefaultRenderer();
137 $i = $f->responsive("source", "\"=test;\")(blah\"");
138
139 $html = $this->normalizeHTML($r->render($i));
140
141 $expected = "<img src=\"source\" class=\"img-responsive\" alt=\"&quot;=test;&quot;)(blah&quot;\" />";
142
143 $this->assertEquals($expected, $html);
144 }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317

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 120 of file ImageTest.php.

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

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 107 of file ImageTest.php.

108 {
109 $f = $this->getImageFactory();
110 $r = $this->getDefaultRenderer();
111 $i = $f->standard("source", "alt");
112
113 $html = $this->normalizeHTML($r->render($i));
114
115 $expected = "<img src=\"source\" class=\"img-standard\" alt=\"alt\" />";
116
117 $this->assertEquals($expected, $html);
118 }

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 159 of file ImageTest.php.

160 {
161 $f = $this->getImageFactory();
162 $r = $this->getDefaultRenderer();
163 $signal = $this->createMock(Signal::class);
164
165 $i = $f->standard("source", "alt")->withAction($signal);
166
167 $html = $this->normalizeHTML($r->render($i));
168
169 $expected = "<a href=\"#\" id=\"id_1\"><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_render_with_string_action()

ImageTest::test_render_with_string_action ( )

Definition at line 146 of file ImageTest.php.

147 {
148 $f = $this->getImageFactory();
149 $r = $this->getDefaultRenderer();
150 $i = $f->standard("source", "alt")->withAction("action");
151
152 $html = $this->normalizeHTML($r->render($i));
153
154 $expected = "<a href=\"action\"><img src=\"source\" class=\"img-standard\" alt=\"alt\" /></a>";
155
156 $this->assertEquals($expected, $html);
157 }

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 68 of file ImageTest.php.

69 {
70 $f = $this->getImageFactory();
71 $i = $f->standard("source", "alt");
72 $i = $i->withAlt("newAlt");
73 $this->assertEquals("newAlt", $i->getAlt());
74 }

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 84 of file ImageTest.php.

85 {
86 $f = $this->getImageFactory();
87 $signal = $this->createMock(C\Signal::class);
88 $i = $f->standard("source", "alt");
89 $i = $i->withAction($signal);
90 $this->assertEquals([$signal], $i->getAction());
91 }

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 60 of file ImageTest.php.

61 {
62 $f = $this->getImageFactory();
63 $i = $f->standard("source", "alt");
64 $i = $i->withSource("newSource");
65 $this->assertEquals("newSource", $i->getSource());
66 }

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 76 of file ImageTest.php.

77 {
78 $f = $this->getImageFactory();
79 $i = $f->standard("source", "alt");
80 $i = $i->withAction("newAction");
81 $this->assertEquals("newAction", $i->getAction());
82 }

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 188 of file ImageTest.php.

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

References Vendor\Package\$f, $i, 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 174 of file ImageTest.php.

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

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: