ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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_with_dependant ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Protected Member Functions

 buildFactory ()
 
 buildRadio ()
 

Detailed Description

Definition at line 15 of file RadioInputTest.php.

Member Function Documentation

◆ buildFactory()

RadioInputTest::buildFactory ( )
protected

Definition at line 22 of file RadioInputTest.php.

Referenced by buildRadio(), test_implements_factory_interface(), and test_with_dependant().

23  {
24  $df = new Data\Factory();
26  new SignalGenerator(),
27  $df,
28  new Validation\Factory($df, $this->createMock(\ilLanguage::class)),
30  );
31  }
A transformation is a function from one datatype to another.
Builds data types.
Definition: Factory.php:14
+ Here is the caller graph for this function:

◆ buildRadio()

RadioInputTest::buildRadio ( )
protected

Definition at line 33 of file RadioInputTest.php.

References $f, and buildFactory().

Referenced by test_render(), 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('value1', '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 17 of file RadioInputTest.php.

18  {
19  $this->name_source = new DefNamesource();
20  }

◆ test_implements_factory_interface()

RadioInputTest::test_implements_factory_interface ( )

Definition at line 46 of file RadioInputTest.php.

References $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, PHPMailer\PHPMailer\$options, $r, 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:228
$r
Definition: example_031.php:79
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
+ 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, PHPMailer\PHPMailer\$options, $r, 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 = array_keys($options)[0];
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:228
$r
Definition: example_031.php:79
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
+ Here is the call graph for this function:

◆ test_with_dependant()

RadioInputTest::test_with_dependant ( )

Definition at line 127 of file RadioInputTest.php.

References $f, $r, buildFactory(), and ILIAS_UI_TestBase\getDefaultRenderer().

128  {
129  $r = $this->getDefaultRenderer();
130  $f = $this->buildFactory();
131  $dep_field = $f->text('text', 'text');
132  $radio = $f->radio('label', 'byline')
133  ->withOption('value0', 'label0', 'byline0');
134 
135  $this->assertNull($radio->getDependantFieldsFor('value0'));
136 
137  $dep = ['dep1' => $dep_field];
138  $radio = $radio->withOption('value1', 'label1', 'byline1', $dep);
139  $this->assertEquals(
140  $dep,
141  $radio->getDependantFieldsFor('value1')
142  );
143  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
$r
Definition: example_031.php:79
+ Here is the call graph for this function:

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