ILIAS  release_8 Revision v8.24
RadioInputTest Class Reference
+ Inheritance diagram for RadioInputTest:
+ Collaboration diagram for RadioInputTest:

Public Member Functions

 setUp ()
 
 test_implements_factory_interface ()
 
 test_render ()
 
 test_render_value ()
 
 test_render_disabled ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML (string $html)
 
 assertHTMLEquals (string $expected_html_as_string, string $html_as_string)
 

Protected Member Functions

 buildFactory ()
 
 buildRadio ()
 
- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML (string $html)
 A more radical version of normalizeHTML. More...
 
 brutallyTrimSignals (string $html)
 A naive replacement of all il_signal-ids with dots to ease comparisons of rendered output. More...
 

Protected Attributes

DefNamesource $name_source
 

Detailed Description

Definition at line 30 of file RadioInputTest.php.

Member Function Documentation

◆ buildFactory()

RadioInputTest::buildFactory ( )
protected

Definition at line 39 of file RadioInputTest.php.

39 : I\Input\Field\Factory
40 {
41 $df = new Data\Factory();
42 $language = $this->createMock(\ilLanguage::class);
43 return new I\Input\Field\Factory(
44 $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
45 new SignalGenerator(),
46 $df,
47 new Refinery($df, $language),
48 $language
49 );
50 }
This is a legacy support of Component\Input\Field\Input that has been moved to Component\Input\Contai...
Definition: Input.php:32
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.

Referenced by buildRadio(), and test_implements_factory_interface().

+ Here is the caller graph for this function:

◆ buildRadio()

RadioInputTest::buildRadio ( )
protected

Definition at line 52 of file RadioInputTest.php.

53 {
54 $f = $this->buildFactory();
55 $label = "label";
56 $byline = "byline";
57 return $f
58 ->radio($label, $byline)
59 ->withOption('value0', 'label0', 'byline0')
60 ->withOption('1', 'label1', 'byline1')
61 ->withNameFrom($this->name_source);
62 }
This describes inputs that can be used in forms.
Definition: FormInput.php:32

References Vendor\Package\$f, and buildFactory().

Referenced by test_render(), test_render_disabled(), and test_render_value().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setUp()

RadioInputTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 34 of file RadioInputTest.php.

34 : void
35 {
36 $this->name_source = new DefNamesource();
37 }

◆ test_implements_factory_interface()

RadioInputTest::test_implements_factory_interface ( )

Definition at line 64 of file RadioInputTest.php.

64 : void
65 {
66 $f = $this->buildFactory();
67 $radio = $f->radio("label", "byline");
68 $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $radio);
69 $this->assertInstanceOf(Field\Radio::class, $radio);
70 }

References Vendor\Package\$f, and buildFactory().

+ Here is the call graph for this function:

◆ test_render()

RadioInputTest::test_render ( )

Definition at line 72 of file RadioInputTest.php.

72 : void
73 {
74 $r = $this->getDefaultRenderer();
75 $radio = $this->buildRadio();
76 $name = $radio->getName();
77 $label = $radio->getLabel();
78 $byline = $radio->getByline();
79 $options = $radio->getOptions();
80
81 $expected = ""
82 . "<div class=\"form-group row\">"
83 . "<label class=\"control-label col-sm-4 col-md-3 col-lg-2\">$label</label>"
84 . "<div class=\"col-sm-8 col-md-9 col-lg-10\">"
85 . "<div id=\"id_1\" class=\"il-input-radio\">";
86
87 foreach ($options as $opt_value => $opt_label) {
88 $expected .= ""
89 . "<div class=\"form-control form-control-sm il-input-radiooption\">"
90 . "<input type=\"radio\" id=\"id_1_" . $opt_value . "_opt\" name=\"$name\" value=\"$opt_value\" />"
91 . "<label for=\"id_1_" . $opt_value . "_opt\">$opt_label</label>"
92 . "<div class=\"help-block\">{$radio->getBylineFor((string) $opt_value)}</div>"
93 . "</div>";
94 }
95
96 $expected .= ""
97 . "</div>"
98 . "<div class=\"help-block\">$byline</div>"
99 . "</div>"
100 . "</div>";
101 $this->assertHTMLEquals($expected, $r->render($radio));
102 }
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
if($format !==null) $name
Definition: metadata.php:247

References $name, ILIAS_UI_TestBase\assertHTMLEquals(), buildRadio(), and ILIAS_UI_TestBase\getDefaultRenderer().

+ Here is the call graph for this function:

◆ test_render_disabled()

RadioInputTest::test_render_disabled ( )

Definition at line 142 of file RadioInputTest.php.

142 : void
143 {
144 $r = $this->getDefaultRenderer();
145 $radio = $this->buildRadio()->withDisabled(true);
146 $name = $radio->getName();
147 $label = $radio->getLabel();
148 $byline = $radio->getByline();
149 $options = $radio->getOptions();
150
151 $expected = ""
152 . "<div class=\"form-group row\">"
153 . "<label class=\"control-label col-sm-4 col-md-3 col-lg-2\">$label</label>"
154 . "<div class=\"col-sm-8 col-md-9 col-lg-10\">"
155 . "<div id=\"id_1\" class=\"il-input-radio\">";
156
157 foreach ($options as $opt_value => $opt_label) {
158 $expected .= ""
159 . "<div class=\"form-control form-control-sm il-input-radiooption\">"
160 . "<input type=\"radio\" id=\"id_1_" . $opt_value . "_opt\" name=\"$name\" value=\"$opt_value\" disabled=\"disabled\"/>"
161 . "<label for=\"id_1_" . $opt_value . "_opt\">$opt_label</label>"
162 . "<div class=\"help-block\">{$radio->getBylineFor((string) $opt_value)}</div>"
163 . "</div>";
164 }
165
166 $expected .= ""
167 . "</div>"
168 . "<div class=\"help-block\">$byline</div>"
169 . "</div>"
170 . "</div>";
171 $this->assertHTMLEquals($expected, $r->render($radio));
172 }

References $name, ILIAS_UI_TestBase\assertHTMLEquals(), buildRadio(), and ILIAS_UI_TestBase\getDefaultRenderer().

+ Here is the call graph for this function:

◆ test_render_value()

RadioInputTest::test_render_value ( )

Definition at line 104 of file RadioInputTest.php.

104 : void
105 {
106 $r = $this->getDefaultRenderer();
107 $radio = $this->buildRadio();
108 $name = $radio->getName();
109 $label = $radio->getLabel();
110 $byline = $radio->getByline();
111 $options = $radio->getOptions();
112 $value = '1';
113 $radio = $radio->withValue($value);
114 $expected = ""
115 . "<div class=\"form-group row\">"
116 . "<label class=\"control-label col-sm-4 col-md-3 col-lg-2\">$label</label>"
117 . "<div class=\"col-sm-8 col-md-9 col-lg-10\">"
118 . "<div id=\"id_1\" class=\"il-input-radio\">";
119
120 foreach ($options as $opt_value => $opt_label) {
121 $expected .= "<div class=\"form-control form-control-sm il-input-radiooption\">";
122 if ($opt_value == $value) {
123 $expected .= "<input type=\"radio\" id=\"id_1_" . $opt_value . "_opt\" name=\"$name\" value=\"$opt_value\" checked=\"checked\"/>";
124 } else {
125 $expected .= "<input type=\"radio\" id=\"id_1_" . $opt_value . "_opt\" name=\"$name\" value=\"$opt_value\" />";
126 }
127 $expected .= ""
128 . "<label for=\"id_1_" . $opt_value . "_opt\">$opt_label</label>"
129 . "<div class=\"help-block\">{$radio->getBylineFor((string) $opt_value)}</div>"
130 . "</div>";
131 }
132
133 $expected .= ""
134 . "</div>"
135 . "<div class=\"help-block\">$byline</div>"
136 . "</div>"
137 . "</div>";
138
139 $this->assertHTMLEquals($expected, $r->render($radio));
140 }

References $name, ILIAS_UI_TestBase\assertHTMLEquals(), buildRadio(), and ILIAS_UI_TestBase\getDefaultRenderer().

+ Here is the call graph for this function:

Field Documentation

◆ $name_source

DefNamesource RadioInputTest::$name_source
protected

Definition at line 32 of file RadioInputTest.php.


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