ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
NumericInputTest Class Reference
+ Inheritance diagram for NumericInputTest:
+ Collaboration diagram for NumericInputTest:

Public Member Functions

 setUp ()
 
 testImplementsFactoryInterface ()
 
 testRender ()
 
 testCommonRendering ()
 
 testRenderValue ()
 
 testNullValue ()
 
 testEmptyValue (\ILIAS\UI\Component\Input\Container\Form\FormInput $field)
 testNullValue More...
 
 testZeroIsValidValue (\ILIAS\UI\Component\Input\Container\Form\FormInput $field)
 testNullValue More...
 
 testConstraintForRequirementForFloat (\ILIAS\UI\Component\Input\Container\Form\FormInput $field)
 testNullValue More...
 

Protected Attributes

DefNamesource $name_source
 

Detailed Description

Definition at line 32 of file NumericInputTest.php.

Member Function Documentation

◆ setUp()

NumericInputTest::setUp ( )

Definition at line 38 of file NumericInputTest.php.

38  : void
39  {
40  $this->name_source = new DefNamesource();
41  }

◆ testCommonRendering()

NumericInputTest::testCommonRendering ( )

Definition at line 71 of file NumericInputTest.php.

References Vendor\Package\$f.

71  : void
72  {
73  $f = $this->getFieldFactory();
74  $label = "label";
75  $numeric = $f->numeric($label)->withNameFrom($this->name_source);
76 
77  $this->testWithError($numeric);
78  $this->testWithNoByline($numeric);
79  $this->testWithRequired($numeric);
80  $this->testWithDisabled($numeric);
81  $this->testWithAdditionalOnloadCodeRendersId($numeric);
82  }

◆ testConstraintForRequirementForFloat()

NumericInputTest::testConstraintForRequirementForFloat ( \ILIAS\UI\Component\Input\Container\Form\FormInput  $field)

testNullValue

Definition at line 154 of file NumericInputTest.php.

154  : void
155  {
156  $post_data = new DefInputData(['name_0' => 1.1]);
157  $field_required = $field->withRequired(true);
158 
159  $value = $field->withInput($post_data)->getContent();
160  $this->assertTrue($value->isOk());
161  //Note, this float will be Transformed to int, since this input only accepts int
162  $this->assertEquals(1, $value->value());
163 
164  $value = $field_required->withInput($post_data)->getContent();
165  $this->assertTrue($value->isOK());
166  $this->assertEquals(1, $value->value());
167  }

◆ testEmptyValue()

NumericInputTest::testEmptyValue ( \ILIAS\UI\Component\Input\Container\Form\FormInput  $field)

testNullValue

Definition at line 120 of file NumericInputTest.php.

120  : void
121  {
122  $post_data = new DefInputData(['name_0' => '']);
123  $field_required = $field->withRequired(true);
124 
125  $value = $field->withInput($post_data)->getContent();
126  $this->assertTrue($value->isOk());
127  $this->assertNull($value->value());
128 
129  $field_required = $field_required->withInput($post_data);
130  $value = $field_required->getContent();
131  $this->assertTrue($value->isError());
132  }

◆ testImplementsFactoryInterface()

NumericInputTest::testImplementsFactoryInterface ( )

Definition at line 43 of file NumericInputTest.php.

References Vendor\Package\$f.

43  : void
44  {
45  $f = $this->getFieldFactory();
46 
47  $numeric = $f->numeric("label", "byline");
48 
49  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $numeric);
50  $this->assertInstanceOf(Field\Numeric::class, $numeric);
51  }
Interface Observer Contains several chained tasks and infos about them.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ testNullValue()

NumericInputTest::testNullValue ( )

Definition at line 101 of file NumericInputTest.php.

References Vendor\Package\$f.

101  : \ILIAS\UI\Component\Input\Container\Form\FormInput
102  {
103  $f = $this->getFieldFactory();
104  $post_data = new DefInputData(['name_0' => null]);
105  $field = $f->numeric('')->withNameFrom($this->name_source);
106  $field_required = $field->withRequired(true);
107 
108  $value = $field->withInput($post_data)->getContent();
109  $this->assertTrue($value->isOk());
110  $this->assertNull($value->value());
111 
112  $value = $field_required->withInput($post_data)->getContent();
113  $this->assertTrue($value->isError());
114  return $field;
115  }

◆ testRender()

NumericInputTest::testRender ( )

Definition at line 54 of file NumericInputTest.php.

References Vendor\Package\$f.

54  : void
55  {
56  $f = $this->getFieldFactory();
57  $label = "label";
58  $byline = "byline";
59  $numeric = $f->numeric($label, $byline)->withNameFrom($this->name_source);
60 
61  $expected = $this->getFormWrappedHtml(
62  'numeric-field-input',
63  $label,
64  '<input id="id_1" type="number" name="name_0" class="c-field-number" />',
65  $byline,
66  'id_1'
67  );
68  $this->assertEquals($expected, $this->render($numeric));
69  }

◆ testRenderValue()

NumericInputTest::testRenderValue ( )

Definition at line 84 of file NumericInputTest.php.

References Vendor\Package\$f.

84  : void
85  {
86  $f = $this->getFieldFactory();
87  $label = "label";
88  $value = "10";
89  $numeric = $f->numeric($label)->withValue($value)->withNameFrom($this->name_source);
90 
91  $expected = $this->getFormWrappedHtml(
92  'numeric-field-input',
93  $label,
94  '<input id="id_1" type="number" value="10" name="name_0" class="c-field-number" />',
95  null,
96  'id_1'
97  );
98  $this->assertEquals($expected, $this->render($numeric));
99  }

◆ testZeroIsValidValue()

NumericInputTest::testZeroIsValidValue ( \ILIAS\UI\Component\Input\Container\Form\FormInput  $field)

testNullValue

Definition at line 137 of file NumericInputTest.php.

137  : void
138  {
139  $post_data = new DefInputData(['name_0' => 0]);
140  $field_required = $field->withRequired(true);
141 
142  $value = $field->withInput($post_data)->getContent();
143  $this->assertTrue($value->isOk());
144  $this->assertEquals(0, $value->value());
145 
146  $value = $field_required->withInput($post_data)->getContent();
147  $this->assertTrue($value->isOK());
148  $this->assertEquals(0, $value->value());
149  }

Field Documentation

◆ $name_source

DefNamesource NumericInputTest::$name_source
protected

Definition at line 36 of file NumericInputTest.php.


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