ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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 ()
 
 test_render_disabled ()
 
 testNullValue ()
 
 testEmptyValue ($field)
 testNullValue More...
 
 testZeroIsValidValue ($field)
 testNullValue More...
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Protected Member Functions

 buildFactory ()
 
- 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 NumericInputTest.php.

Member Function Documentation

◆ buildFactory()

NumericInputTest::buildFactory ( )
protected

Definition at line 22 of file NumericInputTest.php.

References ILIAS_UI_TestBase\getLanguage().

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

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

◆ setUp()

NumericInputTest::setUp ( )

Definition at line 16 of file NumericInputTest.php.

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

◆ test_implements_factory_interface()

NumericInputTest::test_implements_factory_interface ( )

Definition at line 35 of file NumericInputTest.php.

References Vendor\Package\$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 Vendor\Package\$f, $name, ILIAS_UI_TestBase\brutallyTrimHTML(), buildFactory(), and ILIAS_UI_TestBase\getDefaultRenderer().

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->brutallyTrimHTML($r->render($numeric));
56 
57  $expected = $this->brutallyTrimHTML('
58 <div class="form-group row">
59  <label for="id_1" class="control-label col-sm-3">label</label>
60  <div class="col-sm-9">
61  <input id="id_1" type="number" name="name_0" class="form-control form-control-sm" />
62  <div class="help-block">byline</div>
63  </div>
64 </div>
65 ');
66  $this->brutallyTrimHTML($expected, $html);
67  $this->assertEquals($expected, $html);
68  }
if($format !==null) $name
Definition: metadata.php:230
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ test_render_disabled()

NumericInputTest::test_render_disabled ( )

Definition at line 136 of file NumericInputTest.php.

References Vendor\Package\$f, $name, ILIAS_UI_TestBase\brutallyTrimHTML(), buildFactory(), and ILIAS_UI_TestBase\getDefaultRenderer().

137  {
138  $f = $this->buildFactory();
139  $label = "label";
140  $name = "name_0";
141  $numeric = $f->numeric($label)->withNameFrom($this->name_source)->withDisabled(true);
142 
143  $r = $this->getDefaultRenderer();
144  $html = $this->brutallyTrimHTML($r->render($numeric));
145 
146  $expected = $this->brutallyTrimHTML('
147 <div class="form-group row">
148  <label for="id_1" class="control-label col-sm-3">label</label>
149  <div class="col-sm-9"> <input id="id_1" type="number" name="name_0" disabled="disabled" class="form-control form-control-sm" /> </div>
150 </div>');
151  $this->assertEquals($expected, $html);
152  }
if($format !==null) $name
Definition: metadata.php:230
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ test_render_error()

NumericInputTest::test_render_error ( )

Definition at line 71 of file NumericInputTest.php.

References Vendor\Package\$f, $name, ILIAS_UI_TestBase\brutallyTrimHTML(), buildFactory(), and ILIAS_UI_TestBase\getDefaultRenderer().

72  {
73  $f = $this->buildFactory();
74  $label = "label";
75  $byline = "byline";
76  $name = "name_0";
77  $error = "an_error";
78  $numeric = $f->numeric($label, $byline)->withNameFrom($this->name_source)->withError($error);
79 
80  $r = $this->getDefaultRenderer();
81  $html = $this->brutallyTrimHTML($r->render($numeric));
82 
83  $expected = $this->brutallyTrimHTML('
84 <div class="form-group row">
85  <label for="id_1" class="control-label col-sm-3">label</label>
86  <div class="col-sm-9">
87  <div class="help-block alert alert-danger" role="alert">an_error</div>
88  <input id="id_1" type="number" name="name_0" class="form-control form-control-sm" />
89  <div class="help-block">byline</div>
90  </div>
91 </div>');
92  $this->assertEquals($expected, $html);
93  }
if($format !==null) $name
Definition: metadata.php:230
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ test_render_no_byline()

NumericInputTest::test_render_no_byline ( )

Definition at line 96 of file NumericInputTest.php.

References Vendor\Package\$f, $name, ILIAS_UI_TestBase\brutallyTrimHTML(), buildFactory(), and ILIAS_UI_TestBase\getDefaultRenderer().

97  {
98  $f = $this->buildFactory();
99  $label = "label";
100  $name = "name_0";
101  $numeric = $f->numeric($label)->withNameFrom($this->name_source);
102 
103  $r = $this->getDefaultRenderer();
104  $html = $this->brutallyTrimHTML($r->render($numeric));
105 
106  $expected = $this->brutallyTrimHTML('
107 <div class="form-group row">
108  <label for="id_1" class="control-label col-sm-3">label</label>
109  <div class="col-sm-9"> <input id="id_1" type="number" name="name_0" class="form-control form-control-sm" /> </div>
110 </div>
111 ');
112  $this->assertEquals($expected, $html);
113  }
if($format !==null) $name
Definition: metadata.php:230
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ test_render_value()

NumericInputTest::test_render_value ( )

Definition at line 116 of file NumericInputTest.php.

References Vendor\Package\$f, $name, ILIAS_UI_TestBase\brutallyTrimHTML(), buildFactory(), and ILIAS_UI_TestBase\getDefaultRenderer().

117  {
118  $f = $this->buildFactory();
119  $label = "label";
120  $value = "10";
121  $name = "name_0";
122  $numeric = $f->numeric($label)->withValue($value)->withNameFrom($this->name_source);
123 
124  $r = $this->getDefaultRenderer();
125  $html = $this->brutallyTrimHTML($r->render($numeric));
126 
127  $expected = $this->brutallyTrimHTML('
128 <div class="form-group row">
129  <label for="id_1" class="control-label col-sm-3">label</label>
130  <div class="col-sm-9"> <input id="id_1" type="number" value="10" name="name_0" class="form-control form-control-sm" /> </div>
131 </div>
132 ');
133  $this->assertEquals($expected, $html);
134  }
if($format !==null) $name
Definition: metadata.php:230
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ testEmptyValue()

NumericInputTest::testEmptyValue (   $field)

testNullValue

Definition at line 173 of file NumericInputTest.php.

174  {
175  $post_data = new DefInputData(['name_0' => '']);
176  $field_required = $field->withRequired(true);
177 
178  $value = $field->withInput($post_data)->getContent();
179  $this->assertTrue($value->isOk());
180  $this->assertNull($value->value());
181 
182  $field_required = $field_required->withInput($post_data);
183  $value = $field_required->getContent();
184  $this->assertTrue($value->isError());
185  }

◆ testNullValue()

NumericInputTest::testNullValue ( )

Definition at line 154 of file NumericInputTest.php.

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

155  {
156  $f = $this->buildFactory();
157  $post_data = new DefInputData(['name_0' => null]);
158  $field = $f->numeric('')->withNameFrom($this->name_source);
159  $field_required = $field->withRequired(true);
160 
161  $value = $field->withInput($post_data)->getContent();
162  $this->assertTrue($value->isOk());
163  $this->assertNull($value->value());
164 
165  $value = $field_required->withInput($post_data)->getContent();
166  $this->assertTrue($value->isError());
167  return $field;
168  }
+ Here is the call graph for this function:

◆ testZeroIsValidValue()

NumericInputTest::testZeroIsValidValue (   $field)

testNullValue

Definition at line 190 of file NumericInputTest.php.

191  {
192  $post_data = new DefInputData(['name_0' => 0]);
193  $field_required = $field->withRequired(true);
194 
195  $value = $field->withInput($post_data)->getContent();
196  $this->assertTrue($value->isOk());
197  $this->assertEquals(0, $value->value());
198 
199  $value = $field_required->withInput($post_data)->getContent();
200  $this->assertTrue($value->isOK());
201  $this->assertEquals(0, $value->value());
202  }

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