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");
34 use CommonFieldRendering;
35 use HasOptionFilterTestHelper;
46 $f = $this->getFieldFactory();
50 ->radio($label, $byline)
51 ->withOption(
'value0',
'label0',
'byline0')
52 ->withOption(
'1',
'label1',
'byline1')
53 ->withNameFrom($this->name_source);
54 if ($with_has_option_filter) {
55 $return = $return->withHasOptionFilter();
62 $f = $this->getFieldFactory();
63 $radio =
$f->radio(
"label",
"byline");
65 $this->assertInstanceOf(Field\Radio::class, $radio);
70 $r = $this->getDefaultRenderer();
72 $name = $radio->getName();
73 $label = $radio->getLabel();
74 $byline = $radio->getByline();
77 $expected_options =
"";
78 foreach (
$options as $opt_value => $opt_label) {
79 $expected_options .=
""
80 .
'<div class="c-field-radio__item">'
81 .
"<input type=\"radio\" id=\"id_1_" . $opt_value .
"_opt\" name=\"$name\" value=\"$opt_value\" />"
82 .
"<label for=\"id_1_" . $opt_value .
"_opt\">$opt_label</label>"
83 .
"<div class=\"c-input__help-byline\">{$radio->getBylineFor((string) $opt_value)}</div>"
86 $expected = $this->getFormWrappedHtml(
89 '<div class="c-field-radio">' . $expected_options .
'</div>',
93 $this->assertEquals($expected, $this->render($radio));
98 $r = $this->getDefaultRenderer();
100 $name = $radio->getName();
101 $label = $radio->getLabel();
102 $byline = $radio->getByline();
105 $radio = $radio->withValue($value);
106 $expected_options =
"";
107 foreach (
$options as $opt_value => $opt_label) {
108 $expected_options .=
'<div class="c-field-radio__item">';
109 if ($opt_value == $value) {
110 $expected_options .=
"<input type=\"radio\" id=\"id_1_" . $opt_value .
"_opt\" name=\"$name\" value=\"$opt_value\" checked=\"checked\" />";
112 $expected_options .=
"<input type=\"radio\" id=\"id_1_" . $opt_value .
"_opt\" name=\"$name\" value=\"$opt_value\" />";
114 $expected_options .=
""
115 .
"<label for=\"id_1_" . $opt_value .
"_opt\">$opt_label</label>"
116 .
"<div class=\"c-input__help-byline\">{$radio->getBylineFor((string) $opt_value)}</div>"
119 $expected = $this->getFormWrappedHtml(
122 '<div class="c-field-radio">' . $expected_options .
'</div>',
126 $this->assertEquals($expected, $this->render($radio));
133 $this->testHasOptionFilter($radio);
138 $f = $this->getFieldFactory();
139 $radio =
$f->radio(
'label',
null)->withNameFrom($this->name_source);
141 $this->testWithError($radio);
142 $this->testWithNoByline($radio);
143 $this->testWithRequired($radio);
144 $this->testWithDisabled($radio);
145 $this->testWithAdditionalOnloadCodeRendersId($radio);
150 $radio = $this->
buildRadio()->withValue(
'value0');
151 $this->assertEquals(
'value0', $radio->getValue());
156 $this->expectException(\InvalidArgumentException::class);
157 $radio = $this->
buildRadio()->withValue(
'something not in options');
162 $this->expectException(\InvalidArgumentException::class);
168 $radio = $this->
buildRadio()->withValue(
null);
169 $this->assertNull($radio->getValue());
Provides common functionality for UI tests.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.