ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Protected Member Functions

 getSectionExpectedHTML ()
 
- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 

Protected Attributes

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

Detailed Description

Definition at line 10 of file ViewControlTest.php.

Member Function Documentation

◆ getSectionExpectedHTML()

ViewControlTest::getSectionExpectedHTML ( )
protected

Definition at line 157 of file ViewControlTest.php.

158 {
159 $expected = <<<EOT
160<div class="il-viewcontrol-section">
161<a class="btn btn-default " href="http://www.ilias.de" aria-label="previous" data-action="http://www.ilias.de"><span class="glyphicon glyphicon-chevron-left"></span></a>
162<button class="btn btn-default" data-action="">Today</button>
163<a class="btn btn-default " href="http://www.github.com" aria-label="next" data-action="http://www.github.com"><span class="glyphicon glyphicon-chevron-right"></span></a>
164</div>
165EOT;
166 return $expected;
167 }

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 142 of file ViewControlTest.php.

143 {
144 $factory = new class extends NoUIFactory {
145 public function counter()
146 {
147 return new I\Component\Counter\Factory();
148 }
149 public function button()
150 {
151 return new I\Component\Button\Factory();
152 }
153 };
154 return $factory;
155 }
$factory
Definition: metadata.php:58

References $factory.

◆ getViewControlFactory()

◆ test_implements_factory_interface()

ViewControlTest::test_implements_factory_interface ( )

Definition at line 26 of file ViewControlTest.php.

27 {
28 $view_control_f = $this->getViewControlFactory();
29 $button_f = new I\Component\Button\Factory();
30
31 $back = new I\Component\Button\Standard("", "http://www.ilias.de");
32 $next = new I\Component\Button\Standard("", "http://www.github.com");
33 $button = new I\Component\Button\Standard("Today", "");
34
35 $this->assertInstanceOf("ILIAS\\UI\\Component\\Button\\Button", $back);
36 $this->assertInstanceOf("ILIAS\\UI\\Component\\Button\\Button", $next);
37 $this->assertInstanceOf("ILIAS\\UI\\Component\\Button\\Button", $button);
38 $this->assertInstanceOf("ILIAS\\UI\\Component\\ViewControl\\Factory", $view_control_f);
39
40 $section = $view_control_f->section($back, $button, $next);
41 $this->assertInstanceOf("ILIAS\\UI\\Component\\ViewControl\\Section", $section);
42 }
$section
Definition: Utf8Test.php:83

References $section, and getViewControlFactory().

+ Here is the call graph for this function:

◆ test_render_viewcontrol_mode()

ViewControlTest::test_render_viewcontrol_mode ( )

Definition at line 113 of file ViewControlTest.php.

114 {
115 $f = $this->getViewControlFactory();
116 $r = $this->getDefaultRenderer();
117 $mode = $f->mode($this->actions, $this->aria_label);
118
119 $html = $this->normalizeHTML($r->render($mode));
120
121 $active = $mode->getActive();
122 if ($active == "") {
123 $activate_first_item = true;
124 }
125
126 $expected = "<div class=\"btn-group il-viewcontrol-mode\" aria-label=\"" . $this->aria_label . "\" role=\"" . $this->role . "\">";
127 foreach ($this->actions as $label => $action) {
128 if ($activate_first_item) {
129 $expected .= "<button class=\"btn btn-default engaged\" aria-label=\"$label\" aria-pressed=\"true\" data-action=\"$action\" disabled=\"true\">$label</button>";
130 $activate_first_item = false;
131 } elseif ($active == $label) {
132 $expected .= "<button class=\"btn btn-default engaged\" aria-label=\"$label\" aria-pressed=\"true\" data-action=\"$action\" disabled=\"true\">$label</button>";
133 } else {
134 $expected .= "<button class=\"btn btn-default\" aria-label=\"$label\" aria-pressed=\"false\" data-action=\"$action\" id=\"id_1\">$label</button>";
135 }
136 }
137 $expected .= "</div>";
138
139 $this->assertHTMLEquals($expected, $html);
140 }
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317

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 71 of file ViewControlTest.php.

72 {
73 $view_control_f = $this->getViewControlFactory();
75
76 $r = $this->getDefaultRenderer();
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 $section = $view_control_f->section($back, $button, $next);
83
84 $html = $r->render($section);
85 $this->assertStringContainsString("glyphicon-chevron-left", $html);
86 $this->assertStringContainsString("glyphicon-chevron-right", $html);
87 $this->assertStringContainsString("il-viewcontrol-section", $html);
88 $this->assertStringContainsString("btn", $html);
89
90 $expected = $this->getSectionExpectedHTML();
91 $this->assertHTMLEquals($expected, $html);
92
93 $f = $this->getViewControlFactory();
94 $this->assertInstanceOf("ILIAS\\UI\\Component\\ViewControl\\Factory", $f);
95 }

References Vendor\Package\$f, $section, 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 105 of file ViewControlTest.php.

106 {
107 $f = $this->getViewControlFactory();
108 $r = $this->getDefaultRenderer();
109
110 $this->assertIsArray($f->mode($this->actions, $this->aria_label)->getLabelledActions());
111 }

References Vendor\Package\$f, ILIAS_UI_TestBase\getDefaultRenderer(), 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 58 of file ViewControlTest.php.

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

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 45 of file ViewControlTest.php.

46 {
48
49 $back = $button_f->standard("", "http://www.ilias.de");
50 $next = $button_f->standard("", "http://www.github.com");
51 $button = $button_f->standard("Today", "");
52
53 $action = $this->getViewControlFactory()->section($back, $button, $next)->getPreviousActions();
54
55 $this->assertInstanceOf("ILIAS\\UI\\Component\\Button\\Button", $action);
56 }

References getViewControlFactory().

+ Here is the call graph for this function:

◆ test_viewcontrol_with_active()

ViewControlTest::test_viewcontrol_with_active ( )

Definition at line 97 of file ViewControlTest.php.

98 {
99 $f = $this->getViewControlFactory();
100
101 $this->assertEquals($this->active, $f->mode($this->actions, $this->aria_label)->withActive($this->active)->getActive());
102 $this->assertNotEquals($this->active, $f->mode($this->actions, $this->aria_label)->withActive("Dummy text")->getActive());
103 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $actions

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

Definition at line 12 of file ViewControlTest.php.

◆ $active

ViewControlTest::$active = "Github"
protected

Definition at line 19 of file ViewControlTest.php.

Referenced by test_render_viewcontrol_mode().

◆ $aria_label

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

Definition at line 17 of file ViewControlTest.php.

◆ $role

ViewControlTest::$role = "group"
protected

Definition at line 18 of file ViewControlTest.php.


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