ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
RadioInputTest Class Reference
+ Inheritance diagram for RadioInputTest:
+ Collaboration diagram for RadioInputTest:

Public Member Functions

 setUp ()
 
 testImplementsFactoryInterface ()
 
 testRender ()
 
 testRenderValue ()
 
 testRenderWithHasOptionFilter ()
 
 testCommonRendering ()
 
 testRadioValueOK ()
 
 testRadioValueNotOK ()
 
 testRadioValueNotOKType ()
 
 testRadioValueOKForNull ()
 

Protected Member Functions

 buildRadio (bool $with_has_option_filter=false)
 

Protected Attributes

DefNamesource $name_source
 

Detailed Description

Definition at line 32 of file RadioInputTest.php.

Member Function Documentation

◆ buildRadio()

RadioInputTest::buildRadio ( bool  $with_has_option_filter = false)
protected

Definition at line 44 of file RadioInputTest.php.

45 {
46 $f = $this->getFieldFactory();
47 $label = "label";
48 $byline = "byline";
49 $return = $f
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();
56 }
57 return $return;
58 }
This describes inputs that can be used in forms.
Definition: FormInput.php:33

References Vendor\Package\$f.

Referenced by testRadioValueNotOK(), testRadioValueNotOKType(), testRadioValueOK(), testRadioValueOKForNull(), testRender(), testRenderValue(), and testRenderWithHasOptionFilter().

+ Here is the caller graph for this function:

◆ setUp()

RadioInputTest::setUp ( )

Definition at line 39 of file RadioInputTest.php.

39 : void
40 {
41 $this->name_source = new DefNamesource();
42 }

◆ testCommonRendering()

RadioInputTest::testCommonRendering ( )

Definition at line 136 of file RadioInputTest.php.

136 : void
137 {
138 $f = $this->getFieldFactory();
139 $radio = $f->radio('label', null)->withNameFrom($this->name_source);
140
141 $this->testWithError($radio);
142 $this->testWithNoByline($radio);
143 $this->testWithRequired($radio);
144 $this->testWithDisabled($radio);
145 $this->testWithAdditionalOnloadCodeRendersId($radio);
146 }

References Vendor\Package\$f.

◆ testImplementsFactoryInterface()

RadioInputTest::testImplementsFactoryInterface ( )

Definition at line 60 of file RadioInputTest.php.

60 : void
61 {
62 $f = $this->getFieldFactory();
63 $radio = $f->radio("label", "byline");
64 $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $radio);
65 $this->assertInstanceOf(Field\Radio::class, $radio);
66 }
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

References Vendor\Package\$f.

◆ testRadioValueNotOK()

RadioInputTest::testRadioValueNotOK ( )

Definition at line 154 of file RadioInputTest.php.

154 : void
155 {
156 $this->expectException(\InvalidArgumentException::class);
157 $radio = $this->buildRadio()->withValue('something not in options');
158 }
buildRadio(bool $with_has_option_filter=false)

References buildRadio().

+ Here is the call graph for this function:

◆ testRadioValueNotOKType()

RadioInputTest::testRadioValueNotOKType ( )

Definition at line 160 of file RadioInputTest.php.

160 : void
161 {
162 $this->expectException(\InvalidArgumentException::class);
163 $radio = $this->buildRadio()->withValue('');
164 }

References buildRadio().

+ Here is the call graph for this function:

◆ testRadioValueOK()

RadioInputTest::testRadioValueOK ( )

Definition at line 148 of file RadioInputTest.php.

148 : void
149 {
150 $radio = $this->buildRadio()->withValue('value0');
151 $this->assertEquals('value0', $radio->getValue());
152 }

References buildRadio().

+ Here is the call graph for this function:

◆ testRadioValueOKForNull()

RadioInputTest::testRadioValueOKForNull ( )

Definition at line 166 of file RadioInputTest.php.

166 : void
167 {
168 $radio = $this->buildRadio()->withValue(null);
169 $this->assertNull($radio->getValue());
170 }

References buildRadio().

+ Here is the call graph for this function:

◆ testRender()

RadioInputTest::testRender ( )

Definition at line 68 of file RadioInputTest.php.

68 : void
69 {
70 $r = $this->getDefaultRenderer();
71 $radio = $this->buildRadio();
72 $name = $radio->getName();
73 $label = $radio->getLabel();
74 $byline = $radio->getByline();
75 $options = $radio->getOptions();
76
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>"
84 . '</div>';
85 }
86 $expected = $this->getFormWrappedHtml(
87 'radio-field-input',
88 $label,
89 '<div class="c-field-radio">' . $expected_options . '</div>',
90 $byline,
91 null
92 );
93 $this->assertEquals($expected, $this->render($radio));
94 }

References ILIAS\UI\Implementation\Component\Input\Field\$options, and buildRadio().

+ Here is the call graph for this function:

◆ testRenderValue()

RadioInputTest::testRenderValue ( )

Definition at line 96 of file RadioInputTest.php.

96 : void
97 {
98 $r = $this->getDefaultRenderer();
99 $radio = $this->buildRadio();
100 $name = $radio->getName();
101 $label = $radio->getLabel();
102 $byline = $radio->getByline();
103 $options = $radio->getOptions();
104 $value = '1';
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\" />";
111 } else {
112 $expected_options .= "<input type=\"radio\" id=\"id_1_" . $opt_value . "_opt\" name=\"$name\" value=\"$opt_value\" />";
113 }
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>"
117 . '</div>';
118 }
119 $expected = $this->getFormWrappedHtml(
120 'radio-field-input',
121 $label,
122 '<div class="c-field-radio">' . $expected_options . '</div>',
123 $byline,
124 null
125 );
126 $this->assertEquals($expected, $this->render($radio));
127 }

References ILIAS\UI\Implementation\Component\Input\Field\$options, and buildRadio().

+ Here is the call graph for this function:

◆ testRenderWithHasOptionFilter()

RadioInputTest::testRenderWithHasOptionFilter ( )

Definition at line 129 of file RadioInputTest.php.

129 : void
130 {
131 $radio = $this->buildRadio(true);
132
133 $this->testHasOptionFilter($radio);
134 }

References buildRadio().

+ Here is the call graph for this function:

Field Documentation

◆ $name_source

DefNamesource RadioInputTest::$name_source
protected

Definition at line 37 of file RadioInputTest.php.


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