ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ()
 
- 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

 buildFactory ()
 

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.

23 {
24 $df = new Data\Factory();
26 new SignalGenerator(),
27 $df,
28 new Validation\Factory($df, $this->createMock(\ilLanguage::class)),
30 );
31 }
Builds data types.
Definition: Factory.php:15
A transformation is a function from one datatype to another.

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

+ Here is the caller graph for this function:

◆ setUp()

MultiSelectInputTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 17 of file MultiSelectInputTest.php.

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

◆ test_implements_factory_interface()

MultiSelectInputTest::test_implements_factory_interface ( )

Definition at line 34 of file MultiSelectInputTest.php.

35 {
36 $f = $this->buildFactory();
37 $options = array(
38 "1" => "Pick 1",
39 "2" => "Pick 2"
40 );
41 $ms = $f->multiSelect("label", $options, "byline");
42 $this->assertInstanceOf(Field\Input::class, $ms);
43 $this->assertInstanceOf(Field\MultiSelect::class, $ms);
44 }

References $f, PHPMailer\PHPMailer\$options, and buildFactory().

+ 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 59 of file MultiSelectInputTest.php.

60 {
61 $this->expectException(\InvalidArgumentException::class);
62 $f = $this->buildFactory();
63 $options = array(
64 "1" => "Pick 1",
65 "2" => "Pick 2"
66 );
67 $ms = $f->multiSelect("label", $options, "byline");
68 $ms = $ms->withInput(new class() implements PostData {
69 public function getOr($_, $__)
70 {
71 return ["3"];
72 }
73 public function get($_)
74 {
75 }
76 });
77 $content = $ms->getContent();
78 }
Describes how Input-Elements want to interact with posted data.
Definition: PostData.php:13

References $f, PHPMailer\PHPMailer\$options, and buildFactory().

+ Here is the call graph for this function:

◆ test_options()

MultiSelectInputTest::test_options ( )

Definition at line 47 of file MultiSelectInputTest.php.

48 {
49 $f = $this->buildFactory();
50 $options = array(
51 "1" => "Pick 1",
52 "2" => "Pick 2"
53 );
54 $ms = $f->multiSelect("label", $options, "byline");
55 $this->assertEquals($options, $ms->getOptions());
56 }

References $f, PHPMailer\PHPMailer\$options, and buildFactory().

+ Here is the call graph for this function:

◆ test_render()

MultiSelectInputTest::test_render ( )

Definition at line 81 of file MultiSelectInputTest.php.

82 {
83 $r = $this->getDefaultRenderer();
84 $f = $this->buildFactory();
85 $options = array(
86 "1" => "Pick 1",
87 "2" => "Pick 2"
88 );
89 $ms = $f->multiSelect("label", $options, "byline")
90 ->withNameFrom($this->name_source);
91
92 $name = $ms->getName();
93 $label = $ms->getLabel();
94 $byline = $ms->getByline();
95 $expected = ""
96 . "<div class=\"form-group row\">"
97 . "<label for=\"$name\" class=\"control-label col-sm-3\">$label</label>"
98 . "<div class=\"col-sm-9\">"
99 . "<ul class=\"il-input-multiselect\">";
100
101 foreach ($options as $opt_value => $opt_label) {
102 $expected .= ""
103 . "<li>"
104 . "<input type=\"checkbox\" name=\"$name" . "[]\" value=\"$opt_value\" />"
105 . "<span>$opt_label</span>"
106 . "</li>";
107 }
108
109 $expected .= ""
110 . "</ul>"
111 . "<div class=\"help-block\">$byline</div>"
112 . "</div>"
113 . "</div>";
114 $this->assertHTMLEquals($expected, $r->render($ms));
115 }
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
$r
Definition: example_031.php:79

References $f, $name, PHPMailer\PHPMailer\$options, $r, ILIAS_UI_TestBase\assertHTMLEquals(), buildFactory(), and ILIAS_UI_TestBase\getDefaultRenderer().

+ Here is the call graph for this function:

◆ test_render_value()

MultiSelectInputTest::test_render_value ( )

Definition at line 118 of file MultiSelectInputTest.php.

119 {
120 $r = $this->getDefaultRenderer();
121 $f = $this->buildFactory();
122 $options = array(
123 "1" => "Pick 1",
124 "2" => "Pick 2"
125 );
126 $value = array_keys($options)[1];
127 $ms = $f->multiSelect("label", $options, "byline")
128 ->withNameFrom($this->name_source)
129 ->withValue([$value]);
130
131 $name = $ms->getName();
132 $label = $ms->getLabel();
133 $byline = $ms->getByline();
134 $expected = ""
135 . "<div class=\"form-group row\">"
136 . "<label for=\"$name\" class=\"control-label col-sm-3\">$label</label>"
137 . "<div class=\"col-sm-9\">"
138 . "<ul class=\"il-input-multiselect\">";
139
140 foreach ($options as $opt_value => $opt_label) {
141 if ($opt_value === $value) {
142 $expected .= ""
143 . "<li>"
144 . "<input type=\"checkbox\" name=\"$name" . "[]\" value=\"$opt_value\" checked=\"checked\" />"
145 . "<span>$opt_label</span>"
146 . "</li>";
147 } else {
148 $expected .= ""
149 . "<li>"
150 . "<input type=\"checkbox\" name=\"$name" . "[]\" value=\"$opt_value\" />"
151 . "<span>$opt_label</span>"
152 . "</li>";
153 }
154 }
155
156 $expected .= ""
157 . "</ul>"
158 . "<div class=\"help-block\">$byline</div>"
159 . "</div>"
160 . "</div>";
161 $this->assertHTMLEquals($expected, $r->render($ms));
162 }

References $f, $name, PHPMailer\PHPMailer\$options, $r, ILIAS_UI_TestBase\assertHTMLEquals(), buildFactory(), and ILIAS_UI_TestBase\getDefaultRenderer().

+ Here is the call graph for this function:

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