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

Public Member Functions

 setUp ()
 
 test_implements_factory_interface ()
 
 test_render ()
 
 test_render_error ()
 
 test_render_no_byline ()
 
 test_render_value ()
 
 testNullValue ()
 
 testEmptyValue ($field)
 testNullValue More...
 
- 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 NumericInputTest.php.

Member Function Documentation

◆ buildFactory()

NumericInputTest::buildFactory ( )
protected

Definition at line 23 of file NumericInputTest.php.

References ILIAS_UI_TestBase\getLanguage().

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

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

◆ setUp()

NumericInputTest::setUp ( )

Definition at line 17 of file NumericInputTest.php.

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

◆ test_implements_factory_interface()

NumericInputTest::test_implements_factory_interface ( )

Definition at line 35 of file NumericInputTest.php.

References $f, and buildFactory().

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

◆ test_render()

NumericInputTest::test_render ( )

Definition at line 46 of file NumericInputTest.php.

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

47  {
48  $f = $this->buildFactory();
49  $label = "label";
50  $byline = "byline";
51  $name = "name_0";
52  $numeric = $f->numeric($label, $byline)->withNameFrom($this->name_source);
53 
54  $r = $this->getDefaultRenderer();
55  $html = $this->normalizeHTML($r->render($numeric));
56 
57  $expected = "<div class=\"form-group row\">" . " <label for=\"$name\" class=\"control-label col-sm-3\">$label</label>"
58  . " <div class=\"col-sm-9\">" . " <input type=\"number\" name=\"$name\" class=\"form-control form-control-sm\" />"
59  . " <div class=\"help-block\">$byline</div>" . " " . " </div>" . "</div>";
60  $this->assertEquals($expected, $html);
61  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
$r
Definition: example_031.php:79
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ test_render_error()

NumericInputTest::test_render_error ( )

Definition at line 64 of file NumericInputTest.php.

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

65  {
66  $f = $this->buildFactory();
67  $label = "label";
68  $byline = "byline";
69  $name = "name_0";
70  $error = "an_error";
71  $numeric = $f->numeric($label, $byline)->withNameFrom($this->name_source)->withError($error);
72 
73  $r = $this->getDefaultRenderer();
74  $html = $this->normalizeHTML($r->render($numeric));
75 
76  $expected = "<div class=\"form-group row\">" . " <label for=\"$name\" class=\"control-label col-sm-3\">$label</label>"
77  . " <div class=\"col-sm-9\">" . " <input type=\"number\" name=\"$name\" class=\"form-control form-control-sm\" />"
78  . " <div class=\"help-block\">$byline</div>" . " <div class=\"help-block alert alert-danger\" role=\"alert\">"
79  . " <img border=\"0\" src=\"./templates/default/images/icon_alert.svg\" alt=\"alert\" />" . " $error"
80  . " </div>" . " </div>" . "</div>";
81  $this->assertEquals($expected, $html);
82  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
$r
Definition: example_031.php:79
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ test_render_no_byline()

NumericInputTest::test_render_no_byline ( )

Definition at line 85 of file NumericInputTest.php.

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

86  {
87  $f = $this->buildFactory();
88  $label = "label";
89  $name = "name_0";
90  $numeric = $f->numeric($label)->withNameFrom($this->name_source);
91 
92  $r = $this->getDefaultRenderer();
93  $html = $this->normalizeHTML($r->render($numeric));
94 
95  $expected = "<div class=\"form-group row\">" . " <label for=\"$name\" class=\"control-label col-sm-3\">$label</label>"
96  . " <div class=\"col-sm-9\">" . " <input type=\"number\" name=\"$name\" class=\"form-control form-control-sm\" />"
97  . " " . " " . " </div>" . "</div>";
98  $this->assertEquals($expected, $html);
99  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
$r
Definition: example_031.php:79
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ test_render_value()

NumericInputTest::test_render_value ( )

Definition at line 102 of file NumericInputTest.php.

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

103  {
104  $f = $this->buildFactory();
105  $label = "label";
106  $value = "10";
107  $name = "name_0";
108  $numeric = $f->numeric($label)->withValue($value)->withNameFrom($this->name_source);
109 
110  $r = $this->getDefaultRenderer();
111  $html = $this->normalizeHTML($r->render($numeric));
112 
113  $expected = "<div class=\"form-group row\">" . " <label for=\"$name\" class=\"control-label col-sm-3\">$label</label>"
114  . " <div class=\"col-sm-9\">"
115  . " <input type=\"number\" value=\"$value\" name=\"$name\" class=\"form-control form-control-sm\" />" . " " . " "
116  . " </div>" . "</div>";
117  $this->assertEquals($expected, $html);
118  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
$r
Definition: example_031.php:79
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ testEmptyValue()

NumericInputTest::testEmptyValue (   $field)

testNullValue

Definition at line 139 of file NumericInputTest.php.

140  {
141  $post_data = new DefPostData(['name_0' => '']);
142  $field_required = $field->withRequired(true);
143 
144  $value = $field->withInput($post_data)->getContent();
145  $this->assertTrue($value->isOk());
146  $this->assertNull($value->value());
147  $this->assertFalse($value->value() === '');
148 
149  $value = $field_required->withInput($post_data)->getContent();
150  $this->assertTrue($value->isError());
151  }

◆ testNullValue()

NumericInputTest::testNullValue ( )

Definition at line 120 of file NumericInputTest.php.

References $f, and buildFactory().

121  {
122  $f = $this->buildFactory();
123  $post_data = new DefPostData(['name_0' => null]);
124  $field = $f->numeric('')->withNameFrom($this->name_source);
125  $field_required = $field->withRequired(true);
126 
127  $value = $field->withInput($post_data)->getContent();
128  $this->assertTrue($value->isOk());
129  $this->assertNull($value->value());
130 
131  $value = $field_required->withInput($post_data)->getContent();
132  $this->assertTrue($value->isError());
133  return $field;
134  }
+ Here is the call graph for this function:

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