ILIAS  release_8 Revision v8.24
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 ()
 
 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 60 of file PasswordInputTest.php.

Member Function Documentation

◆ buildFactory()

PasswordInputTest::buildFactory ( )
protected

Definition at line 69 of file PasswordInputTest.php.

69 : I\Input\Field\Factory
70 {
71 $df = new Data\Factory();
72 $language = $this->createMock(ilLanguage::class);
73 return new I\Input\Field\Factory(
74 $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
75 new SignalGenerator(),
76 $df,
77 new Refinery($df, $language),
78 $language
79 );
80 }
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 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 64 of file PasswordInputTest.php.

64 : void
65 {
66 $this->name_source = new DefNamesource();
67 }

◆ test_implements_factory_interface()

PasswordInputTest::test_implements_factory_interface ( )

Definition at line 82 of file PasswordInputTest.php.

82 : void
83 {
84 $f = $this->buildFactory();
85 $pwd = $f->password("label", "byline");
86 $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $pwd);
87 $this->assertInstanceOf(Field\Password::class, $pwd);
88 }

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

+ Here is the call graph for this function:

◆ test_render()

PasswordInputTest::test_render ( )

Definition at line 90 of file PasswordInputTest.php.

90 : void
91 {
92 $f = $this->buildFactory();
93 $label = "label";
94 $byline = "byline";
95 $name = "name_0";
96 $pwd = $f->password($label, $byline)->withNameFrom($this->name_source);
97
98 $r = $this->getDefaultRenderer();
99 $expected = '
100 <div class="form-group row">
101 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">' . $label . '</label>
102 <div class="col-sm-8 col-md-9 col-lg-10">
103 <div class="il-input-password" id="id_1_container">
104 <input id="id_1" type="password" name="' . $name . '" class="form-control form-control-sm" />
105 </div>
106 <div class="help-block">' . $byline . '</div>
107 </div>
108 </div>';
109 $this->assertHTMLEquals($expected, $r->render($pwd));
110 }
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
if($format !==null) $name
Definition: metadata.php:247

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

198 : void
199 {
200 $f = $this->buildFactory();
201 $label = "label";
202 $name = "name_0";
203 $pwd = $f->password($label)->withNameFrom($this->name_source)->withDisabled(true);
204
205 $r = $this->getDefaultRenderer();
206 $html = $r->render($pwd);
207
208 $expected = '
209 <div class="form-group row">
210 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">' . $label . '</label>
211 <div class="col-sm-8 col-md-9 col-lg-10">
212 <div class="il-input-password" id="id_1_container">
213 <input id="id_1" type="password" name="' . $name . '" disabled="disabled" class="form-control form-control-sm" />
214 </div>
215 </div>
216 </div>';
217 $this->assertHTMLEquals($expected, $html);
218 }

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

112 : void
113 {
114 $f = $this->buildFactory();
115 $label = "label";
116 $byline = "byline";
117 $error = "an_error";
118 $pwd = $f->password($label, $byline)->withNameFrom($this->name_source)->withError($error);
119
120 $r = $this->getDefaultRenderer();
121 $html = $this->brutallyTrimHTML($r->render($pwd));
122 $expected = $this->brutallyTrimHTML('
123<div class="form-group row">
124 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">label</label>
125 <div class="col-sm-8 col-md-9 col-lg-10">
126 <div class="help-block alert alert-danger" aria-describedby="id_1" role="alert">an_error</div>
127 <div class="il-input-password" id="id_1_container"><input id="id_1" type="password" name="name_0" class="form-control form-control-sm" /></div>
128 <div class="help-block">byline</div>
129 </div>
130</div>');
131
132 $this->assertEquals($expected, $html);
133 }
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:444

References Vendor\Package\$f, 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 135 of file PasswordInputTest.php.

135 : void
136 {
137 $f = $this->buildFactory();
138 $label = "label";
139 $name = "name_0";
140 $pwd = $f->password($label)->withNameFrom($this->name_source);
141
142 $r = $this->getDefaultRenderer();
143 $expected = '
144 <div class="form-group row">
145 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">' . $label . '</label>
146 <div class="col-sm-8 col-md-9 col-lg-10">
147 <div class="il-input-password" id="id_1_container">
148 <input id="id_1" type="password" name="' . $name . '" class="form-control form-control-sm" />
149 </div>
150 </div>
151 </div>';
152 $this->assertHTMLEquals($expected, $r->render($pwd));
153 }

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

176 : void
177 {
178 $f = $this->buildFactory();
179 $label = "label";
180 $name = "name_0";
181 $pwd = $f->password($label)->withNameFrom($this->name_source)->withRequired(true);
182
183 $r = $this->getDefaultRenderer();
184 $html = $r->render($pwd);
185
186 $expected = '
187 <div class="form-group row">
188 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">' . $label . '<span class="asterisk">*</span></label>
189 <div class="col-sm-8 col-md-9 col-lg-10">
190 <div class="il-input-password" id="id_1_container">
191 <input id="id_1" type="password" name="' . $name . '" class="form-control form-control-sm" />
192 </div>
193 </div>
194 </div>';
195 $this->assertHTMLEquals($expected, $html);
196 }

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

155 : void
156 {
157 $f = $this->buildFactory();
158 $label = "label";
159 $value = "value_0";
160 $name = "name_0";
161 $pwd = $f->password($label)->withValue($value)->withNameFrom($this->name_source);
162
163 $r = $this->getDefaultRenderer();
164 $expected = '
165 <div class="form-group row">
166 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">' . $label . '</label>
167 <div class="col-sm-8 col-md-9 col-lg-10">
168 <div class="il-input-password" id="id_1_container">
169 <input id="id_1" type="password" name="' . $name . '" value="' . $value . '" class="form-control form-control-sm" />
170 </div>
171 </div>
172 </div>';
173 $this->assertHTMLEquals($expected, $r->render($pwd));
174 }

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

220 : void
221 {
222 $f = $this->buildFactory();
223 $label = "label";
224 $name = "name_0";
225 $pwd = $f->password($label)->withNameFrom($this->name_source)->withRequired(true);
226
227 $pwd1 = $pwd->withInput(new DefInputData([$name => "0"]));
228 $value1 = $pwd1->getContent();
229 $this->assertTrue($value1->isOk());
230
231 $pwd2 = $pwd->withInput(new DefInputData([$name => ""]));
232 $value2 = $pwd2->getContent();
233 $this->assertTrue($value2->isError());
234 }

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

236 : void
237 {
238 $f = $this->buildFactory();
239 $label = "label";
240 $pwd = $f->password($label)->withNameFrom($this->name_source);
241 $this->assertNull($pwd->getValue());
242
243 $post = new _PWDInputData();
244 $pwd = $pwd->withInput($post);
245 $this->assertEquals($post->getOr('', ''), $pwd->getValue());
246 $this->assertInstanceOf(PWD::class, $pwd->getContent()->value());
247 }
$post
Definition: ltitoken.php:49

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

+ Here is the call graph for this function:

Field Documentation

◆ $name_source

DefNamesource PasswordInputTest::$name_source
protected

Definition at line 62 of file PasswordInputTest.php.


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