ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
CheckboxInputTest Class Reference
+ Inheritance diagram for CheckboxInputTest:
+ Collaboration diagram for CheckboxInputTest:

Public Member Functions

 setUp ()
 
 test_implements_factory_interface ()
 
 test_render ()
 
 test_render_error ()
 
 test_render_no_byline ()
 
 test_render_value ()
 
 test_handle_invalid_value ()
 
 test_render_required ()
 
- 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 ()
 

Detailed Description

Definition at line 15 of file CheckboxInputTest.php.

Member Function Documentation

◆ buildFactory()

CheckboxInputTest::buildFactory ( )
protected

Definition at line 23 of file CheckboxInputTest.php.

Referenced by test_handle_invalid_value(), test_implements_factory_interface(), test_render(), test_render_error(), test_render_no_byline(), test_render_required(), and test_render_value().

24  {
25  $df = new Data\Factory();
27  new SignalGenerator(),
28  $df,
29  new Validation\Factory($df, $this->createMock(\ilLanguage::class)),
31  );
32  }
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:

◆ setUp()

CheckboxInputTest::setUp ( )

Definition at line 17 of file CheckboxInputTest.php.

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

◆ test_handle_invalid_value()

CheckboxInputTest::test_handle_invalid_value ( )

Definition at line 106 of file CheckboxInputTest.php.

References $f, and buildFactory().

107  {
108  $f = $this->buildFactory();
109  $label = "label";
110  $value = "invalid";
111  try {
112  $f->checkbox($label)->withValue($value);
113  $this->assertFalse(true);
114  } catch (InvalidArgumentException $e) {
115  $this->assertTrue(true);
116  }
117  }
+ Here is the call graph for this function:

◆ test_implements_factory_interface()

CheckboxInputTest::test_implements_factory_interface ( )

Definition at line 35 of file CheckboxInputTest.php.

References $f, and buildFactory().

36  {
37  $f = $this->buildFactory();
38 
39  $checkbox = $f->checkbox("label", "byline");
40 
41  $this->assertInstanceOf(Field\Input::class, $checkbox);
42  $this->assertInstanceOf(Field\Checkbox::class, $checkbox);
43  }
+ Here is the call graph for this function:

◆ test_render()

CheckboxInputTest::test_render ( )

Definition at line 46 of file CheckboxInputTest.php.

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

47  {
48  $f = $this->buildFactory();
49  $label = "label";
50  $byline = "byline";
51  $checkbox = $f->checkbox($label, $byline)->withNameFrom($this->name_source);
52 
53  $r = $this->getDefaultRenderer();
54  $html = $r->render($checkbox);
55 
56  $expected = "<div class=\"form-group row\"> <label for=\"name_0\" class=\"control-label col-sm-3\">label</label> <div class=\"col-sm-9\"> <input type=\"checkbox\" value=\"checked\" name=\"name_0\" class=\"form-control form-control-sm\" /> <div class=\"help-block\">byline</div> </div></div>";
57  $this->assertHTMLEquals($expected, $html);
58  }
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
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ test_render_error()

CheckboxInputTest::test_render_error ( )

Definition at line 61 of file CheckboxInputTest.php.

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

62  {
63  $f = $this->buildFactory();
64  $label = "label";
65  $byline = "byline";
66  $error = "an_error";
67  $checkbox = $f->checkbox($label, $byline)->withNameFrom($this->name_source)->withError($error);
68 
69  $r = $this->getDefaultRenderer();
70  $html = $r->render($checkbox);
71 
72  $expected = "<div class=\"form-group row\"> <label for=\"name_0\" class=\"control-label col-sm-3\">label</label> <div class=\"col-sm-9\"> <input type=\"checkbox\" value=\"checked\" name=\"name_0\" class=\"form-control form-control-sm\" /> <div class=\"help-block\">byline</div> <div class=\"help-block alert alert-danger\" role=\"alert\"> <img border=\"0\" src=\" ./templates/default/images/icon_alert.svg\" alt=\"alert\" />" . " $error"
73  . " </div></div></div>";
74  $this->assertHTMLEquals($expected, $html);
75  }
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
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ test_render_no_byline()

CheckboxInputTest::test_render_no_byline ( )

Definition at line 78 of file CheckboxInputTest.php.

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

79  {
80  $f = $this->buildFactory();
81  $label = "label";
82  $checkbox = $f->checkbox($label)->withNameFrom($this->name_source);
83 
84  $r = $this->getDefaultRenderer();
85  $html = $r->render($checkbox);
86 
87  $expected = "<div class=\"form-group row\"> <label for=\"name_0\" class=\"control-label col-sm-3\">label</label> <div class=\"col-sm-9\"> <input type=\"checkbox\" value=\"checked\" name=\"name_0\" class=\"form-control form-control-sm\" /> </div></div>";
88  $this->assertHTMLEquals($expected, $html);
89  }
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
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ test_render_required()

CheckboxInputTest::test_render_required ( )

Definition at line 120 of file CheckboxInputTest.php.

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

121  {
122  $f = $this->buildFactory();
123  $label = "label";
124  $checbox = $f->checkbox($label)->withNameFrom($this->name_source)->withRequired(true);
125 
126  $r = $this->getDefaultRenderer();
127  $html = $r->render($checbox);
128 
129  $expected = "<div class=\"form-group row\"> <label for=\"name_0\" class=\"control-label col-sm-3\">label<span class=\"asterisk\">*</span></label> <div class=\"col-sm-9\"> <input type=\"checkbox\" value=\"checked\" name=\"name_0\" class=\"form-control form-control-sm\" /> </div></div>";
130  $this->assertHTMLEquals($expected, $html);
131  }
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
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ test_render_value()

CheckboxInputTest::test_render_value ( )

Definition at line 92 of file CheckboxInputTest.php.

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

93  {
94  $f = $this->buildFactory();
95  $label = "label";
96  $value = "checked";
97  $checkbox = $f->checkbox($label)->withValue($value)->withNameFrom($this->name_source);
98 
99  $r = $this->getDefaultRenderer();
100  $html = $r->render($checkbox);
101 
102  $expected = "<div class=\"form-group row\"> <label for=\"name_0\" class=\"control-label col-sm-3\">label</label> <div class=\"col-sm-9\"> <input type=\"checkbox\" value=\"checked\" checked=\"checked\" name=\"name_0\" class=\"form-control form-control-sm\" /> </div></div>";
103  $this->assertHTMLEquals($expected, $html);
104  }
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
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

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