ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ()
 
- 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)
 

Detailed Description

Test on button implementation.

Definition at line 14 of file ImageTest.php.

Member Function Documentation

◆ getImageFactory()

ImageTest::getImageFactory ( )
Returns
\ILIAS\UI\Implementation\Component\Image\Factory

Definition at line 20 of file ImageTest.php.

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

Referenced by test_get_alt(), test_get_source(), test_get_type(), test_implements_factory_interface(), test_invalid_alt(), test_invalid_source(), test_render_alt_escaping(), test_render_responsive(), test_render_standard(), test_render_with_signal_action(), test_render_with_string_action(), test_set_alt(), test_set_signal_action(), test_set_source(), and test_set_string_action().

+ Here is the caller graph for this function:

◆ 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: disco.tpl.php:19

References $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 $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 $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 $f, and getImageFactory().

+ Here is the call graph for this function:

◆ test_invalid_alt()

ImageTest::test_invalid_alt ( )

Definition at line 104 of file ImageTest.php.

105 {
106 $f = $this->getImageFactory();
107
108 try {
109 $f->standard("source", 1);
110 $this->assertFalse("This should not happen");
111 } catch (InvalidArgumentException $e) {
112 }
113 }

References $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 $f = $this->getImageFactory();
96
97 try {
98 $f->standard(1, "alt");
99 $this->assertFalse("This should not happen");
100 } catch (InvalidArgumentException $e) {
101 }
102 }

References $f, and getImageFactory().

+ Here is the call graph for this function:

◆ test_render_alt_escaping()

ImageTest::test_render_alt_escaping ( )

Definition at line 141 of file ImageTest.php.

142 {
143 $f = $this->getImageFactory();
144 $r = $this->getDefaultRenderer();
145 $i = $f->responsive("source", "\"=test;\")(blah\"");
146
147 $html = $this->normalizeHTML($r->render($i));
148
149 $expected = "<img src=\"source\" class=\"img-responsive\" alt=\"&quot;=test;&quot;)(blah&quot;\" />";
150
151 $this->assertEquals($expected, $html);
152 }
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, $i, $r, 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 128 of file ImageTest.php.

129 {
130 $f = $this->getImageFactory();
131 $r = $this->getDefaultRenderer();
132 $i = $f->responsive("source", "alt");
133
134 $html = $this->normalizeHTML($r->render($i));
135
136 $expected = "<img src=\"source\" class=\"img-responsive\" alt=\"alt\" />";
137
138 $this->assertEquals($expected, $html);
139 }

References $f, $html, $i, $r, 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 115 of file ImageTest.php.

116 {
117 $f = $this->getImageFactory();
118 $r = $this->getDefaultRenderer();
119 $i = $f->standard("source", "alt");
120
121 $html = $this->normalizeHTML($r->render($i));
122
123 $expected = "<img src=\"source\" class=\"img-standard\" alt=\"alt\" />";
124
125 $this->assertEquals($expected, $html);
126 }

References $f, $html, $i, $r, 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 167 of file ImageTest.php.

168 {
169 $f = $this->getImageFactory();
170 $r = $this->getDefaultRenderer();
171 $signal = $this->createMock(Signal::class);
172
173 $i = $f->standard("source", "alt")->withAction($signal);
174
175 $html = $this->normalizeHTML($r->render($i));
176
177 $expected = "<a id=\"id_1\"><img src=\"source\" class=\"img-standard\" alt=\"alt\" /></a>";
178
179 $this->assertEquals($expected, $html);
180 }

References $f, $html, $i, $r, 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 154 of file ImageTest.php.

155 {
156 $f = $this->getImageFactory();
157 $r = $this->getDefaultRenderer();
158 $i = $f->standard("source", "alt")->withAction("action");
159
160 $html = $this->normalizeHTML($r->render($i));
161
162 $expected = "<a href=\"action\"><img src=\"source\" class=\"img-standard\" alt=\"alt\" /></a>";
163
164 $this->assertEquals($expected, $html);
165 }

References $f, $html, $i, $r, 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 $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 $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 $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 $f, $i, and getImageFactory().

+ Here is the call graph for this function:

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