ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
SelectInputTest Class Reference
+ Inheritance diagram for SelectInputTest:
+ Collaboration diagram for SelectInputTest:

Public Member Functions

 setUp ()
 
 testOnlyValuesFromOptionsAreAcceptableClientSideValues ()
 
 testEmptyStringIsAcceptableClientSideValueIfSelectIsNotRequired ()
 
 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 ()
 
 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 19 of file SelectTest.php.

Member Function Documentation

◆ buildFactory()

SelectInputTest::buildFactory ( )
protected

Definition at line 26 of file SelectTest.php.

27  {
28  $df = new Data\Factory();
29  $language = $this->createMock(\ilLanguage::class);
31  new SignalGenerator(),
32  $df,
33  new Refinery\Factory($df, $language),
34  $language
35  );
36  }
Builds data types.
Definition: Factory.php:19

◆ setUp()

SelectInputTest::setUp ( )

Definition at line 21 of file SelectTest.php.

21  : void
22  {
23  $this->name_source = new DefNamesource();
24  }

◆ test_render()

SelectInputTest::test_render ( )

Definition at line 83 of file SelectTest.php.

References Vendor\Package\$f.

84  {
85  $f = $this->buildFactory();
86  $label = "label";
87  $byline = "byline";
88  $options = ["one" => "One", "two" => "Two", "three" => "Three"];
89  $select = $f->select($label, $options, $byline)->withNameFrom($this->name_source);
90 
91  $r = $this->getDefaultRenderer();
92  $html = $this->brutallyTrimHTML($r->render($select));
93 
94  $expected = $this->brutallyTrimHTML('
95 <div class="form-group row">
96  <label for="id_1" class="control-label col-sm-3">label</label>
97  <div class="col-sm-9">
98  <select id="id_1" name="name_0">
99  <option selected="selected" value="">-</option>
100  <option value="one">One</option>
101  <option value="two">Two</option>
102  <option value="three">Three</option>
103  </select>
104  <div class="help-block">byline</div>
105  </div>
106 </div>
107 ');
108  $this->assertEquals($expected, $html);
109  }
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311

◆ test_render_disabled()

SelectInputTest::test_render_disabled ( )

Definition at line 140 of file SelectTest.php.

References Vendor\Package\$f.

141  {
142  $f = $this->buildFactory();
143  $label = "label";
144  $byline = "byline";
145  $options = ["one" => "One", "two" => "Two", "three" => "Three"];
146  $select = $f->select($label, $options, $byline)->withNameFrom($this->name_source)->withDisabled(true);
147 
148  $r = $this->getDefaultRenderer();
149  $html = $this->brutallyTrimHTML($r->render($select));
150 
151  $expected = $this->brutallyTrimHTML('
152 <div class="form-group row">
153  <label for="id_1" class="control-label col-sm-3">label</label>
154  <div class="col-sm-9">
155  <select id="id_1" name="name_0" disabled="disabled">
156  <option selected="selected" value="">-</option>
157  <option value="one">One</option>
158  <option value="two">Two</option>
159  <option value="three">Three</option>
160  </select>
161  <div class="help-block">byline</div>
162  </div>
163 </div>
164 ');
165  $this->assertEquals($expected, $html);
166  }
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311

◆ test_render_value()

SelectInputTest::test_render_value ( )

Definition at line 112 of file SelectTest.php.

References Vendor\Package\$f.

113  {
114  $f = $this->buildFactory();
115  $label = "label";
116  $byline = "byline";
117  $options = ["one" => "One", "two" => "Two", "three" => "Three"];
118  $select = $f->select($label, $options, $byline)->withNameFrom($this->name_source)->withValue("one");
119 
120  $r = $this->getDefaultRenderer();
121  $html = $this->brutallyTrimHTML($r->render($select));
122 
123  $expected = $this->brutallyTrimHTML('
124 <div class="form-group row">
125  <label for="id_1" class="control-label col-sm-3">label</label>
126  <div class="col-sm-9">
127  <select id="id_1" name="name_0">
128  <option value="">-</option>
129  <option selected="selected" value="one">One</option>
130  <option value="two">Two</option>
131  <option value="three">Three</option>
132  </select>
133  <div class="help-block">byline</div>
134  </div>
135 </div>
136 ');
137  $this->assertEquals($expected, $html);
138  }
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311

◆ testEmptyStringIsAcceptableClientSideValueIfSelectIsNotRequired()

SelectInputTest::testEmptyStringIsAcceptableClientSideValueIfSelectIsNotRequired ( )

Definition at line 55 of file SelectTest.php.

56  {
57  $options = [];
58  $select = new SelectForTest(
59  $this->createMock(ILIAS\Data\Factory::class),
60  $this->createMock(ILIAS\Refinery\Factory::class),
61  "",
62  $options,
63  ""
64  );
65 
66  $this->assertTrue($select->_isClientSideValueOk(""));
67  }
Class ChatMainBarProvider .

◆ testEmptyStringIsAnAcceptableClientSideValueEvenIfSelectIsRequired()

SelectInputTest::testEmptyStringIsAnAcceptableClientSideValueEvenIfSelectIsRequired ( )

Definition at line 69 of file SelectTest.php.

References ILIAS\UI\Component\Input\Field\FormInput\withRequired().

70  {
71  $options = [];
72  $select = (new SelectForTest(
73  $this->createMock(ILIAS\Data\Factory::class),
74  $this->createMock(ILIAS\Refinery\Factory::class),
75  "",
76  $options,
77  ""
78  ))->withRequired(true);
79 
80  $this->assertTrue($select->_isClientSideValueOk(""));
81  }
Class ChatMainBarProvider .
+ Here is the call graph for this function:

◆ testOnlyValuesFromOptionsAreAcceptableClientSideValues()

SelectInputTest::testOnlyValuesFromOptionsAreAcceptableClientSideValues ( )

Definition at line 38 of file SelectTest.php.

39  {
40  $options = ["one" => "Eins", "two" => "Zwei", "three" => "Drei"];
41  $select = new SelectForTest(
42  $this->createMock(ILIAS\Data\Factory::class),
43  $this->createMock(ILIAS\Refinery\Factory::class),
44  "",
45  $options,
46  ""
47  );
48 
49  $this->assertTrue($select->_isClientSideValueOk("one"));
50  $this->assertTrue($select->_isClientSideValueOk("two"));
51  $this->assertTrue($select->_isClientSideValueOk("three"));
52  $this->assertFalse($select->_isClientSideValueOk("four"));
53  }
Class ChatMainBarProvider .

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