ILIAS  release_8 Revision v8.24
SelectInputTest Class Reference
+ Inheritance diagram for SelectInputTest:
+ Collaboration diagram for SelectInputTest:

Public Member Functions

 setUp ()
 
 testOnlyValuesFromOptionsAreAcceptableClientSideValues ()
 
 testEmptyStringIsAcceptableClientSideValueIfSelectIsNotRequired ()
 
 testEmptyStringCreatesErrorIfSelectIsRequired ()
 
 testEmptyStringIsAnAcceptableClientSideValueEvenIfSelectIsRequired ()
 
 test_render ()
 
 test_render_value ()
 
 test_render_disabled ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML (string $html)
 
 assertHTMLEquals (string $expected_html_as_string, string $html_as_string)
 

Protected Member Functions

 buildFactory ()
 
- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML (string $html)
 A more radical version of normalizeHTML. More...
 
 brutallyTrimSignals (string $html)
 A naive replacement of all il_signal-ids with dots to ease comparisons of rendered output. More...
 

Protected Attributes

DefNamesource $name_source
 

Detailed Description

Definition at line 37 of file SelectTest.php.

Member Function Documentation

◆ buildFactory()

SelectInputTest::buildFactory ( )
protected

Definition at line 46 of file SelectTest.php.

46 : I\Input\Field\Factory
47 {
48 $df = new Data\Factory();
49 $language = $this->createMock(ilLanguage::class);
50 return new I\Input\Field\Factory(
51 $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
52 new SignalGenerator(),
53 $df,
54 new Refinery($df, $language),
55 $language
56 );
57 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.

Referenced by test_render(), test_render_disabled(), test_render_value(), and testEmptyStringCreatesErrorIfSelectIsRequired().

+ Here is the caller graph for this function:

◆ setUp()

SelectInputTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 41 of file SelectTest.php.

41 : void
42 {
43 $this->name_source = new DefNamesource();
44 }

◆ test_render()

SelectInputTest::test_render ( )

Definition at line 126 of file SelectTest.php.

126 : void
127 {
128 $f = $this->buildFactory();
129 $label = "label";
130 $byline = "byline";
131 $options = ["one" => "One", "two" => "Two", "three" => "Three"];
132 $select = $f->select($label, $options, $byline)->withNameFrom($this->name_source);
133
134 $r = $this->getDefaultRenderer();
135 $html = $this->brutallyTrimHTML($r->render($select));
136
137 $expected = $this->brutallyTrimHTML('
138<div class="form-group row">
139 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">label</label>
140 <div class="col-sm-8 col-md-9 col-lg-10">
141 <select id="id_1" name="name_0">
142 <option selected="selected" value="">-</option>
143 <option value="one">One</option>
144 <option value="two">Two</option>
145 <option value="three">Three</option>
146 </select>
147 <div class="help-block">byline</div>
148 </div>
149</div>
150');
151 $this->assertEquals($expected, $html);
152 }
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:444
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355

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

+ Here is the call graph for this function:

◆ test_render_disabled()

SelectInputTest::test_render_disabled ( )

Definition at line 183 of file SelectTest.php.

183 : void
184 {
185 $f = $this->buildFactory();
186 $label = "label";
187 $byline = "byline";
188 $options = ["one" => "One", "two" => "Two", "three" => "Three"];
189 $select = $f->select($label, $options, $byline)->withNameFrom($this->name_source)->withDisabled(true);
190
191 $r = $this->getDefaultRenderer();
192 $html = $this->brutallyTrimHTML($r->render($select));
193
194 $expected = $this->brutallyTrimHTML('
195<div class="form-group row">
196 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">label</label>
197 <div class="col-sm-8 col-md-9 col-lg-10">
198 <select id="id_1" name="name_0" disabled="disabled">
199 <option selected="selected" value="">-</option>
200 <option value="one">One</option>
201 <option value="two">Two</option>
202 <option value="three">Three</option>
203 </select>
204 <div class="help-block">byline</div>
205 </div>
206</div>
207');
208 $this->assertEquals($expected, $html);
209 }

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

+ Here is the call graph for this function:

◆ test_render_value()

SelectInputTest::test_render_value ( )

Definition at line 155 of file SelectTest.php.

155 : void
156 {
157 $f = $this->buildFactory();
158 $label = "label";
159 $byline = "byline";
160 $options = ["one" => "One", "two" => "Two", "three" => "Three"];
161 $select = $f->select($label, $options, $byline)->withNameFrom($this->name_source)->withValue("one");
162
163 $r = $this->getDefaultRenderer();
164 $html = $this->brutallyTrimHTML($r->render($select));
165
166 $expected = $this->brutallyTrimHTML('
167<div class="form-group row">
168 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">label</label>
169 <div class="col-sm-8 col-md-9 col-lg-10">
170 <select id="id_1" name="name_0">
171 <option value="">-</option>
172 <option selected="selected" value="one">One</option>
173 <option value="two">Two</option>
174 <option value="three">Three</option>
175 </select>
176 <div class="help-block">byline</div>
177 </div>
178</div>
179');
180 $this->assertEquals($expected, $html);
181 }

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

+ Here is the call graph for this function:

◆ testEmptyStringCreatesErrorIfSelectIsRequired()

SelectInputTest::testEmptyStringCreatesErrorIfSelectIsRequired ( )

Definition at line 90 of file SelectTest.php.

90 : void
91 {
92 $options = [];
93 $select = $this->buildFactory()->select(
94 "",
95 $options,
96 ""
97 )
98 ->withRequired(true)
99 ->withNameFrom($this->name_source);
100
101 $data = $this->createMock(InputData::class);
102 $data->expects($this->once())
103 ->method("getOr")
104 ->willReturn(null);
105 $select = $select->withInput(
106 $data
107 );
108
109 $this->assertNotEquals(null, $select->getError());
110 }

References $data, and buildFactory().

+ Here is the call graph for this function:

◆ testEmptyStringIsAcceptableClientSideValueIfSelectIsNotRequired()

SelectInputTest::testEmptyStringIsAcceptableClientSideValueIfSelectIsNotRequired ( )

Definition at line 76 of file SelectTest.php.

76 : void
77 {
78 $options = [];
79 $select = new SelectForTest(
80 $this->createMock(ILIAS\Data\Factory::class),
81 $this->createMock(ILIAS\Refinery\Factory::class),
82 "",
83 $options,
84 ""
85 );
86
87 $this->assertTrue($select->_isClientSideValueOk(""));
88 }

◆ testEmptyStringIsAnAcceptableClientSideValueEvenIfSelectIsRequired()

SelectInputTest::testEmptyStringIsAnAcceptableClientSideValueEvenIfSelectIsRequired ( )

Definition at line 112 of file SelectTest.php.

112 : void
113 {
114 $options = [];
115 $select = (new SelectForTest(
116 $this->createMock(ILIAS\Data\Factory::class),
117 $this->createMock(ILIAS\Refinery\Factory::class),
118 "",
119 $options,
120 ""
121 ))->withRequired(true);
122
123 $this->assertTrue($select->_isClientSideValueOk(""));
124 }

◆ testOnlyValuesFromOptionsAreAcceptableClientSideValues()

SelectInputTest::testOnlyValuesFromOptionsAreAcceptableClientSideValues ( )

Definition at line 59 of file SelectTest.php.

59 : void
60 {
61 $options = ["one" => "Eins", "two" => "Zwei", "three" => "Drei"];
62 $select = new SelectForTest(
63 $this->createMock(ILIAS\Data\Factory::class),
64 $this->createMock(ILIAS\Refinery\Factory::class),
65 "",
66 $options,
67 ""
68 );
69
70 $this->assertTrue($select->_isClientSideValueOk("one"));
71 $this->assertTrue($select->_isClientSideValueOk("two"));
72 $this->assertTrue($select->_isClientSideValueOk("three"));
73 $this->assertFalse($select->_isClientSideValueOk("four"));
74 }

Field Documentation

◆ $name_source

DefNamesource SelectInputTest::$name_source
protected

Definition at line 39 of file SelectTest.php.


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