ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
PopoverTest.php
Go to the documentation of this file.
1 <?php
3 
4 require_once(__DIR__ . "/../../../../libs/composer/vendor/autoload.php");
5 require_once(__DIR__ . "/../../Base.php");
6 
15 {
16  public function test_implements_interface()
17  {
18  $factory = new \ILIAS\UI\Implementation\Factory();
19  $standard = $factory->popover()->standard(new DummyComponent());
20  $this->assertInstanceOf("ILIAS\\UI\\Component\\Popover\\Standard", $standard);
21  $listing = $factory->popover()->listing([new DummyComponent()]);
22  $this->assertInstanceOf("ILIAS\\UI\\Component\\Popover\\Listing", $listing);
23  }
24 
26  {
27  $factory = new \ILIAS\UI\Implementation\Factory();
28  $popover = $factory->popover()->standard(new DummyComponent());
29  $this->assertEquals(Popover::POS_AUTO, $popover->getPosition());
30  }
31 
32  public function test_with_position()
33  {
34  $factory = new \ILIAS\UI\Implementation\Factory();
35  $popover1 = $factory->popover()->standard(new DummyComponent());
36  $popover2 = $popover1->withVerticalPosition();
37  $popover3 = $popover2->withHorizontalPosition();
38  $this->assertEquals(Popover::POS_AUTO, $popover1->getPosition());
39  $this->assertEquals(Popover::POS_VERTICAL, $popover2->getPosition());
40  $this->assertEquals(Popover::POS_HORIZONTAL, $popover3->getPosition());
41  $this->assertEquals($popover1->getContent(), $popover2->getContent());
42  $this->assertEquals($popover1->getContent(), $popover3->getContent());
43  }
44 
45  public function test_render_standard()
46  {
47  $factory = new \ILIAS\UI\Implementation\Factory();
48  $popover = $factory->popover()->standard($factory->legacy('myContent'));
49  $expected = $this->normalizeHTML($this->getExpectedStandardHTML('myContent'));
50  $actual = $this->normalizeHTML($this->getDefaultRenderer()->render($popover));
51  $this->assertEquals($expected, $actual);
52  }
53 
54  public function test_render_listing()
55  {
56  // TODO Listing not yet in framework core
57  $this->assertTrue(true);
58  }
59 
60  public function test_render_async()
61  {
62  $factory = new \ILIAS\UI\Implementation\Factory();
63  $popover = $factory->popover()->standard($factory->legacy('myContent'))->withAsyncContentUrl('/blub/');
64  $this->assertEquals('', $this->getDefaultRenderer()->render($popover));
65  }
66 
71  protected function getExpectedStandardHTML($content)
72  {
73  return '<div class="il-standard-popover-content" style="display:none;" id="id_1">' . $content . '</div>';
74  }
75 }
test_render_listing()
Definition: PopoverTest.php:54
$factory
Definition: metadata.php:47
getExpectedStandardHTML($content)
Definition: PopoverTest.php:71
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:216
normalizeHTML($html)
Definition: Base.php:243
Class PopoverTest.
Definition: PopoverTest.php:14
test_render_standard()
Definition: PopoverTest.php:45
test_implements_interface()
Definition: PopoverTest.php:16
test_with_position()
Definition: PopoverTest.php:32
Provides common functionality for UI tests.
Definition: Base.php:177
test_that_position_is_auto_by_default()
Definition: PopoverTest.php:25