ILIAS  release_8 Revision v8.24
MultiSelectInputTest Class Reference
+ Inheritance diagram for MultiSelectInputTest:
+ Collaboration diagram for MultiSelectInputTest:

Public Member Functions

 setUp ()
 
 testImplementsFactoryInterface ()
 
 testOptions ()
 
 testOnlyAcceptsActualOptionsFromClientSide ()
 
 testRender ()
 
 testRenderValue ()
 
 testRenderDisabled ()
 
 testRenderNoOptions ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 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)
 

Protected Member Functions

 buildFactory ()
 
- 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

DefNamesource $name_source
 

Detailed Description

Definition at line 32 of file MultiSelectInputTest.php.

Member Function Documentation

◆ buildFactory()

MultiSelectInputTest::buildFactory ( )
protected

Definition at line 41 of file MultiSelectInputTest.php.

41 : I\Input\Field\Factory
42 {
43 $df = new Data\Factory();
44 $language = $this->createMock(ilLanguage::class);
45 return new I\Input\Field\Factory(
46 $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
47 new SignalGenerator(),
48 $df,
49 new Refinery($df, $language),
50 $language
51 );
52 }
This is a legacy support of Component\Input\Field\Input that has been moved to Component\Input\Contai...
Definition: Input.php:32
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.

Referenced by testImplementsFactoryInterface(), testOnlyAcceptsActualOptionsFromClientSide(), testOptions(), testRender(), testRenderDisabled(), testRenderNoOptions(), and testRenderValue().

+ Here is the caller graph for this function:

◆ setUp()

MultiSelectInputTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 36 of file MultiSelectInputTest.php.

36 : void
37 {
38 $this->name_source = new DefNamesource();
39 }

◆ testImplementsFactoryInterface()

MultiSelectInputTest::testImplementsFactoryInterface ( )

Definition at line 54 of file MultiSelectInputTest.php.

54 : void
55 {
56 $f = $this->buildFactory();
57 $options = array(
58 "1" => "Pick 1",
59 "2" => "Pick 2"
60 );
61 $ms = $f->multiSelect("label", $options, "byline");
62 $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $ms);
63 $this->assertInstanceOf(Field\MultiSelect::class, $ms);
64 }

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

+ Here is the call graph for this function:

◆ testOnlyAcceptsActualOptionsFromClientSide()

MultiSelectInputTest::testOnlyAcceptsActualOptionsFromClientSide ( )
Returns
string[]

Definition at line 77 of file MultiSelectInputTest.php.

77 : void
78 {
79 $this->expectException(InvalidArgumentException::class);
80 $f = $this->buildFactory();
81 $options = array(
82 "1" => "Pick 1",
83 "2" => "Pick 2"
84 );
85 $ms = $f->multiSelect("label", $options, "byline")
86 ->withNameFrom(new class () implements NameSource {
87 public function getNewName(): string
88 {
89 return "name";
90 }
91 });
92 $ms = $ms->withInput(new class () implements InputData {
96 public function getOr($_, $__): array
97 {
98 return ["3"];
99 }
100 public function get($_): void
101 {
102 }
103 public function has($name): bool
104 {
105 }
106 });
107 $ms->getContent();
108 }
Describes how Input-Elements want to interact with posted data.
Definition: InputData.php:30
Describes a source for input names.
Definition: NameSource.php:27
if($format !==null) $name
Definition: metadata.php:247
has(string $class_name)

References Vendor\Package\$f, $name, buildFactory(), and ILIAS\GlobalScreen\has().

+ Here is the call graph for this function:

◆ testOptions()

MultiSelectInputTest::testOptions ( )

Definition at line 66 of file MultiSelectInputTest.php.

66 : void
67 {
68 $f = $this->buildFactory();
69 $options = array(
70 "1" => "Pick 1",
71 "2" => "Pick 2"
72 );
73 $ms = $f->multiSelect("label", $options, "byline");
74 $this->assertEquals($options, $ms->getOptions());
75 }

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

+ Here is the call graph for this function:

◆ testRender()

MultiSelectInputTest::testRender ( )

Definition at line 110 of file MultiSelectInputTest.php.

110 : void
111 {
112 $r = $this->getDefaultRenderer();
113 $f = $this->buildFactory();
114 $options = array(
115 "1" => "Pick 1",
116 "2" => "Pick 2"
117 );
118 $ms = $f->multiSelect("label", $options, "byline")
119 ->withNameFrom($this->name_source);
120
121 $name = $ms->getName();
122 $label = $ms->getLabel();
123 $byline = $ms->getByline();
124 $expected = ""
125 . "<div class=\"form-group row\">"
126 . "<label class=\"control-label col-sm-4 col-md-3 col-lg-2\">$label</label>"
127 . "<div class=\"col-sm-8 col-md-9 col-lg-10\">"
128 . "<ul class=\"il-input-multiselect\" id=\"id_1\">";
129
130 foreach ($options as $opt_value => $opt_label) {
131 $expected .= ""
132 . "<li>"
133 . "<input type=\"checkbox\" name=\"$name" . "[]\" value=\"$opt_value\" />"
134 . "<span>$opt_label</span>"
135 . "</li>";
136 }
137
138 $expected .= ""
139 . "</ul>"
140 . "<div class=\"help-block\">$byline</div>"
141 . "</div>"
142 . "</div>";
143 $this->assertHTMLEquals($expected, $r->render($ms));
144 }
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355

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

+ Here is the call graph for this function:

◆ testRenderDisabled()

MultiSelectInputTest::testRenderDisabled ( )

Definition at line 192 of file MultiSelectInputTest.php.

192 : void
193 {
194 $r = $this->getDefaultRenderer();
195 $f = $this->buildFactory();
196 $options = array(
197 "1" => "Pick 1",
198 "2" => "Pick 2"
199 );
200 $ms = $f->multiSelect("label", $options, "byline")
201 ->withNameFrom($this->name_source)->withDisabled(true);
202
203 $name = $ms->getName();
204 $label = $ms->getLabel();
205 $byline = $ms->getByline();
206 $expected = ""
207 . "<div class=\"form-group row\">"
208 . "<label class=\"control-label col-sm-4 col-md-3 col-lg-2\">$label</label>"
209 . "<div class=\"col-sm-8 col-md-9 col-lg-10\">"
210 . "<ul class=\"il-input-multiselect\" id=\"id_1\">";
211
212 foreach ($options as $opt_value => $opt_label) {
213 $expected .= ""
214 . "<li>"
215 . "<input type=\"checkbox\" name=\"$name" . "[]\" value=\"$opt_value\" disabled=\"disabled\" />"
216 . "<span>$opt_label</span>"
217 . "</li>";
218 }
219
220 $expected .= ""
221 . "</ul>"
222 . "<div class=\"help-block\">$byline</div>"
223 . "</div>"
224 . "</div>";
225 $this->assertHTMLEquals($expected, $r->render($ms));
226 }

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

+ Here is the call graph for this function:

◆ testRenderNoOptions()

MultiSelectInputTest::testRenderNoOptions ( )

Definition at line 228 of file MultiSelectInputTest.php.

228 : void
229 {
230 $r = $this->getDefaultRenderer();
231 $f = $this->buildFactory();
232 $options = [];
233 $ms = $f->multiSelect("label", $options, "byline")
234 ->withNameFrom($this->name_source)->withDisabled(true);
235
236 $name = $ms->getName();
237 $label = $ms->getLabel();
238 $byline = $ms->getByline();
239 $expected = ""
240 . "<div class=\"form-group row\">"
241 . "<label class=\"control-label col-sm-4 col-md-3 col-lg-2\">$label</label>"
242 . "<div class=\"col-sm-8 col-md-9 col-lg-10\">"
243 . "<ul class=\"il-input-multiselect\" id=\"id_1\">"
244 . "<li>-</li>"
245 . "</ul>"
246 . "<div class=\"help-block\">$byline</div>"
247 . "</div>"
248 . "</div>";
249
250 $this->assertHTMLEquals($expected, $r->render($ms));
251 }

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

+ Here is the call graph for this function:

◆ testRenderValue()

MultiSelectInputTest::testRenderValue ( )

Definition at line 146 of file MultiSelectInputTest.php.

146 : void
147 {
148 $r = $this->getDefaultRenderer();
149 $f = $this->buildFactory();
150 $options = array(
151 "1" => "Pick 1",
152 "2" => "Pick 2"
153 );
154 $value = array_keys($options)[1];
155 $ms = $f->multiSelect("label", $options, "byline")
156 ->withNameFrom($this->name_source)
157 ->withValue([$value]);
158
159 $name = $ms->getName();
160 $label = $ms->getLabel();
161 $byline = $ms->getByline();
162 $expected = ""
163 . "<div class=\"form-group row\">"
164 . "<label class=\"control-label col-sm-4 col-md-3 col-lg-2\">$label</label>"
165 . "<div class=\"col-sm-8 col-md-9 col-lg-10\">"
166 . "<ul class=\"il-input-multiselect\" id=\"id_1\">";
167
168 foreach ($options as $opt_value => $opt_label) {
169 if ($opt_value === $value) {
170 $expected .= ""
171 . "<li>"
172 . "<input type=\"checkbox\" name=\"$name" . "[]\" value=\"$opt_value\" checked=\"checked\" />"
173 . "<span>$opt_label</span>"
174 . "</li>";
175 } else {
176 $expected .= ""
177 . "<li>"
178 . "<input type=\"checkbox\" name=\"$name" . "[]\" value=\"$opt_value\" />"
179 . "<span>$opt_label</span>"
180 . "</li>";
181 }
182 }
183
184 $expected .= ""
185 . "</ul>"
186 . "<div class=\"help-block\">$byline</div>"
187 . "</div>"
188 . "</div>";
189 $this->assertHTMLEquals($expected, $r->render($ms));
190 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $name_source

DefNamesource MultiSelectInputTest::$name_source
protected

Definition at line 34 of file MultiSelectInputTest.php.


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