ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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_value_required ()
 
 test_value_type ()
 
- 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 29 of file PasswordInputTest.php.

Member Function Documentation

◆ buildFactory()

PasswordInputTest::buildFactory ( )
protected

Definition at line 37 of file PasswordInputTest.php.

38  {
39  $df = new Data\Factory();
41  new SignalGenerator(),
42  $df,
43  new Validation\Factory($df, $this->createMock(\ilLanguage::class)),
45  );
46  }
A transformation is a function from one datatype to another.
Builds data types.
Definition: Factory.php:14

◆ setUp()

PasswordInputTest::setUp ( )

Definition at line 31 of file PasswordInputTest.php.

32  {
33  $this->name_source = new DefNamesource();
34  }

◆ test_implements_factory_interface()

PasswordInputTest::test_implements_factory_interface ( )

Definition at line 49 of file PasswordInputTest.php.

References $f.

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

◆ test_render()

PasswordInputTest::test_render ( )

Definition at line 58 of file PasswordInputTest.php.

References $f, $name, and $r.

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

◆ test_render_error()

PasswordInputTest::test_render_error ( )

Definition at line 81 of file PasswordInputTest.php.

References $f, $html, $name, and $r.

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

◆ test_render_no_byline()

PasswordInputTest::test_render_no_byline ( )

Definition at line 115 of file PasswordInputTest.php.

References $f, $name, and $r.

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

◆ test_render_required()

PasswordInputTest::test_render_required ( )

Definition at line 158 of file PasswordInputTest.php.

References $f, $html, $name, and $r.

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

◆ test_render_value()

PasswordInputTest::test_render_value ( )

Definition at line 136 of file PasswordInputTest.php.

References $f, $name, and $r.

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

◆ test_value_required()

PasswordInputTest::test_value_required ( )

Definition at line 183 of file PasswordInputTest.php.

References $f, and $name.

184  {
185  $f = $this->buildFactory();
186  $label = "label";
187  $name = "name_0";
188  $pwd = $f->password($label)->withNameFrom($this->name_source)->withRequired(true);
189 
190  $pwd1 = $pwd->withInput(new DefPostData([$name => "0"]));
191  $value1 = $pwd1->getContent();
192  $this->assertTrue($value1->isOk());
193 
194  $pwd2 = $pwd->withInput(new DefPostData([$name => ""]));
195  $value2 = $pwd2->getContent();
196  $this->assertTrue($value2->isError());
197  }

◆ test_value_type()

PasswordInputTest::test_value_type ( )

Definition at line 199 of file PasswordInputTest.php.

References $f, and $post.

200  {
201  $f = $this->buildFactory();
202  $label = "label";
203  $pwd = $f->password($label);
204  $this->assertNull($pwd->getValue());
205 
206  $post = new _PWDPostData();
207  $pwd = $pwd->withInput($post);
208  $this->assertEquals($post->getOr('', ''), $pwd->getValue());
209  $this->assertInstanceOf(PWD::class, $pwd->getContent()->value());
210  }
$post
Definition: post.php:34

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