ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ViewControlTest Class Reference
+ Inheritance diagram for ViewControlTest:
+ Collaboration diagram for ViewControlTest:

Public Member Functions

 getViewControlFactory ()
 
 testImplementsFactoryInterface ()
 
 testViewControlSectionGetPreviousActions ()
 
 testViewControlSectionGetNextActions ()
 
 testRenderViewControlSection ()
 
 testViewControlWithActive ()
 
 testViewControlGetActions ()
 
 testViewControlModeRender ()
 
 getUIFactory ()
 

Protected Member Functions

 getSectionExpectedHTML ()
 

Protected Attributes

array $actions
 
string $aria_label = "Mode View Controler"
 
string $role = "group"
 
string $active = "Github"
 

Detailed Description

Definition at line 28 of file ViewControlTest.php.

Member Function Documentation

◆ getSectionExpectedHTML()

ViewControlTest::getSectionExpectedHTML ( )
protected

Definition at line 172 of file ViewControlTest.php.

172 : string
173 {
174 return <<<EOT
175<div class="il-viewcontrol-section l-bar__element">
176 <a class="btn btn-ctrl browse previous" href="http://www.ilias.de" aria-label="previous" data-action="http://www.ilias.de" id="id_1"><span class="glyphicon glyphicon-chevron-left"></span></a>
177 <button class="btn btn-default" data-action="">Today</button>
178 <a class="btn btn-ctrl browse next" href="http://www.github.com" aria-label="next" data-action="http://www.github.com" id="id_2"><span class="glyphicon glyphicon-chevron-right"></span></a>
179</div>
180EOT;
181 }
button(string $caption, string $cmd)

References ILIAS\Repository\button().

Referenced by testRenderViewControlSection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUIFactory()

ViewControlTest::getUIFactory ( )

Definition at line 158 of file ViewControlTest.php.

159 {
160 return new class () extends NoUIFactory {
161 public function counter(): I\Component\Counter\Factory
162 {
163 return new I\Component\Counter\Factory();
164 }
165 public function button(): I\Component\Button\Factory
166 {
167 return new I\Component\Button\Factory();
168 }
169 };
170 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21

References ILIAS\Repository\button().

+ Here is the call graph for this function:

◆ getViewControlFactory()

ViewControlTest::getViewControlFactory ( )

Definition at line 39 of file ViewControlTest.php.

39 : I\Component\ViewControl\Factory
40 {
41 return new I\Component\ViewControl\Factory(new SignalGenerator());
42 }

Referenced by testImplementsFactoryInterface(), testRenderViewControlSection(), testViewControlGetActions(), testViewControlModeRender(), testViewControlSectionGetNextActions(), testViewControlSectionGetPreviousActions(), and testViewControlWithActive().

+ Here is the caller graph for this function:

◆ testImplementsFactoryInterface()

ViewControlTest::testImplementsFactoryInterface ( )

Definition at line 44 of file ViewControlTest.php.

44 : void
45 {
46 $view_control_f = $this->getViewControlFactory();
47
48 $back = new I\Component\Button\Standard("", "http://www.ilias.de");
49 $next = new I\Component\Button\Standard("", "http://www.github.com");
50 $button = new I\Component\Button\Standard("Today", "");
51
52 $this->assertInstanceOf("ILIAS\\UI\\Component\\Button\\Button", $back);
53 $this->assertInstanceOf("ILIAS\\UI\\Component\\Button\\Button", $next);
54 $this->assertInstanceOf("ILIAS\\UI\\Component\\Button\\Button", $button);
55 $this->assertInstanceOf("ILIAS\\UI\\Component\\ViewControl\\Factory", $view_control_f);
56
57 $section = $view_control_f->section($back, $button, $next);
58 $this->assertInstanceOf("ILIAS\\UI\\Component\\ViewControl\\Section", $section);
59 }

References getViewControlFactory().

+ Here is the call graph for this function:

◆ testRenderViewControlSection()

ViewControlTest::testRenderViewControlSection ( )

Definition at line 87 of file ViewControlTest.php.

87 : void
88 {
89 $view_control_f = $this->getViewControlFactory();
91
92 $r = $this->getDefaultRenderer();
93
94 $back = $button_f->standard("", "http://www.ilias.de");
95 $next = $button_f->standard("", "http://www.github.com");
96 $button = $button_f->standard("Today", "");
97
98 $section = $view_control_f->section($back, $button, $next);
99
100 $html = $r->render($section);
101 $this->assertStringContainsString("glyphicon-chevron-left", $html);
102 $this->assertStringContainsString("glyphicon-chevron-right", $html);
103 $this->assertStringContainsString("il-viewcontrol-section", $html);
104 $this->assertStringContainsString("btn", $html);
105
106 $expected = $this->getSectionExpectedHTML();
107 $this->assertEquals($this->brutallyTrimHTML($expected), $this->brutallyTrimHTML($html));
108
109 $f = $this->getViewControlFactory();
110 $this->assertInstanceOf("ILIAS\\UI\\Component\\ViewControl\\Factory", $f);
111 }
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31

References Vendor\Package\$f, getSectionExpectedHTML(), and getViewControlFactory().

+ Here is the call graph for this function:

◆ testViewControlGetActions()

ViewControlTest::testViewControlGetActions ( )

Definition at line 121 of file ViewControlTest.php.

121 : void
122 {
123 $f = $this->getViewControlFactory();
124
125 $this->assertIsArray($f->mode($this->actions, $this->aria_label)->getLabelledActions());
126 }

References Vendor\Package\$f, and getViewControlFactory().

+ Here is the call graph for this function:

◆ testViewControlModeRender()

ViewControlTest::testViewControlModeRender ( )

Definition at line 128 of file ViewControlTest.php.

128 : void
129 {
130 $f = $this->getViewControlFactory();
131 $r = $this->getDefaultRenderer();
132 $mode = $f->mode($this->actions, $this->aria_label);
133
134 $html = $this->normalizeHTML($r->render($mode));
135
136 $activate_first_item = false;
137 $active = $mode->getActive();
138 if ($active == "") {
139 $activate_first_item = true;
140 }
141
142 $expected = "<div class=\"il-viewcontrol-mode l-bar__element\" aria-label=\"" . $this->aria_label . "\" role=\"" . $this->role . "\">";
143 foreach ($this->actions as $label => $action) {
144 if ($activate_first_item) {
145 $expected .= "<button class=\"btn btn-default engaged\" aria-pressed=\"true\" data-action=\"$action\" id=\"id_1\">$label</button>";
146 $activate_first_item = false;
147 } elseif ($active == $label) {
148 $expected .= "<button class=\"btn btn-default engaged\" aria-pressed=\"true\" data-action=\"$action\" id=\"id_1\">$label</button>";
149 } else {
150 $expected .= "<button class=\"btn btn-default\" aria-pressed=\"false\" data-action=\"$action\" id=\"id_2\">$label</button>";
151 }
152 }
153 $expected .= "</div>";
154
155 $this->assertEquals($this->brutallyTrimHTML($expected), $this->brutallyTrimHTML($html));
156 }

References $active, Vendor\Package\$f, and getViewControlFactory().

+ Here is the call graph for this function:

◆ testViewControlSectionGetNextActions()

ViewControlTest::testViewControlSectionGetNextActions ( )

Definition at line 74 of file ViewControlTest.php.

74 : void
75 {
77
78 $back = $button_f->standard("", "http://www.ilias.de");
79 $next = $button_f->standard("", "http://www.github.com");
80 $button = $button_f->standard("Today", "");
81
82 $action = $this->getViewControlFactory()->section($back, $button, $next)->getNextActions();
83
84 $this->assertInstanceOf("ILIAS\\UI\\Component\\Button\\Button", $action);
85 }

References getViewControlFactory().

+ Here is the call graph for this function:

◆ testViewControlSectionGetPreviousActions()

ViewControlTest::testViewControlSectionGetPreviousActions ( )

Definition at line 61 of file ViewControlTest.php.

61 : void
62 {
64
65 $back = $button_f->standard("", "http://www.ilias.de");
66 $next = $button_f->standard("", "http://www.github.com");
67 $button = $button_f->standard("Today", "");
68
69 $action = $this->getViewControlFactory()->section($back, $button, $next)->getPreviousActions();
70
71 $this->assertInstanceOf("ILIAS\\UI\\Component\\Button\\Button", $action);
72 }

References getViewControlFactory().

+ Here is the call graph for this function:

◆ testViewControlWithActive()

ViewControlTest::testViewControlWithActive ( )

Definition at line 113 of file ViewControlTest.php.

113 : void
114 {
115 $f = $this->getViewControlFactory();
116
117 $this->assertEquals($this->active, $f->mode($this->actions, $this->aria_label)->withActive($this->active)->getActive());
118 $this->assertNotEquals($this->active, $f->mode($this->actions, $this->aria_label)->withActive("Dummy text")->getActive());
119 }

References Vendor\Package\$f, and getViewControlFactory().

+ Here is the call graph for this function:

Field Documentation

◆ $actions

array ViewControlTest::$actions
protected
Initial value:
= [
"ILIAS" => "http://www.ilias.de",
"Github" => "http://www.github.com"
]

Definition at line 30 of file ViewControlTest.php.

◆ $active

string ViewControlTest::$active = "Github"
protected

Definition at line 37 of file ViewControlTest.php.

Referenced by testViewControlModeRender().

◆ $aria_label

string ViewControlTest::$aria_label = "Mode View Controler"
protected

Definition at line 35 of file ViewControlTest.php.

◆ $role

string ViewControlTest::$role = "group"
protected

Definition at line 36 of file ViewControlTest.php.


The documentation for this class was generated from the following file: