ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 10 of file ViewControlTest.php.

Member Function Documentation

◆ getSectionExpectedHTML()

ViewControlTest::getSectionExpectedHTML ( )
protected

Definition at line 170 of file ViewControlTest.php.

References data.

Referenced by test_render_viewcontrol_section().

171  {
172  $expected = <<<EOT
173 <div class="il-viewcontrol-section">
174 <a class="btn btn-default " href="http://www.ilias.de" data-action="http://www.ilias.de"><span class="glyphicon glyphicon-chevron-left"></span></a>
175 <button class="btn btn-default" data-action="">Today</button>
176 <a class="btn btn-default " href="http://www.github.com" data-action="http://www.github.com"><span class="glyphicon glyphicon-chevron-right"></span></a>
177 </div>
178 EOT;
179  return $expected;
180  }
$this data['403_header']
+ Here is the caller graph for this function:

◆ getUIFactory()

ViewControlTest::getUIFactory ( )

Definition at line 144 of file ViewControlTest.php.

145  {
146  return new \ILIAS\UI\Implementation\Factory(
147  new I\Component\Counter\Factory(),
148  $this->createMock(C\Glyph\Factory::class),
149  new I\Component\Button\Factory,
150  $this->createMock(C\Listing\Factory::class),
151  $this->createMock(C\Image\Factory::class),
152  $this->createMock(C\Panel\Factory::class),
153  $this->createMock(C\Modal\Factory::class),
154  $this->createMock(C\Dropzone\Factory::class),
155  $this->createMock(C\Popover\Factory::class),
156  $this->createMock(C\Divider\Factory::class),
157  $this->createMock(C\Link\Factory::class),
158  $this->createMock(C\Dropdown\Factory::class),
159  $this->createMock(C\Item\Factory::class),
160  $this->createMock(C\Icon\Factory::class),
161  $this->createMock(C\ViewControl\Factory::class),
162  $this->createMock(C\Chart\Factory::class),
163  $this->createMock(C\Input\Factory::class),
164  $this->createMock(C\Table\Factory::class),
165  $this->createMock(C\MessageBox\Factory::class),
166  $this->createMock(C\Card\Factory::class)
167  );
168  }

◆ getViewControlFactory()

◆ test_implements_factory_interface()

ViewControlTest::test_implements_factory_interface ( )

Definition at line 26 of file ViewControlTest.php.

References $section, and getViewControlFactory().

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
+ Here is the call graph for this function:

◆ test_render_viewcontrol_mode()

ViewControlTest::test_render_viewcontrol_mode ( )

Definition at line 115 of file ViewControlTest.php.

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

116  {
117  $f = $this->getViewControlFactory();
118  $r = $this->getDefaultRenderer();
119  $mode = $f->mode($this->actions, $this->aria_label);
120 
121  $html = $this->normalizeHTML($r->render($mode));
122 
123  $active = $mode->getActive();
124  if ($active == "") {
125  $activate_first_item = true;
126  }
127 
128  $expected = "<div class=\"btn-group il-viewcontrol-mode\" aria-label=\"" . $this->aria_label . "\" role=\"" . $this->role . "\">";
129  foreach ($this->actions as $label => $action) {
130  if ($activate_first_item) {
131  $expected .= "<button class=\"btn btn-default ilSubmitInactive disabled\" aria-label=\"$label\" aria-checked=\"true\" data-action=\"$action\">$label</button>";
132  $activate_first_item = false;
133  } elseif ($active == $label) {
134  $expected .= "<button class=\"btn btn-default ilSubmitInactive disabled \" aria-label=\"$label\" aria-checked=\"true\" data-action=\"$action\">$label</button>";
135  } else {
136  $expected .= "<button class=\"btn btn-default\" aria-label=\"$label\" data-action=\"$action\" id=\"id_1\">$label</button>";
137  }
138  }
139  $expected .= "</div>";
140 
141  $this->assertHTMLEquals($expected, $html);
142  }
$action
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
$r
Definition: example_031.php:79
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
$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 71 of file ViewControlTest.php.

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

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->assertContains("glyphicon-chevron-left", $html);
86  $this->assertContains("glyphicon-chevron-right", $html);
87  $this->assertContains("il-viewcontrol-section", $html);
88  //$this->assertContains('back', $html);
89  //$this->assertContains('next', $html);
90  $this->assertContains("btn", $html);
91 
92  $expected = $this->getSectionExpectedHTML();
93  $this->assertHTMLEquals($expected, $html);
94 
95  $f = $this->getViewControlFactory();
96  $this->assertInstanceOf("ILIAS\\UI\\Component\\ViewControl\\Factory", $f);
97  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
$section
Definition: Utf8Test.php:83
$r
Definition: example_031.php:79
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
$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 107 of file ViewControlTest.php.

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

108  {
109  $f = $this->getViewControlFactory();
110  $r = $this->getDefaultRenderer();
111 
112  $this->assertInternalType("array", $f->mode($this->actions, $this->aria_label)->getLabelledActions());
113  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
$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 58 of file ViewControlTest.php.

References $action, and getViewControlFactory().

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

References $action, and getViewControlFactory().

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  }
$action
+ Here is the call graph for this function:

◆ test_viewcontrol_with_active()

ViewControlTest::test_viewcontrol_with_active ( )

Definition at line 99 of file ViewControlTest.php.

References $f, and getViewControlFactory().

100  {
101  $f = $this->getViewControlFactory();
102 
103  $this->assertEquals($this->active, $f->mode($this->actions, $this->aria_label)->withActive($this->active)->getActive());
104  $this->assertNotEquals($this->active, $f->mode($this->actions, $this->aria_label)->withActive("Dummy text")->getActive());
105  }
+ 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: