ILIAS  release_8 Revision v8.24
PopoverTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
23
24require_once(__DIR__ . "/../../../../libs/composer/vendor/autoload.php");
25require_once(__DIR__ . "/../../Base.php");
26
35{
36 public function getFactory(): NoUIFactory
37 {
38 return new class () extends NoUIFactory {
39 public function legacy(string $content): I\Component\Legacy\Legacy
40 {
41 $f = new I\Component\Legacy\Factory(new I\Component\SignalGenerator());
42 return $f->legacy($content);
43 }
44 };
45 }
46
47 public function test_implements_interface(): void
48 {
49 $factory = new I\Component\Popover\Factory(new I\Component\SignalGenerator());
50 $standard = $factory->standard(new DummyComponent());
51 $this->assertInstanceOf("ILIAS\\UI\\Component\\Popover\\Standard", $standard);
52 $listing = $factory->listing([new DummyComponent()]);
53 $this->assertInstanceOf("ILIAS\\UI\\Component\\Popover\\Listing", $listing);
54 }
55
57 {
58 $factory = new I\Component\Popover\Factory(new I\Component\SignalGenerator());
59 $popover = $factory->standard(new DummyComponent());
60 $this->assertEquals(Popover::POS_AUTO, $popover->getPosition());
61 }
62
63 public function test_with_position(): void
64 {
65 $factory = new I\Component\Popover\Factory(new I\Component\SignalGenerator());
66 $popover1 = $factory->standard(new DummyComponent());
67 $popover2 = $popover1->withVerticalPosition();
68 $popover3 = $popover2->withHorizontalPosition();
69 $this->assertEquals(Popover::POS_AUTO, $popover1->getPosition());
70 $this->assertEquals(Popover::POS_VERTICAL, $popover2->getPosition());
71 $this->assertEquals(Popover::POS_HORIZONTAL, $popover3->getPosition());
72 $this->assertEquals($popover1->getContent(), $popover2->getContent());
73 $this->assertEquals($popover1->getContent(), $popover3->getContent());
74 }
75
76 public function test_render_standard(): void
77 {
78 $factory = new I\Component\Popover\Factory(new I\Component\SignalGenerator());
79 $popover = $factory->standard($this->getFactory()->legacy('myContent'));
80 $expected = $this->normalizeHTML($this->getExpectedStandardHTML('myContent'));
81 $actual = $this->normalizeHTML($this->getDefaultRenderer()->render($popover));
82 $this->assertEquals($expected, $actual);
83 }
84
85 public function test_render_listing(): void
86 {
87 // TODO Listing not yet in framework core
88 $this->assertTrue(true);
89 }
90
91 public function test_render_async(): void
92 {
93 $factory = new I\Component\Popover\Factory(new I\Component\SignalGenerator());
94 $popover = $factory->standard($this->getFactory()->legacy('myContent'))->withAsyncContentUrl('/blub/');
95 $this->assertEquals('', $this->getDefaultRenderer()->render($popover));
96 }
97
98 protected function getExpectedStandardHTML(string $content): string
99 {
100 return '<div class="il-standard-popover-content" style="display:none;" id="id_1">' . $content . '</div>';
101 }
102}
Provides common functionality for UI tests.
Definition: Base.php:299
normalizeHTML(string $html)
Definition: Base.php:422
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
Class PopoverTest.
Definition: PopoverTest.php:35
test_that_position_is_auto_by_default()
Definition: PopoverTest.php:56
test_implements_interface()
Definition: PopoverTest.php:47
test_with_position()
Definition: PopoverTest.php:63
test_render_standard()
Definition: PopoverTest.php:76
getExpectedStandardHTML(string $content)
Definition: PopoverTest.php:98
test_render_listing()
Definition: PopoverTest.php:85
Describes the Popover component.
Definition: Popover.php:32
$factory
Definition: metadata.php:75
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...