ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Protected Member Functions

 getSectionExpectedHTML ()
 

Protected Attributes

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

Detailed Description

Definition at line 9 of file ViewControlTest.php.

Member Function Documentation

◆ getSectionExpectedHTML()

ViewControlTest::getSectionExpectedHTML ( )
protected

Definition at line 148 of file ViewControlTest.php.

References data.

Referenced by test_render_viewcontrol_section().

149  {
150  $expected = <<<EOT
151 <div class="il-viewcontrol-section">
152 <a class="btn btn-default " type="button"
153  href="http://www.ilias.de" data-action="http://www.ilias.de"
154  ><span class="glyphicon glyphicon-chevron-left"></span></a>
155 <a class="btn btn-default" href="" data-action="">Today</a>
156 <a class="btn btn-default " type="button"
157  href="http://www.github.com" data-action="http://www.github.com"
158  ><span class="glyphicon glyphicon-chevron-right"></span></a>
159 </div>
160 EOT;
161  return $expected;
162  }
Add some data
+ Here is the caller graph for this function:

◆ getUIFactory()

ViewControlTest::getUIFactory ( )

Definition at line 143 of file ViewControlTest.php.

144  {
145  return new \ILIAS\UI\Implementation\Factory();
146  }

◆ getViewControlFactory()

ViewControlTest::getViewControlFactory ( )

◆ test_implements_factory_interface()

ViewControlTest::test_implements_factory_interface ( )

Definition at line 25 of file ViewControlTest.php.

References $section, and getViewControlFactory().

26  {
27  $view_control_f = $this->getViewControlFactory();
29 
30  $back = $button_f->standard("", "http://www.ilias.de");
31  $next = $button_f->standard("", "http://www.github.com");
32  $button = $button_f->standard("Today", "");
33 
34  $this->assertInstanceOf("ILIAS\\UI\\Component\\Button\\Button", $back);
35  $this->assertInstanceOf("ILIAS\\UI\\Component\\Button\\Button", $next);
36  $this->assertInstanceOf("ILIAS\\UI\\Component\\Button\\Button", $button);
37  $this->assertInstanceOf("ILIAS\\UI\\Component\\ViewControl\\Factory", $view_control_f);
38 
39  $section = $view_control_f->section($back, $button, $next);
40  $this->assertInstanceOf("ILIAS\\UI\\Component\\ViewControl\\Section", $section);
41  }
$section
Definition: Utf8Test.php:83
+ Here is the call graph for this function:

◆ test_render_viewcontrol_mode()

ViewControlTest::test_render_viewcontrol_mode ( )

Definition at line 114 of file ViewControlTest.php.

References $action, $active, $html, $r, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\getDefaultRenderer(), getViewControlFactory(), and ILIAS_UI_TestBase\normalizeHTML().

115  {
116  $f = $this->getViewControlFactory();
117  $r = $this->getDefaultRenderer();
118  $mode = $f->mode($this->actions, $this->aria_label);
119 
120  $html = $this->normalizeHTML($r->render($mode));
121 
122  $active = $mode->getActive();
123  if ($active == "") {
124  $activate_first_item = true;
125  }
126 
127  $expected = "<div class=\"btn-group il-viewcontrol-mode\" aria-label=\"" . $this->aria_label . "\" role=\"" . $this->role . "\">";
128  foreach ($this->actions as $label => $action) {
129  if ($activate_first_item) {
130  $expected .= "<a class=\"btn btn-default ilSubmitInactive disabled\" aria-label=\"$label\" aria-checked=\"true\" data-action=\"$action\">$label</a>";
131  $activate_first_item = false;
132  } elseif ($active == $label) {
133  $expected .= "<a class=\"btn btn-default ilSubmitInactive disabled \" aria-label=\"$label\" aria-checked=\"true\" data-action=\"$action\">$label</a>";
134  } else {
135  $expected .= "<a class=\"btn btn-default\" href=\"$action\" aria-label=\"$label\" data-action=\"$action\">$label</a>";
136  }
137  }
138  $expected .= "</div>";
139 
140  $this->assertHTMLEquals($expected, $html);
141  }
$action
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:216
normalizeHTML($html)
Definition: Base.php:243
$r
Definition: example_031.php:79
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:252
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ test_render_viewcontrol_section()

ViewControlTest::test_render_viewcontrol_section ( )

Definition at line 70 of file ViewControlTest.php.

References $html, $r, $section, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\getDefaultRenderer(), getSectionExpectedHTML(), and getViewControlFactory().

71  {
72  $view_control_f = $this->getViewControlFactory();
74 
75  $r = $this->getDefaultRenderer();
76 
77  $back = $button_f->standard("", "http://www.ilias.de");
78  $next = $button_f->standard("", "http://www.github.com");
79  $button = $button_f->standard("Today", "");
80 
81  $section = $view_control_f->section($back, $button, $next);
82 
83  $html = $r->render($section);
84  $this->assertContains("glyphicon-chevron-left", $html);
85  $this->assertContains("glyphicon-chevron-right", $html);
86  $this->assertContains("il-viewcontrol-section", $html);
87  //$this->assertContains('back', $html);
88  //$this->assertContains('next', $html);
89  $this->assertContains("btn", $html);
90 
91  $expected = $this->getSectionExpectedHTML();
92  $this->assertHTMLEquals($expected, $html);
93 
94  $f = $this->getViewControlFactory();
95  $this->assertInstanceOf("ILIAS\\UI\\Component\\ViewControl\\Factory", $f);
96  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:216
$section
Definition: Utf8Test.php:83
$r
Definition: example_031.php:79
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:252
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ test_viewcontrol_get_actions()

ViewControlTest::test_viewcontrol_get_actions ( )

Definition at line 106 of file ViewControlTest.php.

References $r, ILIAS_UI_TestBase\getDefaultRenderer(), and getViewControlFactory().

107  {
108  $f = $this->getViewControlFactory();
109  $r = $this->getDefaultRenderer();
110 
111  $this->assertInternalType("array", $f->mode($this->actions, $this->aria_label)->getLabelledActions());
112  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:216
$r
Definition: example_031.php:79
+ Here is the call graph for this function:

◆ test_viewcontrol_section_get_next_actions()

ViewControlTest::test_viewcontrol_section_get_next_actions ( )

Definition at line 57 of file ViewControlTest.php.

References $action, and getViewControlFactory().

58  {
60 
61  $back = $button_f->standard("", "http://www.ilias.de");
62  $next = $button_f->standard("", "http://www.github.com");
63  $button = $button_f->standard("Today", "");
64 
65  $action = $this->getViewControlFactory()->section($back, $button, $next)->getNextActions();
66 
67  $this->assertInstanceOf("ILIAS\\UI\\Component\\Button\\Button", $action);
68  }
$action
+ Here is the call graph for this function:

◆ test_viewcontrol_section_get_previous_actions()

ViewControlTest::test_viewcontrol_section_get_previous_actions ( )

Definition at line 44 of file ViewControlTest.php.

References $action, and getViewControlFactory().

45  {
47 
48  $back = $button_f->standard("", "http://www.ilias.de");
49  $next = $button_f->standard("", "http://www.github.com");
50  $button = $button_f->standard("Today", "");
51 
52  $action = $this->getViewControlFactory()->section($back, $button, $next)->getPreviousActions();
53 
54  $this->assertInstanceOf("ILIAS\\UI\\Component\\Button\\Button", $action);
55  }
$action
+ Here is the call graph for this function:

◆ test_viewcontrol_with_active()

ViewControlTest::test_viewcontrol_with_active ( )

Definition at line 98 of file ViewControlTest.php.

References getViewControlFactory().

99  {
100  $f = $this->getViewControlFactory();
101 
102  $this->assertEquals($this->active, $f->mode($this->actions, $this->aria_label)->withActive($this->active)->getActive());
103  $this->assertNotEquals($this->active, $f->mode($this->actions, $this->aria_label)->withActive("Dummy text")->getActive());
104  }
+ Here is the call graph for this function:

Field Documentation

◆ $actions

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

Definition at line 11 of file ViewControlTest.php.

◆ $active

ViewControlTest::$active = "Github"
protected

Definition at line 18 of file ViewControlTest.php.

Referenced by test_render_viewcontrol_mode().

◆ $aria_label

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

Definition at line 16 of file ViewControlTest.php.

◆ $role

ViewControlTest::$role = "group"
protected

Definition at line 17 of file ViewControlTest.php.


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