ILIAS  release_7 Revision v7.30-3-g800a261c036
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 ()
 
 getImagePathResolver ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
 
 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 class=\"control-label col-sm-3\">$label</label>"
69 . "<div class=\"col-sm-9\">"
70 . "<div class=\"il-input-password\" id=\"id_1\">"
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:372
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
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 173 of file PasswordInputTest.php.

174 {
175 $f = $this->buildFactory();
176 $label = "label";
177 $name = "name_0";
178 $pwd = $f->password($label)->withNameFrom($this->name_source)->withDisabled(true);
179
180 $r = $this->getDefaultRenderer();
181 $html = $r->render($pwd);
182
183 $expected = ""
184 . "<div class=\"form-group row\">"
185 . "<label class=\"control-label col-sm-3\">$label</label>"
186 . "<div class=\"col-sm-9\">"
187 . "<div class=\"il-input-password\" id=\"id_1\">"
188 . "<input type=\"password\" name=\"$name\" disabled=\"disabled\" class=\"form-control form-control-sm\" />"
189 . "</div>"
190 . "</div>"
191 . "</div>";
192 $this->assertHTMLEquals($expected, $html);
193 }

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->brutallyTrimHTML($r->render($pwd));
91 $expected = $this->brutallyTrimHTML('
92<div class="form-group row">
93 <label class="control-label col-sm-3">label</label>
94 <div class="col-sm-9">
95 <div class="help-block alert alert-danger" role="alert">an_error</div>
96 <div class="il-input-password" id="id_1"><input type="password" name="name_0" class="form-control form-control-sm" /></div>
97 <div class="help-block">byline</div>
98 </div>
99</div>');
100
101 $this->assertEquals($expected, $html);
102 }
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392

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

+ Here is the call graph for this function:

◆ test_render_no_byline()

PasswordInputTest::test_render_no_byline ( )

Definition at line 105 of file PasswordInputTest.php.

106 {
107 $f = $this->buildFactory();
108 $label = "label";
109 $name = "name_0";
110 $pwd = $f->password($label)->withNameFrom($this->name_source);
111
112 $r = $this->getDefaultRenderer();
113 $expected = ""
114 . "<div class=\"form-group row\">"
115 . "<label class=\"control-label col-sm-3\">$label</label>"
116 . "<div class=\"col-sm-9\">"
117 . "<div class=\"il-input-password\" id=\"id_1\">"
118 . "<input type=\"password\" name=\"$name\" class=\"form-control form-control-sm\" />"
119 . "</div>"
120 . "</div>"
121 . "</div>";
122 $this->assertHTMLEquals($expected, $r->render($pwd));
123 }

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 148 of file PasswordInputTest.php.

149 {
150 $f = $this->buildFactory();
151 $label = "label";
152 $name = "name_0";
153 $pwd = $f->password($label)->withNameFrom($this->name_source)->withRequired(true);
154
155 $r = $this->getDefaultRenderer();
156 $html = $r->render($pwd);
157
158 $expected = ""
159 . "<div class=\"form-group row\">"
160 . "<label class=\"control-label col-sm-3\">" . "$label"
161 . "<span class=\"asterisk\">*</span>"
162 . "</label>"
163 . "<div class=\"col-sm-9\">"
164 . "<div class=\"il-input-password\" id=\"id_1\">"
165 . "<input type=\"password\" name=\"$name\" class=\"form-control form-control-sm\" />"
166 . "</div>"
167 . "</div>"
168 . "</div>";
169 $this->assertHTMLEquals($expected, $html);
170 }

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 126 of file PasswordInputTest.php.

127 {
128 $f = $this->buildFactory();
129 $label = "label";
130 $value = "value_0";
131 $name = "name_0";
132 $pwd = $f->password($label)->withValue($value)->withNameFrom($this->name_source);
133
134 $r = $this->getDefaultRenderer();
135 $expected = ""
136 . "<div class=\"form-group row\">"
137 . "<label class=\"control-label col-sm-3\">$label</label>"
138 . "<div class=\"col-sm-9\">"
139 . "<div class=\"il-input-password\" id=\"id_1\">"
140 . "<input type=\"password\" name=\"$name\" value=\"$value\" class=\"form-control form-control-sm\" />"
141 . "</div>"
142 . "</div>"
143 . "</div>";
144 $this->assertHTMLEquals($expected, $r->render($pwd));
145 }

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 196 of file PasswordInputTest.php.

197 {
198 $f = $this->buildFactory();
199 $label = "label";
200 $name = "name_0";
201 $pwd = $f->password($label)->withNameFrom($this->name_source)->withRequired(true);
202
203 $pwd1 = $pwd->withInput(new DefInputData([$name => "0"]));
204 $value1 = $pwd1->getContent();
205 $this->assertTrue($value1->isOk());
206
207 $pwd2 = $pwd->withInput(new DefInputData([$name => ""]));
208 $value2 = $pwd2->getContent();
209 $this->assertTrue($value2->isError());
210 }

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 212 of file PasswordInputTest.php.

213 {
214 $f = $this->buildFactory();
215 $label = "label";
216 $pwd = $f->password($label)->withNameFrom($this->name_source);
217 $this->assertNull($pwd->getValue());
218
219 $post = new _PWDInputData();
220 $pwd = $pwd->withInput($post);
221 $this->assertEquals($post->getOr('', ''), $pwd->getValue());
222 $this->assertInstanceOf(PWD::class, $pwd->getContent()->value());
223 }

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: