ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
RadioInputTest Class Reference
+ Inheritance diagram for RadioInputTest:
+ Collaboration diagram for RadioInputTest:

Public Member Functions

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

Protected Member Functions

 buildRadio ()
 

Protected Attributes

DefNamesource $name_source
 

Detailed Description

Definition at line 31 of file RadioInputTest.php.

Member Function Documentation

◆ buildRadio()

RadioInputTest::buildRadio ( )
protected

Definition at line 42 of file RadioInputTest.php.

43 {
44 $f = $this->getFieldFactory();
45 $label = "label";
46 $byline = "byline";
47 return $f
48 ->radio($label, $byline)
49 ->withOption('value0', 'label0', 'byline0')
50 ->withOption('1', 'label1', 'byline1')
51 ->withNameFrom($this->name_source);
52 }
This describes inputs that can be used in forms.
Definition: FormInput.php:33

References Vendor\Package\$f.

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

+ Here is the caller graph for this function:

◆ setUp()

RadioInputTest::setUp ( )

Definition at line 37 of file RadioInputTest.php.

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

◆ testCommonRendering()

RadioInputTest::testCommonRendering ( )

Definition at line 123 of file RadioInputTest.php.

123 : void
124 {
125 $f = $this->getFieldFactory();
126 $radio = $f->radio('label', null)->withNameFrom($this->name_source);
127
128 $this->testWithError($radio);
129 $this->testWithNoByline($radio);
130 $this->testWithRequired($radio);
131 $this->testWithDisabled($radio);
132 $this->testWithAdditionalOnloadCodeRendersId($radio);
133 }

References Vendor\Package\$f.

◆ testImplementsFactoryInterface()

RadioInputTest::testImplementsFactoryInterface ( )

Definition at line 54 of file RadioInputTest.php.

54 : void
55 {
56 $f = $this->getFieldFactory();
57 $radio = $f->radio("label", "byline");
58 $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $radio);
59 $this->assertInstanceOf(Field\Radio::class, $radio);
60 }
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

References Vendor\Package\$f.

◆ testRadioValueNotOK()

RadioInputTest::testRadioValueNotOK ( )

Definition at line 141 of file RadioInputTest.php.

141 : void
142 {
143 $this->expectException(\InvalidArgumentException::class);
144 $radio = $this->buildRadio()->withValue('something not in options');
145 }

References buildRadio().

+ Here is the call graph for this function:

◆ testRadioValueNotOKType()

RadioInputTest::testRadioValueNotOKType ( )

Definition at line 147 of file RadioInputTest.php.

147 : void
148 {
149 $this->expectException(\InvalidArgumentException::class);
150 $radio = $this->buildRadio()->withValue('');
151 }

References buildRadio().

+ Here is the call graph for this function:

◆ testRadioValueOK()

RadioInputTest::testRadioValueOK ( )

Definition at line 135 of file RadioInputTest.php.

135 : void
136 {
137 $radio = $this->buildRadio()->withValue('value0');
138 $this->assertEquals('value0', $radio->getValue());
139 }

References buildRadio().

+ Here is the call graph for this function:

◆ testRadioValueOKForNull()

RadioInputTest::testRadioValueOKForNull ( )

Definition at line 153 of file RadioInputTest.php.

153 : void
154 {
155 $radio = $this->buildRadio()->withValue(null);
156 $this->assertNull($radio->getValue());
157 }

References buildRadio().

+ Here is the call graph for this function:

◆ testRender()

RadioInputTest::testRender ( )

Definition at line 62 of file RadioInputTest.php.

62 : void
63 {
64 $r = $this->getDefaultRenderer();
65 $radio = $this->buildRadio();
66 $name = $radio->getName();
67 $label = $radio->getLabel();
68 $byline = $radio->getByline();
69 $options = $radio->getOptions();
70
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>"
78 . '</div>';
79 }
80 $expected = $this->getFormWrappedHtml(
81 'radio-field-input',
82 $label,
83 '<div class="c-field-radio">' . $expected_options . '</div>',
84 $byline,
85 null
86 );
87 $this->assertEquals($expected, $this->render($radio));
88 }

References buildRadio().

+ Here is the call graph for this function:

◆ testRenderValue()

RadioInputTest::testRenderValue ( )

Definition at line 90 of file RadioInputTest.php.

90 : void
91 {
92 $r = $this->getDefaultRenderer();
93 $radio = $this->buildRadio();
94 $name = $radio->getName();
95 $label = $radio->getLabel();
96 $byline = $radio->getByline();
97 $options = $radio->getOptions();
98 $value = '1';
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\" />";
105 } else {
106 $expected_options .= "<input type=\"radio\" id=\"id_1_" . $opt_value . "_opt\" name=\"$name\" value=\"$opt_value\" />";
107 }
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>"
111 . '</div>';
112 }
113 $expected = $this->getFormWrappedHtml(
114 'radio-field-input',
115 $label,
116 '<div class="c-field-radio">' . $expected_options . '</div>',
117 $byline,
118 null
119 );
120 $this->assertEquals($expected, $this->render($radio));
121 }

References buildRadio().

+ Here is the call graph for this function:

Field Documentation

◆ $name_source

DefNamesource RadioInputTest::$name_source
protected

Definition at line 35 of file RadioInputTest.php.


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