ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Protected Member Functions

 buildFactory ()
 
 buildRadio ()
 
- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 

Detailed Description

Definition at line 14 of file RadioInputTest.php.

Member Function Documentation

◆ buildFactory()

RadioInputTest::buildFactory ( )
protected

Definition at line 21 of file RadioInputTest.php.

Referenced by buildRadio(), and test_implements_factory_interface().

22  {
23  $df = new Data\Factory();
24  $language = $this->createMock(\ilLanguage::class);
26  new SignalGenerator(),
27  $df,
28  new \ILIAS\Refinery\Factory($df, $language),
29  $language
30  );
31  }
Class ChatMainBarProvider .
Builds data types.
Definition: Factory.php:19
+ Here is the caller graph for this function:

◆ buildRadio()

RadioInputTest::buildRadio ( )
protected

Definition at line 33 of file RadioInputTest.php.

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

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

33  : Radio
34  {
35  $f = $this->buildFactory();
36  $label = "label";
37  $byline = "byline";
38  $radio = $f->radio($label, $byline)
39  ->withOption('value0', 'label0', 'byline0')
40  ->withOption('1', 'label1', 'byline1')
41  ->withNameFrom($this->name_source);
42  return $radio;
43  }
This is what a radio-input looks like.
Definition: Radio.php:10
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setUp()

RadioInputTest::setUp ( )

Definition at line 16 of file RadioInputTest.php.

16  : void
17  {
18  $this->name_source = new DefNamesource();
19  }

◆ test_implements_factory_interface()

RadioInputTest::test_implements_factory_interface ( )

Definition at line 46 of file RadioInputTest.php.

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

47  {
48  $f = $this->buildFactory();
49  $radio = $f->radio("label", "byline");
50  $this->assertInstanceOf(Field\Input::class, $radio);
51  $this->assertInstanceOf(Field\Radio::class, $radio);
52  }
+ Here is the call graph for this function:

◆ test_render()

RadioInputTest::test_render ( )

Definition at line 55 of file RadioInputTest.php.

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

56  {
57  $r = $this->getDefaultRenderer();
58  $radio = $this->buildRadio();
59  $name = $radio->getName();
60  $label = $radio->getLabel();
61  $byline = $radio->getByline();
62  $options = $radio->getOptions();
63 
64  $expected = ""
65  . "<div class=\"form-group row\">"
66  . "<label for=\"\" class=\"control-label col-sm-3\">$label</label>"
67  . "<div class=\"col-sm-9\">"
68  . "<div id=\"id_1\" class=\"il-input-radio\">";
69 
70  foreach ($options as $opt_value => $opt_label) {
71  $expected .= ""
72  . "<div class=\"form-control form-control-sm il-input-radiooption\">"
73  . "<input type=\"radio\" id=\"id_1_" . $opt_value . "_opt\" name=\"$name\" value=\"$opt_value\" />"
74  . "<label for=\"id_1_" . $opt_value . "_opt\">$opt_label</label>"
75  . "<div class=\"help-block\">{$radio->getBylineFor($opt_value)}</div>"
76  . "</div>";
77  }
78 
79  $expected .= ""
80  . "</div>"
81  . "<div class=\"help-block\">$byline</div>"
82  . "</div>"
83  . "</div>";
84  $this->assertHTMLEquals($expected, $r->render($radio));
85  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
if($format !==null) $name
Definition: metadata.php:230
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

◆ test_render_disabled()

RadioInputTest::test_render_disabled ( )

Definition at line 128 of file RadioInputTest.php.

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

129  {
130  $r = $this->getDefaultRenderer();
131  $radio = $this->buildRadio()->withDisabled(true);
132  $name = $radio->getName();
133  $label = $radio->getLabel();
134  $byline = $radio->getByline();
135  $options = $radio->getOptions();
136 
137  $expected = ""
138  . "<div class=\"form-group row\">"
139  . "<label for=\"\" class=\"control-label col-sm-3\">$label</label>"
140  . "<div class=\"col-sm-9\">"
141  . "<div id=\"id_1\" class=\"il-input-radio\">";
142 
143  foreach ($options as $opt_value => $opt_label) {
144  $expected .= ""
145  . "<div class=\"form-control form-control-sm il-input-radiooption\">"
146  . "<input type=\"radio\" id=\"id_1_" . $opt_value . "_opt\" name=\"$name\" value=\"$opt_value\" disabled=\"disabled\"/>"
147  . "<label for=\"id_1_" . $opt_value . "_opt\">$opt_label</label>"
148  . "<div class=\"help-block\">{$radio->getBylineFor($opt_value)}</div>"
149  . "</div>";
150  }
151 
152  $expected .= ""
153  . "</div>"
154  . "<div class=\"help-block\">$byline</div>"
155  . "</div>"
156  . "</div>";
157  $this->assertHTMLEquals($expected, $r->render($radio));
158  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
if($format !==null) $name
Definition: metadata.php:230
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

◆ test_render_value()

RadioInputTest::test_render_value ( )

Definition at line 88 of file RadioInputTest.php.

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

89  {
90  $r = $this->getDefaultRenderer();
91  $radio = $this->buildRadio();
92  $name = $radio->getName();
93  $label = $radio->getLabel();
94  $byline = $radio->getByline();
95  $options = $radio->getOptions();
96  $value = '1';
97  $radio = $radio->withValue($value);
98  $expected = ""
99  . "<div class=\"form-group row\">"
100  . "<label for=\"\" class=\"control-label col-sm-3\">$label</label>"
101  . "<div class=\"col-sm-9\">"
102  . "<div id=\"id_1\" class=\"il-input-radio\">";
103 
104  foreach ($options as $opt_value => $opt_label) {
105  $expected .= "<div class=\"form-control form-control-sm il-input-radiooption\">";
106  if ($opt_value == $value) {
107  $expected .= "<input type=\"radio\" id=\"id_1_" . $opt_value . "_opt\" name=\"$name\" value=\"$opt_value\" checked=\"checked\"/>";
108  } else {
109  $expected .= "<input type=\"radio\" id=\"id_1_" . $opt_value . "_opt\" name=\"$name\" value=\"$opt_value\" />";
110  }
111  $expected .= ""
112  . "<label for=\"id_1_" . $opt_value . "_opt\">$opt_label</label>"
113  . "<div class=\"help-block\">{$radio->getBylineFor($opt_value)}</div>"
114  . "</div>";
115  }
116 
117  $expected .= ""
118  . "</div>"
119  . "<div class=\"help-block\">$byline</div>"
120  . "</div>"
121  . "</div>";
122 
123  $this->assertHTMLEquals($expected, $r->render($radio));
124  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
if($format !==null) $name
Definition: metadata.php:230
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

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