19declare(strict_types=1);
21require_once(__DIR__ .
"/../../../../../../../vendor/composer/vendor/autoload.php");
22require_once(__DIR__ .
"/../../../Base.php");
23require_once(__DIR__ .
"/CommonFieldRendering.php");
24require_once(__DIR__ .
"/HasOptionFilterTestHelper.php");
36 use CommonFieldRendering;
37 use HasOptionFilterTestHelper;
48 $f = $this->getFieldFactory();
53 $ms =
$f->multiSelect(
"label",
$options,
"byline");
55 $this->assertInstanceOf(Field\MultiSelect::class, $ms);
60 $f = $this->getFieldFactory();
65 $ms =
$f->multiSelect(
"label",
$options,
"byline");
66 $this->assertEquals(
$options, $ms->getOptions());
71 $this->expectException(InvalidArgumentException::class);
72 $f = $this->getFieldFactory();
77 $ms =
$f->multiSelect(
"label",
$options,
"byline")
78 ->withNameFrom(
new class () implements
NameSource {
79 public function getNewName():
string
84 $ms = $ms->withInput(
new class () implements
InputData {
88 public function getOr($_, $__): array
92 public function get($_):
void
95 public function has($name):
bool
104 $r = $this->getDefaultRenderer();
105 $f = $this->getFieldFactory();
110 $ms =
$f->multiSelect(
"label",
$options,
"byline")
111 ->withNameFrom($this->name_source);
113 $name = $ms->getName();
114 $label = $ms->getLabel();
115 $byline = $ms->getByline();
116 $expected_options =
"";
117 foreach (
$options as $opt_value => $opt_label) {
118 $expected_options .=
""
120 .
"<input type=\"checkbox\" name=\"$name" .
"[]\" value=\"$opt_value\" />"
121 .
' <span class="c-field-multiselect__label-text">'
123 .
"</span></label></li>";
125 $expected = $this->getFormWrappedHtml(
126 'multi-select-field-input',
128 '<ul class="c-field-multiselect">'
129 . $expected_options .
134 $this->assertEquals($expected, $this->render($ms));
139 $r = $this->getDefaultRenderer();
140 $f = $this->getFieldFactory();
146 $ms =
$f->multiSelect(
"label",
$options,
"byline")
147 ->withNameFrom($this->name_source)
148 ->withValue([$value]);
150 $name = $ms->getName();
151 $label = $ms->getLabel();
152 $byline = $ms->getByline();
153 $expected_options =
"";
154 foreach (
$options as $opt_value => $opt_label) {
155 if ($opt_value === $value) {
156 $expected_options .=
""
158 .
"<input type=\"checkbox\" name=\"$name" .
"[]\" value=\"$opt_value\" checked=\"checked\" />"
159 .
'<span class="c-field-multiselect__label-text">'
161 .
"</span></label></li>";
163 $expected_options .=
""
165 .
"<input type=\"checkbox\" name=\"$name" .
"[]\" value=\"$opt_value\" />"
166 .
'<span class="c-field-multiselect__label-text">'
168 .
"</span></label></li>";
171 $expected = $this->getFormWrappedHtml(
172 'multi-select-field-input',
174 '<ul class="c-field-multiselect">'
175 . $expected_options .
180 $this->assertEquals($expected, $this->render($ms));
185 $f = $this->getFieldFactory();
190 $ms =
$f->multiSelect(
"label",
$options,
"byline");
191 $ms = $ms->withHasOptionFilter(
true);
193 $this->testHasOptionFilter($ms);
198 $f = $this->getFieldFactory();
200 $multi_select =
$f->multiSelect($label, [],
null)->withNameFrom($this->name_source);
202 $this->testWithError($multi_select);
203 $this->testWithNoByline($multi_select);
204 $this->testWithRequired($multi_select);
205 $this->testWithDisabled($multi_select);
206 $this->testWithAdditionalOnloadCodeRendersId($multi_select);
211 $r = $this->getDefaultRenderer();
212 $f = $this->getFieldFactory();
214 $ms =
$f->multiSelect(
"label",
$options,
"byline")
215 ->withNameFrom($this->name_source)->withDisabled(
true);
217 $name = $ms->getName();
218 $label = $ms->getLabel();
219 $byline = $ms->getByline();
221 <fieldset class="c-input" data-il-ui-component="multi-select-field-input" data-il-ui-input-name="name_0" disabled="disabled" tabindex="0">
223 <div class="c-input__field">
224 <ul class="c-field-multiselect">
228 <div class="c-input__help-byline">byline</div>
231 $this->assertHTMLEquals($expected, $r->render($ms));
Provides common functionality for UI tests.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.