19declare(strict_types=1);
21require_once(__DIR__ .
"/../../../../../../../vendor/composer/vendor/autoload.php");
22require_once(__DIR__ .
"/../../../Base.php");
23require_once(__DIR__ .
"/CommonFieldRendering.php");
33 use CommonFieldRendering;
44 $f = $this->getFieldFactory();
48 ->radio($label, $byline)
49 ->withOption(
'value0',
'label0',
'byline0')
50 ->withOption(
'1',
'label1',
'byline1')
51 ->withNameFrom($this->name_source);
56 $f = $this->getFieldFactory();
57 $radio =
$f->radio(
"label",
"byline");
59 $this->assertInstanceOf(Field\Radio::class, $radio);
64 $r = $this->getDefaultRenderer();
66 $name = $radio->getName();
67 $label = $radio->getLabel();
68 $byline = $radio->getByline();
69 $options = $radio->getOptions();
71 $expected_options =
"";
72 foreach ($options as $opt_value => $opt_label) {
73 $expected_options .=
""
74 .
'<div class="c-field-radio__item">'
75 .
"<input type=\"radio\" id=\"id_1_" . $opt_value .
"_opt\" name=\"$name\" value=\"$opt_value\" />"
76 .
"<label for=\"id_1_" . $opt_value .
"_opt\">$opt_label</label>"
77 .
"<div class=\"c-input__help-byline\">{$radio->getBylineFor((string) $opt_value)}</div>"
80 $expected = $this->getFormWrappedHtml(
83 '<div class="c-field-radio">' . $expected_options .
'</div>',
87 $this->assertEquals($expected, $this->render($radio));
92 $r = $this->getDefaultRenderer();
94 $name = $radio->getName();
95 $label = $radio->getLabel();
96 $byline = $radio->getByline();
97 $options = $radio->getOptions();
99 $radio = $radio->withValue($value);
100 $expected_options =
"";
101 foreach ($options as $opt_value => $opt_label) {
102 $expected_options .=
'<div class="c-field-radio__item">';
103 if ($opt_value == $value) {
104 $expected_options .=
"<input type=\"radio\" id=\"id_1_" . $opt_value .
"_opt\" name=\"$name\" value=\"$opt_value\" checked=\"checked\" />";
106 $expected_options .=
"<input type=\"radio\" id=\"id_1_" . $opt_value .
"_opt\" name=\"$name\" value=\"$opt_value\" />";
108 $expected_options .=
""
109 .
"<label for=\"id_1_" . $opt_value .
"_opt\">$opt_label</label>"
110 .
"<div class=\"c-input__help-byline\">{$radio->getBylineFor((string) $opt_value)}</div>"
113 $expected = $this->getFormWrappedHtml(
116 '<div class="c-field-radio">' . $expected_options .
'</div>',
120 $this->assertEquals($expected, $this->render($radio));
125 $f = $this->getFieldFactory();
126 $radio =
$f->radio(
'label',
null)->withNameFrom($this->name_source);
128 $this->testWithError($radio);
129 $this->testWithNoByline($radio);
130 $this->testWithRequired($radio);
131 $this->testWithDisabled($radio);
132 $this->testWithAdditionalOnloadCodeRendersId($radio);
137 $radio = $this->
buildRadio()->withValue(
'value0');
138 $this->assertEquals(
'value0', $radio->getValue());
143 $this->expectException(\InvalidArgumentException::class);
144 $radio = $this->
buildRadio()->withValue(
'something not in options');
149 $this->expectException(\InvalidArgumentException::class);
155 $radio = $this->
buildRadio()->withValue(
null);
156 $this->assertNull($radio->getValue());
Provides common functionality for UI tests.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.