ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
PopoverTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23
24require_once(__DIR__ . "/../../../../../../vendor/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(): I\Component\Legacy\Factory
40 {
41 return new I\Component\Legacy\Factory(new I\Component\SignalGenerator());
42 }
43 };
44 }
45
46 public function testImplementsInterface(): void
47 {
48 $factory = new I\Component\Popover\Factory(new I\Component\SignalGenerator());
49 $standard = $factory->standard(new DummyComponent());
50 $this->assertInstanceOf("ILIAS\\UI\\Component\\Popover\\Standard", $standard);
51 $listing = $factory->listing([new DummyComponent()]);
52 $this->assertInstanceOf("ILIAS\\UI\\Component\\Popover\\Listing", $listing);
53 }
54
55 public function testThatPositionIsAutoByDefault(): void
56 {
57 $factory = new I\Component\Popover\Factory(new I\Component\SignalGenerator());
58 $popover = $factory->standard(new DummyComponent());
59 $this->assertEquals(Popover::POS_AUTO, $popover->getPosition());
60 }
61
62 public function testWithPosition(): void
63 {
64 $factory = new I\Component\Popover\Factory(new I\Component\SignalGenerator());
65 $popover1 = $factory->standard(new DummyComponent());
66 $popover2 = $popover1->withVerticalPosition();
67 $popover3 = $popover2->withHorizontalPosition();
68 $this->assertEquals(Popover::POS_AUTO, $popover1->getPosition());
69 $this->assertEquals(Popover::POS_VERTICAL, $popover2->getPosition());
70 $this->assertEquals(Popover::POS_HORIZONTAL, $popover3->getPosition());
71 $this->assertEquals($popover1->getContent(), $popover2->getContent());
72 $this->assertEquals($popover1->getContent(), $popover3->getContent());
73 }
74
75 public function testRenderStandard(): void
76 {
77 $factory = new I\Component\Popover\Factory(new I\Component\SignalGenerator());
78 $popover = $factory->standard($this->getFactory()->legacy()->content('myContent'));
79 $expected = $this->normalizeHTML($this->getExpectedStandardHTML('myContent'));
80 $actual = $this->normalizeHTML($this->getDefaultRenderer()->render($popover));
81 $this->assertEquals($expected, $actual);
82 }
83
84 public function testRenderListing(): void
85 {
86 // TODO Listing not yet in framework core
87 $this->assertTrue(true);
88 }
89
90 public function testRenderAsync(): void
91 {
92 $factory = new I\Component\Popover\Factory(new I\Component\SignalGenerator());
93 $popover = $factory->standard($this->getFactory()->legacy()->content('myContent'))->withAsyncContentUrl('/blub/');
94 $this->assertEquals('', $this->getDefaultRenderer()->render($popover));
95 }
96
97 protected function getExpectedStandardHTML(string $content): string
98 {
99 return '<div class="il-standard-popover-content" style="display:none;" id="id_1">' . $content . '</div>';
100 }
101}
Provides common functionality for UI tests.
Definition: Base.php:337
Class PopoverTest.
Definition: PopoverTest.php:35
testThatPositionIsAutoByDefault()
Definition: PopoverTest.php:55
testRenderStandard()
Definition: PopoverTest.php:75
getExpectedStandardHTML(string $content)
Definition: PopoverTest.php:97
testImplementsInterface()
Definition: PopoverTest.php:46
Describes the Popover component.
Definition: Popover.php:32