ILIAS  release_7 Revision v7.30-3-g800a261c036
PresentationTest.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 2018 Nils Haagen <nils.haagen@concepts-and-training.de> Extended GPL, see docs/LICENSE */
3
4require_once("libs/composer/vendor/autoload.php");
5require_once(__DIR__ . "/../../Base.php");
6
7use \ILIAS\UI\Component as C;
8use \ILIAS\UI\Implementation as I;
9
14{
15 private function getFactory()
16 {
17 return new I\Component\Table\Factory(
18 new I\Component\SignalGenerator()
19 );
20 }
21
22 public function testTableConstruction()
23 {
24 $f = $this->getFactory();
25 $this->assertInstanceOf("ILIAS\\UI\\Component\\Table\\Factory", $f);
26
27 $pt = $f->presentation('title', array(), function () {
28 });
29 $this->assertInstanceOf("ILIAS\\UI\\Component\\Table\\Presentation", $pt);
30
31 $this->assertEquals("title", $pt->getTitle());
32 $this->assertEquals(array(), $pt->getViewControls());
33 $this->assertInstanceOf(\Closure::class, $pt->getRowMapping());
34
35 $pt = $pt
36 ->withEnvironment(array('k' => 'v'))
37 ->withData(array('dk' => 'dv'));
38 $this->assertEquals(array('k' => 'v'), $pt->getEnvironment());
39 $this->assertEquals(array('dk' => 'dv'), $pt->getData());
40 }
41
42 public function testBareTableRendering()
43 {
44 $r = $this->getDefaultRenderer();
45 $f = $this->getFactory();
46 $pt = $f->presentation('title', array(), function () {
47 });
48 $expected = '' .
49 '<div class="il-table-presentation">' .
50 ' <h3 class="ilHeader">title</h3>' .
51 ' <div class="il-table-presentation-data"> </div>' .
52 '</div>';
53 $this->assertHTMLEquals($expected, $r->render($pt->withData([])));
54 }
55
56 public function testRowConstruction()
57 {
58 $f = $this->getFactory();
59 $pt = $f->presentation('title', array(), function () {
60 });
61 $row = new \ILIAS\UI\Implementation\Component\Table\PresentationRow($pt->getSignalGenerator());
62
63 $this->assertInstanceOf("ILIAS\\UI\\Component\\Table\\PresentationRow", $row);
64 $this->assertInstanceOf("ILIAS\\UI\\Component\\Signal", $row->getShowSignal());
65 $this->assertInstanceOf("ILIAS\\UI\\Component\\Signal", $row->getCloseSignal());
66 $this->assertInstanceOf("ILIAS\\UI\\Component\\Signal", $row->getToggleSignal());
67
68 $this->assertEquals(
69 "headline",
70 $row->withHeadline("headline")->getHeadline()
71 );
72 $this->assertEquals(
73 "subheadline",
74 $row->withSubheadline("subheadline")->getSubheadline()
75 );
76 $this->assertEquals(
77 array("f1" => "v1"),
78 $row->withImportantFields(array("f1" => "v1"))->getImportantFields()
79 );
80 $this->assertEquals(
81 "field_headline",
82 $row->withFurtherFieldsHeadline("field_headline")->getFurtherFieldsHeadline()
83 );
84 $this->assertEquals(
85 array("ff1" => "fv1"),
86 $row->withFurtherFields(array("ff1" => "fv1"))->getFurtherFields()
87 );
88 }
89}
An exception for terminatinating execution or to throw for unit testing.
Provides common functionality for UI tests.
Definition: Base.php:263
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:372
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
Tests for Presentation Table.