ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
MultiSelectInputTest Class Reference
+ Inheritance diagram for MultiSelectInputTest:
+ Collaboration diagram for MultiSelectInputTest:

Public Member Functions

 setUp ()
 
 test_implements_factory_interface ()
 
 test_options ()
 
 test_only_accepts_actual_options_from_client_side ()
 
 test_render ()
 
 test_render_value ()
 
 test_render_disabled ()
 
- 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

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

Detailed Description

Definition at line 15 of file MultiSelectInputTest.php.

Member Function Documentation

◆ buildFactory()

MultiSelectInputTest::buildFactory ( )
protected

Definition at line 22 of file MultiSelectInputTest.php.

Referenced by test_implements_factory_interface(), test_only_accepts_actual_options_from_client_side(), test_options(), test_render(), test_render_disabled(), and test_render_value().

23  {
24  $df = new Data\Factory();
25  $language = $this->createMock(\ilLanguage::class);
27  new SignalGenerator(),
28  $df,
29  new \ILIAS\Refinery\Factory($df, $language),
30  $language
31  );
32  }
Class ChatMainBarProvider .
Builds data types.
Definition: Factory.php:19
+ Here is the caller graph for this function:

◆ setUp()

MultiSelectInputTest::setUp ( )

Definition at line 17 of file MultiSelectInputTest.php.

17  : void
18  {
19  $this->name_source = new DefNamesource();
20  }

◆ test_implements_factory_interface()

MultiSelectInputTest::test_implements_factory_interface ( )

Definition at line 35 of file MultiSelectInputTest.php.

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

36  {
37  $f = $this->buildFactory();
38  $options = array(
39  "1" => "Pick 1",
40  "2" => "Pick 2"
41  );
42  $ms = $f->multiSelect("label", $options, "byline");
43  $this->assertInstanceOf(Field\Input::class, $ms);
44  $this->assertInstanceOf(Field\MultiSelect::class, $ms);
45  }
+ Here is the call graph for this function:

◆ test_only_accepts_actual_options_from_client_side()

MultiSelectInputTest::test_only_accepts_actual_options_from_client_side ( )

Definition at line 60 of file MultiSelectInputTest.php.

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

61  {
62  $this->expectException(\InvalidArgumentException::class);
63  $f = $this->buildFactory();
64  $options = array(
65  "1" => "Pick 1",
66  "2" => "Pick 2"
67  );
68  $ms = $f->multiSelect("label", $options, "byline")
69  ->withNameFrom(new class() implements NameSource {
70  public function getNewName()
71  {
72  return "name";
73  }
74  });
75  $ms = $ms->withInput(new class() implements InputData {
76  public function getOr($_, $__)
77  {
78  return ["3"];
79  }
80  public function get($_)
81  {
82  }
83  });
84  $content = $ms->getContent();
85  }
Describes how Input-Elements want to interact with posted data.
Definition: InputData.php:12
Describes a source for input names.
Definition: NameSource.php:10
+ Here is the call graph for this function:

◆ test_options()

MultiSelectInputTest::test_options ( )

Definition at line 48 of file MultiSelectInputTest.php.

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

49  {
50  $f = $this->buildFactory();
51  $options = array(
52  "1" => "Pick 1",
53  "2" => "Pick 2"
54  );
55  $ms = $f->multiSelect("label", $options, "byline");
56  $this->assertEquals($options, $ms->getOptions());
57  }
+ Here is the call graph for this function:

◆ test_render()

MultiSelectInputTest::test_render ( )

Definition at line 88 of file MultiSelectInputTest.php.

References Vendor\Package\$f, $name, ILIAS_UI_TestBase\assertHTMLEquals(), buildFactory(), and ILIAS_UI_TestBase\getDefaultRenderer().

89  {
90  $r = $this->getDefaultRenderer();
91  $f = $this->buildFactory();
92  $options = array(
93  "1" => "Pick 1",
94  "2" => "Pick 2"
95  );
96  $ms = $f->multiSelect("label", $options, "byline")
97  ->withNameFrom($this->name_source);
98 
99  $name = $ms->getName();
100  $label = $ms->getLabel();
101  $byline = $ms->getByline();
102  $expected = ""
103  . "<div class=\"form-group row\">"
104  . "<label for=\"$name\" class=\"control-label col-sm-3\">$label</label>"
105  . "<div class=\"col-sm-9\">"
106  . "<ul class=\"il-input-multiselect\">";
107 
108  foreach ($options as $opt_value => $opt_label) {
109  $expected .= ""
110  . "<li>"
111  . "<input type=\"checkbox\" name=\"$name" . "[]\" value=\"$opt_value\" />"
112  . "<span>$opt_label</span>"
113  . "</li>";
114  }
115 
116  $expected .= ""
117  . "</ul>"
118  . "<div class=\"help-block\">$byline</div>"
119  . "</div>"
120  . "</div>";
121  $this->assertHTMLEquals($expected, $r->render($ms));
122  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
if($format !==null) $name
Definition: metadata.php:230
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

◆ test_render_disabled()

MultiSelectInputTest::test_render_disabled ( )

Definition at line 171 of file MultiSelectInputTest.php.

References Vendor\Package\$f, $name, ILIAS_UI_TestBase\assertHTMLEquals(), buildFactory(), and ILIAS_UI_TestBase\getDefaultRenderer().

172  {
173  $r = $this->getDefaultRenderer();
174  $f = $this->buildFactory();
175  $options = array(
176  "1" => "Pick 1",
177  "2" => "Pick 2"
178  );
179  $ms = $f->multiSelect("label", $options, "byline")
180  ->withNameFrom($this->name_source)->withDisabled(true);
181 
182  $name = $ms->getName();
183  $label = $ms->getLabel();
184  $byline = $ms->getByline();
185  $expected = ""
186  . "<div class=\"form-group row\">"
187  . "<label for=\"$name\" class=\"control-label col-sm-3\">$label</label>"
188  . "<div class=\"col-sm-9\">"
189  . "<ul class=\"il-input-multiselect\">";
190 
191  foreach ($options as $opt_value => $opt_label) {
192  $expected .= ""
193  . "<li>"
194  . "<input type=\"checkbox\" name=\"$name" . "[]\" value=\"$opt_value\" disabled=\"disabled\" />"
195  . "<span>$opt_label</span>"
196  . "</li>";
197  }
198 
199  $expected .= ""
200  . "</ul>"
201  . "<div class=\"help-block\">$byline</div>"
202  . "</div>"
203  . "</div>";
204  $this->assertHTMLEquals($expected, $r->render($ms));
205  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
if($format !==null) $name
Definition: metadata.php:230
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

◆ test_render_value()

MultiSelectInputTest::test_render_value ( )

Definition at line 125 of file MultiSelectInputTest.php.

References Vendor\Package\$f, $name, ILIAS_UI_TestBase\assertHTMLEquals(), buildFactory(), and ILIAS_UI_TestBase\getDefaultRenderer().

126  {
127  $r = $this->getDefaultRenderer();
128  $f = $this->buildFactory();
129  $options = array(
130  "1" => "Pick 1",
131  "2" => "Pick 2"
132  );
133  $value = array_keys($options)[1];
134  $ms = $f->multiSelect("label", $options, "byline")
135  ->withNameFrom($this->name_source)
136  ->withValue([$value]);
137 
138  $name = $ms->getName();
139  $label = $ms->getLabel();
140  $byline = $ms->getByline();
141  $expected = ""
142  . "<div class=\"form-group row\">"
143  . "<label for=\"$name\" class=\"control-label col-sm-3\">$label</label>"
144  . "<div class=\"col-sm-9\">"
145  . "<ul class=\"il-input-multiselect\">";
146 
147  foreach ($options as $opt_value => $opt_label) {
148  if ($opt_value === $value) {
149  $expected .= ""
150  . "<li>"
151  . "<input type=\"checkbox\" name=\"$name" . "[]\" value=\"$opt_value\" checked=\"checked\" />"
152  . "<span>$opt_label</span>"
153  . "</li>";
154  } else {
155  $expected .= ""
156  . "<li>"
157  . "<input type=\"checkbox\" name=\"$name" . "[]\" value=\"$opt_value\" />"
158  . "<span>$opt_label</span>"
159  . "</li>";
160  }
161  }
162 
163  $expected .= ""
164  . "</ul>"
165  . "<div class=\"help-block\">$byline</div>"
166  . "</div>"
167  . "</div>";
168  $this->assertHTMLEquals($expected, $r->render($ms));
169  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
if($format !==null) $name
Definition: metadata.php:230
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

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