5 require_once(__DIR__ .
"/../../../../../libs/composer/vendor/autoload.php");
6 require_once(__DIR__ .
"/../../../Base.php");
7 require_once(__DIR__ .
"/InputTest.php");
12 use \ILIAS\UI\Component\Input\Field;
14 use \ILIAS\Validation;
15 use \ILIAS\Transformation;
25 return 'some alternative value';
39 $df =
new Data\Factory();
43 new Validation\
Factory($df, $this->createMock(\ilLanguage::class)),
51 $f = $this->buildFactory();
52 $pwd =
$f->password(
"label",
"byline");
53 $this->assertInstanceOf(Field\Input::class, $pwd);
54 $this->assertInstanceOf(Field\Password::class, $pwd);
60 $f = $this->buildFactory();
64 $pwd =
$f->password($label, $byline)->withNameFrom($this->name_source);
66 $r = $this->getDefaultRenderer();
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\" />" 74 .
"<div class=\"help-block\">$byline</div>" 77 $this->assertHTMLEquals($expected,
$r->render($pwd));
83 $f = $this->buildFactory();
88 $pwd =
$f->password($label, $byline)->withNameFrom($this->name_source)->withError($error);
90 $r = $this->getDefaultRenderer();
91 $html = $this->normalizeHTML(
$r->render($pwd));
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\" />" 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\" />" 108 $expected = preg_replace(
'!\s+!',
' ', $expected);
110 $expected = explode(
' ', $expected);
111 $this->assertEquals($expected,
$html);
117 $f = $this->buildFactory();
120 $pwd =
$f->password($label)->withNameFrom($this->name_source);
122 $r = $this->getDefaultRenderer();
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\" />" 132 $this->assertHTMLEquals($expected,
$r->render($pwd));
138 $f = $this->buildFactory();
142 $pwd =
$f->password($label)->withValue($value)->withNameFrom($this->name_source);
144 $r = $this->getDefaultRenderer();
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\" />" 154 $this->assertHTMLEquals($expected,
$r->render($pwd));
160 $f = $this->buildFactory();
163 $pwd =
$f->password($label)->withNameFrom($this->name_source)->withRequired(
true);
165 $r = $this->getDefaultRenderer();
169 .
"<div class=\"form-group row\">" 170 .
"<label for=\"$name\" class=\"control-label col-sm-3\">" .
"$label" 171 .
"<span class=\"asterisk\">*</span>" 173 .
"<div class=\"col-sm-9\">" 174 .
"<div class=\"il-input-password\">" 175 .
"<input type=\"password\" name=\"$name\" class=\"form-control form-control-sm\" />" 179 $this->assertHTMLEquals($expected,
$html);
185 $f = $this->buildFactory();
188 $pwd =
$f->password($label)->withNameFrom($this->name_source)->withRequired(
true);
191 $value1 = $pwd1->getContent();
192 $this->assertTrue($value1->isOk());
195 $value2 = $pwd2->getContent();
196 $this->assertTrue($value2->isError());
201 $f = $this->buildFactory();
203 $pwd =
$f->password($label);
204 $this->assertNull($pwd->getValue());
207 $pwd = $pwd->withInput($post);
208 $this->assertEquals($post->getOr(
'',
''), $pwd->getValue());
209 $this->assertInstanceOf(PWD::class, $pwd->getContent()->value());
A password is used as part of credentials for authentication.
Provides common functionality for UI tests.
Describes how Input-Elements want to interact with posted data.
getOr($name, $default)
Get a named value from the data and fallback to default if that name does not exist.