ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ViewControlTest Class Reference
+ Inheritance diagram for ViewControlTest:
+ Collaboration diagram for ViewControlTest:

Public Member Functions

 getViewControlFactory ()
 
 testImplementsFactoryInterface ()
 
 testViewControlSectionGetPreviousActions ()
 
 testViewControlSectionGetNextActions ()
 
 testRenderViewControlSection ()
 
 testViewControlWithActive ()
 
 testViewControlGetActions ()
 
 testViewControlModeRender ()
 
 getUIFactory ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getHelpTextRetriever ()
 
 getUploadLimitResolver ()
 
 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)
 

Data Fields

array Github
 

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.

References ILIAS\Repository\button().

Referenced by testRenderViewControlSection().

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>
180 EOT;
181  }
button(string $caption, string $cmd)
+ 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.

References ILIAS\Repository\button().

158  : NoUIFactory
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  }
button(string $caption, string $cmd)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ getViewControlFactory()

ViewControlTest::getViewControlFactory ( )

Definition at line 39 of file ViewControlTest.php.

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

39  : I\Component\ViewControl\Factory
40  {
41  return new I\Component\ViewControl\Factory(new SignalGenerator());
42  }
+ Here is the caller graph for this function:

◆ testImplementsFactoryInterface()

ViewControlTest::testImplementsFactoryInterface ( )

Definition at line 44 of file ViewControlTest.php.

References getViewControlFactory().

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

◆ testRenderViewControlSection()

ViewControlTest::testRenderViewControlSection ( )

Definition at line 87 of file ViewControlTest.php.

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

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  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:475
$r
+ Here is the call graph for this function:

◆ testViewControlGetActions()

ViewControlTest::testViewControlGetActions ( )

Definition at line 121 of file ViewControlTest.php.

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

121  : void
122  {
123  $f = $this->getViewControlFactory();
124 
125  $this->assertIsArray($f->mode($this->actions, $this->aria_label)->getLabelledActions());
126  }
+ Here is the call graph for this function:

◆ testViewControlModeRender()

ViewControlTest::testViewControlModeRender ( )

Definition at line 128 of file ViewControlTest.php.

References Vendor\Package\$f, $r, ILIAS_UI_TestBase\brutallyTrimHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), getViewControlFactory(), and ILIAS_UI_TestBase\normalizeHTML().

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-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->assertEquals($this->brutallyTrimHTML($expected), $this->brutallyTrimHTML($html));
156  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:475
normalizeHTML(string $html)
Definition: Base.php:453
$r
+ Here is the call graph for this function:

◆ testViewControlSectionGetNextActions()

ViewControlTest::testViewControlSectionGetNextActions ( )

Definition at line 74 of file ViewControlTest.php.

References getViewControlFactory().

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

◆ testViewControlSectionGetPreviousActions()

ViewControlTest::testViewControlSectionGetPreviousActions ( )

Definition at line 61 of file ViewControlTest.php.

References getViewControlFactory().

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

◆ testViewControlWithActive()

ViewControlTest::testViewControlWithActive ( )

Definition at line 113 of file ViewControlTest.php.

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

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

Field Documentation

◆ $actions

array ViewControlTest::$actions
protected
Initial value:
= [
"ILIAS" => "http://www.ilias.de"

Definition at line 30 of file ViewControlTest.php.

◆ $active

string ViewControlTest::$active = "Github"
protected

Definition at line 37 of file ViewControlTest.php.

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

◆ Github

array ViewControlTest::Github
Initial value:
=> "http://www.github.com"
]

Definition at line 32 of file ViewControlTest.php.


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