ILIAS  release_8 Revision v8.24
ViewControlTest Class Reference
+ Inheritance diagram for ViewControlTest:
+ Collaboration diagram for ViewControlTest:

Public Member Functions

 getViewControlFactory ()
 
 test_implements_factory_interface ()
 
 test_viewcontrol_section_get_previous_actions ()
 
 test_viewcontrol_section_get_next_actions ()
 
 test_render_viewcontrol_section ()
 
 test_viewcontrol_with_active ()
 
 test_viewcontrol_get_actions ()
 
 test_render_viewcontrol_mode ()
 
 getUIFactory ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML (string $html)
 
 assertHTMLEquals (string $expected_html_as_string, string $html_as_string)
 

Protected Member Functions

 getSectionExpectedHTML ()
 
- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML (string $html)
 A more radical version of normalizeHTML. More...
 
 brutallyTrimSignals (string $html)
 A naive replacement of all il_signal-ids with dots to ease comparisons of rendered output. More...
 

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">
176<a class="btn btn-default " 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-default " 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 }

Referenced by test_render_viewcontrol_section().

+ Here is the caller graph for this function:

◆ getUIFactory()

ViewControlTest::getUIFactory ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 158 of file ViewControlTest.php.

159 {
160 return new class () extends NoUIFactory {
161 public function counter(): C\Counter\Factory
162 {
163 return new I\Component\Counter\Factory();
164 }
165 public function button(): C\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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getViewControlFactory()

ViewControlTest::getViewControlFactory ( )

◆ test_implements_factory_interface()

ViewControlTest::test_implements_factory_interface ( )

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:

◆ test_render_viewcontrol_mode()

ViewControlTest::test_render_viewcontrol_mode ( )

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=\"btn-group il-viewcontrol-mode\" 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-label=\"$label\" 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-label=\"$label\" aria-pressed=\"true\" data-action=\"$action\" id=\"id_1\">$label</button>";
149 } else {
150 $expected .= "<button class=\"btn btn-default\" aria-label=\"$label\" aria-pressed=\"false\" data-action=\"$action\" id=\"id_2\">$label</button>";
151 }
152 }
153 $expected .= "</div>";
154
155 $this->assertHTMLEquals($expected, $html);
156 }
normalizeHTML(string $html)
Definition: Base.php:422
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355

References $active, Vendor\Package\$f, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\getDefaultRenderer(), getViewControlFactory(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_render_viewcontrol_section()

ViewControlTest::test_render_viewcontrol_section ( )

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->assertHTMLEquals($expected, $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:17

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

+ Here is the call graph for this function:

◆ test_viewcontrol_get_actions()

ViewControlTest::test_viewcontrol_get_actions ( )

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:

◆ test_viewcontrol_section_get_next_actions()

ViewControlTest::test_viewcontrol_section_get_next_actions ( )

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:

◆ test_viewcontrol_section_get_previous_actions()

ViewControlTest::test_viewcontrol_section_get_previous_actions ( )

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:

◆ test_viewcontrol_with_active()

ViewControlTest::test_viewcontrol_with_active ( )

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 test_render_viewcontrol_mode().

◆ $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: