ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
PasswordInputTest Class Reference
+ Inheritance diagram for PasswordInputTest:
+ Collaboration diagram for PasswordInputTest:

Public Member Functions

 setUp ()
 
 test_implements_factory_interface ()
 
 test_render ()
 
 test_render_error ()
 
 test_render_no_byline ()
 
 test_render_value ()
 
 test_render_required ()
 
 test_render_disabled ()
 
 test_value_required ()
 
 test_value_type ()
 
- 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 27 of file PasswordInputTest.php.

Member Function Documentation

◆ buildFactory()

PasswordInputTest::buildFactory ( )
protected

Definition at line 35 of file PasswordInputTest.php.

36 {
37 $df = new Data\Factory();
38 $language = $this->createMock(\ilLanguage::class);
40 new SignalGenerator(),
41 $df,
42 new \ILIAS\Refinery\Factory($df, $language),
43 $language
44 );
45 }
Builds data types.
Definition: Factory.php:20
Class ChatMainBarProvider \MainMenu\Provider.

Referenced by test_implements_factory_interface(), test_render(), test_render_disabled(), test_render_error(), test_render_no_byline(), test_render_required(), test_render_value(), test_value_required(), and test_value_type().

+ Here is the caller graph for this function:

◆ setUp()

PasswordInputTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 29 of file PasswordInputTest.php.

29 : void
30 {
31 $this->name_source = new DefNamesource();
32 }

◆ test_implements_factory_interface()

PasswordInputTest::test_implements_factory_interface ( )

Definition at line 48 of file PasswordInputTest.php.

49 {
50 $f = $this->buildFactory();
51 $pwd = $f->password("label", "byline");
52 $this->assertInstanceOf(Field\Input::class, $pwd);
53 $this->assertInstanceOf(Field\Password::class, $pwd);
54 }

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

+ Here is the call graph for this function:

◆ test_render()

PasswordInputTest::test_render ( )

Definition at line 57 of file PasswordInputTest.php.

58 {
59 $f = $this->buildFactory();
60 $label = "label";
61 $byline = "byline";
62 $name = "name_0";
63 $pwd = $f->password($label, $byline)->withNameFrom($this->name_source);
64
65 $r = $this->getDefaultRenderer();
66 $expected = ""
67 . "<div class=\"form-group row\">"
68 . "<label for=\"$name\" class=\"control-label col-sm-3\">$label</label>"
69 . "<div class=\"col-sm-9\">"
70 . "<div class=\"il-input-password\">"
71 . "<input type=\"password\" name=\"$name\" class=\"form-control form-control-sm\" />"
72 . "</div>"
73 . "<div class=\"help-block\">$byline</div>"
74 . "</div>"
75 . "</div>";
76 $this->assertHTMLEquals($expected, $r->render($pwd));
77 }
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
if($format !==null) $name
Definition: metadata.php:230

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

+ Here is the call graph for this function:

◆ test_render_disabled()

PasswordInputTest::test_render_disabled ( )

Definition at line 182 of file PasswordInputTest.php.

183 {
184 $f = $this->buildFactory();
185 $label = "label";
186 $name = "name_0";
187 $pwd = $f->password($label)->withNameFrom($this->name_source)->withDisabled(true);
188
189 $r = $this->getDefaultRenderer();
190 $html = $r->render($pwd);
191
192 $expected = ""
193 . "<div class=\"form-group row\">"
194 . "<label for=\"$name\" class=\"control-label col-sm-3\">$label</label>"
195 . "<div class=\"col-sm-9\">"
196 . "<div class=\"il-input-password\">"
197 . "<input type=\"password\" name=\"$name\" disabled=\"disabled\" class=\"form-control form-control-sm\" />"
198 . "</div>"
199 . "</div>"
200 . "</div>";
201 $this->assertHTMLEquals($expected, $html);
202 }

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

+ Here is the call graph for this function:

◆ test_render_error()

PasswordInputTest::test_render_error ( )

Definition at line 80 of file PasswordInputTest.php.

81 {
82 $f = $this->buildFactory();
83 $label = "label";
84 $byline = "byline";
85 $name = "name_0";
86 $error = "an_error";
87 $pwd = $f->password($label, $byline)->withNameFrom($this->name_source)->withError($error);
88
89 $r = $this->getDefaultRenderer();
90 $html = $this->normalizeHTML($r->render($pwd));
91 $expected = ""
92 . "<div class=\"form-group row\">"
93 . " <label for=\"$name\" class=\"control-label col-sm-3\">$label</label>"
94 . " <div class=\"col-sm-9\">"
95 . " <div class=\"il-input-password\">"
96 . " <input type=\"password\" name=\"$name\" class=\"form-control form-control-sm\" />"
97 . " </div>"
98 . " <div class=\"help-block\">$byline</div>"
99 . " <div class=\"help-block alert alert-danger\" role=\"alert\">"
100 . " <img border=\"0\" src=\"./templates/default/images/icon_alert.svg\" alt=\"alert\" />"
101 . " $error"
102 . " </div>"
103 . " </div>"
104 . "</div>";
105
106 $html = preg_replace('!\s+!', ' ', $html);
107 $expected = preg_replace('!\s+!', ' ', $expected);
108 $html = explode(' ', $html); //so you can actually _see_ the difference...
109 $expected = explode(' ', $expected);
110 $this->assertEquals($expected, $html);
111 }
normalizeHTML($html)
Definition: Base.php:317

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

+ Here is the call graph for this function:

◆ test_render_no_byline()

PasswordInputTest::test_render_no_byline ( )

Definition at line 114 of file PasswordInputTest.php.

115 {
116 $f = $this->buildFactory();
117 $label = "label";
118 $name = "name_0";
119 $pwd = $f->password($label)->withNameFrom($this->name_source);
120
121 $r = $this->getDefaultRenderer();
122 $expected = ""
123 . "<div class=\"form-group row\">"
124 . "<label for=\"$name\" class=\"control-label col-sm-3\">$label</label>"
125 . "<div class=\"col-sm-9\">"
126 . "<div class=\"il-input-password\">"
127 . "<input type=\"password\" name=\"$name\" class=\"form-control form-control-sm\" />"
128 . "</div>"
129 . "</div>"
130 . "</div>";
131 $this->assertHTMLEquals($expected, $r->render($pwd));
132 }

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

+ Here is the call graph for this function:

◆ test_render_required()

PasswordInputTest::test_render_required ( )

Definition at line 157 of file PasswordInputTest.php.

158 {
159 $f = $this->buildFactory();
160 $label = "label";
161 $name = "name_0";
162 $pwd = $f->password($label)->withNameFrom($this->name_source)->withRequired(true);
163
164 $r = $this->getDefaultRenderer();
165 $html = $r->render($pwd);
166
167 $expected = ""
168 . "<div class=\"form-group row\">"
169 . "<label for=\"$name\" class=\"control-label col-sm-3\">" . "$label"
170 . "<span class=\"asterisk\">*</span>"
171 . "</label>"
172 . "<div class=\"col-sm-9\">"
173 . "<div class=\"il-input-password\">"
174 . "<input type=\"password\" name=\"$name\" class=\"form-control form-control-sm\" />"
175 . "</div>"
176 . "</div>"
177 . "</div>";
178 $this->assertHTMLEquals($expected, $html);
179 }

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

+ Here is the call graph for this function:

◆ test_render_value()

PasswordInputTest::test_render_value ( )

Definition at line 135 of file PasswordInputTest.php.

136 {
137 $f = $this->buildFactory();
138 $label = "label";
139 $value = "value_0";
140 $name = "name_0";
141 $pwd = $f->password($label)->withValue($value)->withNameFrom($this->name_source);
142
143 $r = $this->getDefaultRenderer();
144 $expected = ""
145 . "<div class=\"form-group row\">"
146 . "<label for=\"$name\" class=\"control-label col-sm-3\">$label</label>"
147 . "<div class=\"col-sm-9\">"
148 . "<div class=\"il-input-password\">"
149 . "<input type=\"password\" name=\"$name\" value=\"$value\" class=\"form-control form-control-sm\" />"
150 . "</div>"
151 . "</div>"
152 . "</div>";
153 $this->assertHTMLEquals($expected, $r->render($pwd));
154 }

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

+ Here is the call graph for this function:

◆ test_value_required()

PasswordInputTest::test_value_required ( )

Definition at line 205 of file PasswordInputTest.php.

206 {
207 $f = $this->buildFactory();
208 $label = "label";
209 $name = "name_0";
210 $pwd = $f->password($label)->withNameFrom($this->name_source)->withRequired(true);
211
212 $pwd1 = $pwd->withInput(new DefInputData([$name => "0"]));
213 $value1 = $pwd1->getContent();
214 $this->assertTrue($value1->isOk());
215
216 $pwd2 = $pwd->withInput(new DefInputData([$name => ""]));
217 $value2 = $pwd2->getContent();
218 $this->assertTrue($value2->isError());
219 }

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

+ Here is the call graph for this function:

◆ test_value_type()

PasswordInputTest::test_value_type ( )

Definition at line 221 of file PasswordInputTest.php.

222 {
223 $f = $this->buildFactory();
224 $label = "label";
225 $pwd = $f->password($label)->withNameFrom($this->name_source);
226 $this->assertNull($pwd->getValue());
227
228 $post = new _PWDInputData();
229 $pwd = $pwd->withInput($post);
230 $this->assertEquals($post->getOr('', ''), $pwd->getValue());
231 $this->assertInstanceOf(PWD::class, $pwd->getContent()->value());
232 }

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

+ Here is the call graph for this function:

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