19 declare(strict_types=1);
21 require_once(__DIR__ .
"/../../../../../../vendor/composer/vendor/autoload.php");
22 require_once(__DIR__ .
"/../../Base.php");
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"));
54 $i =
$f->standard(
"source",
"alt");
56 $this->assertEquals($i::STANDARD, $i->getType());
62 $i =
$f->standard(
"source",
"alt");
64 $this->assertEquals(
"source", $i->getSource());
70 $i =
$f->standard(
"source",
"alt");
72 $this->assertEquals(
"alt", $i->getAlt());
78 $i =
$f->standard(
"source",
"alt");
79 $i = $i->withSource(
"newSource");
80 $this->assertEquals(
"newSource", $i->getSource());
86 $i =
$f->standard(
"source",
"alt");
87 $i = $i->withAlt(
"newAlt");
88 $this->assertEquals(
"newAlt", $i->getAlt());
94 $i =
$f->standard(
"source",
"alt");
95 $i = $i->withAction(
"newAction");
96 $this->assertEquals(
"newAction", $i->getAction());
102 $signal = $this->createMock(
C\Signal::class);
103 $i =
$f->standard(
"source",
"alt");
104 $i = $i->withAction($signal);
105 $this->assertEquals([$signal], $i->getAction());
110 $additional_sources = [
115 $i =
$f->standard(
"source",
"alt");
116 foreach($additional_sources as $min_width_in_pixels => $source) {
117 $i = $i->withAdditionalHighResSource($source, $min_width_in_pixels);
119 $this->assertEquals($additional_sources, $i->getAdditionalHighResSources());
124 $this->expectException(TypeError::class);
126 $f->standard(1,
"alt");
131 $this->expectException(TypeError::class);
133 $f->standard(
"source", 1);
138 $this->expectException(TypeError::class);
140 $f->standard(
"source", 1)->withAdditionalHighResSource(
148 $this->expectException(TypeError::class);
150 $f->standard(
"source", 1)->withAdditionalHighResSource(
159 $r = $this->getDefaultRenderer();
160 $i =
$f->standard(
"source",
"alt");
162 $html = $this->normalizeHTML(
$r->render($i));
164 $expected =
"<img src=\"source\" class=\"img-standard\" alt=\"alt\" />";
166 $this->assertEquals($expected, $html);
172 $r = $this->getDefaultRenderer();
173 $i =
$f->responsive(
"source",
"alt");
175 $html = $this->normalizeHTML(
$r->render($i));
177 $expected =
"<img src=\"source\" class=\"img-responsive\" alt=\"alt\" />";
179 $this->assertEquals($expected, $html);
185 $r = $this->getDefaultRenderer();
186 $i =
$f->responsive(
"source",
"\"=test;\")(blah\"");
188 $html = $this->normalizeHTML(
$r->render($i));
190 $expected =
"<img src=\"source\" class=\"img-responsive\" alt=\""=test;")(blah"\" />";
192 $this->assertEquals($expected, $html);
198 $r = $this->getDefaultRenderer();
199 $i =
$f->standard(
"source",
"alt")->withAction(
"action");
201 $html = $this->normalizeHTML(
$r->render($i));
203 $expected =
"<a href=\"action\"><img src=\"source\" class=\"img-standard\" alt=\"alt\" /></a>";
205 $this->assertEquals($expected, $html);
211 $r = $this->getDefaultRenderer();
212 $signal = $this->createMock(Signal::class);
214 $i =
$f->standard(
"source",
"alt")->withAction($signal);
216 $html = $this->normalizeHTML(
$r->render($i));
218 $expected =
"<a href=\"#\" id=\"id_1\"><img src=\"source\" class=\"img-standard\" alt=\"alt\" /></a>";
220 $this->assertEquals($expected, $html);
226 $r = $this->getDefaultRenderer();
228 $i =
$f->standard(
"source",
"alt")->withAction(
"#");
230 $html = $this->normalizeHTML(
$r->render($i));
232 $expected =
"<a href=\"#\"><img src=\"source\" class=\"img-standard\" alt=\"alt\" /></a>";
234 $this->assertEquals($expected, $html);
240 $r = $this->getDefaultRenderer();
242 $i =
$f->standard(
"source",
"alt")->withAction(
"#")->withOnLoadCode(
function (
$id) {
246 $html = $this->normalizeHTML(
$r->render($i));
248 $expected =
"<a href=\"#\"><img src=\"source\" class=\"img-standard\" id='id_1' alt=\"alt\" /></a>";
250 $this->assertEquals($expected, $html);
testWithEmptyActionAndNoAdditionalOnLoadCode()
Test on button implementation.
testInvalidAdditionalHighResSource()
testRenderWithSignalAction()
testImplementsFactoryInterface()
testRenderWithStringAction()
testInvalidAdditionalHighResSourceSize()
testWithAdditionalOnLoadCode()
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
testSetAdditionalHighResSources()