ILIAS  release_8 Revision v8.24
TagInputTest Class Reference

Class TagInputTest. More...

+ Inheritance diagram for TagInputTest:
+ Collaboration diagram for TagInputTest:

Public Member Functions

 setUp ()
 
 testImplementsFactoryInterface ()
 @doesNotPerformAssertions More...
 
 testRender ()
 
 testRenderError ()
 
 testRenderNoByline ()
 
 testRenderRequired ()
 
 testRenderDisabled ()
 
 testNullValueLeadsToException ()
 
 testUserCreatedNotAllowed ()
 
 testMaxTagsOk ()
 
 test_max_tags_not_ok ()
 
 testMaxTaglengthTagsOk ()
 
 testMaxTaglengthTagsNotOk ()
 
- 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

Class TagInputTest.

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

Definition at line 35 of file TagInputTest.php.

Member Function Documentation

◆ buildFactory()

TagInputTest::buildFactory ( )
protected

Definition at line 44 of file TagInputTest.php.

44 : I\Input\Field\Factory
45 {
46 $df = new Data\Factory();
47 $language = $this->createMock(ilLanguage::class);
48 return new I\Input\Field\Factory(
49 $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
50 new SignalGenerator(),
51 $df,
52 new Refinery($df, $language),
53 $language
54 );
55 }
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_max_tags_not_ok(), testImplementsFactoryInterface(), testMaxTaglengthTagsNotOk(), testMaxTaglengthTagsOk(), testMaxTagsOk(), testNullValueLeadsToException(), testRender(), testRenderDisabled(), testRenderError(), testRenderNoByline(), testRenderRequired(), and testUserCreatedNotAllowed().

+ Here is the caller graph for this function:

◆ setUp()

TagInputTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 39 of file TagInputTest.php.

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

◆ test_max_tags_not_ok()

TagInputTest::test_max_tags_not_ok ( )

Definition at line 298 of file TagInputTest.php.

298 : void
299 {
300 $f = $this->buildFactory();
301
302 $this->expectException(InvalidArgumentException::class);
303 $f->tag("label", [])->withMaxTags(2)->withNameFrom($this->name_source)->withInput(
304 new DefInputData(
305 ["name_0" => "lorem,ipsum,dolor"]
306 )
307 );
308 }

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

+ Here is the call graph for this function:

◆ testImplementsFactoryInterface()

TagInputTest::testImplementsFactoryInterface ( )

@doesNotPerformAssertions

Definition at line 60 of file TagInputTest.php.

60 : void
61 {
62 $f = $this->buildFactory();
63
64 $f->tag(
65 "label",
66 ["lorem", "ipsum", "dolor"],
67 "byline"
68 );
69 }

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

+ Here is the call graph for this function:

◆ testMaxTaglengthTagsNotOk()

TagInputTest::testMaxTaglengthTagsNotOk ( )

Definition at line 321 of file TagInputTest.php.

321 : void
322 {
323 $f = $this->buildFactory();
324
325 $this->expectException(InvalidArgumentException::class);
326 $f->tag("label", [])->withTagMaxLength(2)->withNameFrom($this->name_source)->withInput(
327 new DefInputData(
328 ["name_0" => "lorem,ipsum,dolor"]
329 )
330 );
331 }

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

+ Here is the call graph for this function:

◆ testMaxTaglengthTagsOk()

TagInputTest::testMaxTaglengthTagsOk ( )

Definition at line 310 of file TagInputTest.php.

310 : void
311 {
312 $f = $this->buildFactory();
313
314 $tag = $f->tag("label", [])->withTagMaxLength(10)->withNameFrom($this->name_source)->withInput(
315 new DefInputData(["name_0" => "lorem,ipsum"])
316 );
317 $value = $tag->getContent();
318 $this->assertTrue($value->isOk());
319 }

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

+ Here is the call graph for this function:

◆ testMaxTagsOk()

TagInputTest::testMaxTagsOk ( )

Definition at line 287 of file TagInputTest.php.

287 : void
288 {
289 $f = $this->buildFactory();
290
291 $tag = $f->tag("label", [])->withMaxTags(3)->withNameFrom($this->name_source)->withInput(
292 new DefInputData(["name_0" => "lorem,ipsum"])
293 );
294 $value = $tag->getContent();
295 $this->assertTrue($value->isOk());
296 }

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

+ Here is the call graph for this function:

◆ testNullValueLeadsToException()

TagInputTest::testNullValueLeadsToException ( )

Definition at line 244 of file TagInputTest.php.

244 : void
245 {
246 $f = $this->buildFactory();
247 $label = "label";
248 $name = "name_0";
249 $tags = ["lorem", "ipsum", "dolor",];
250
251 $tag = $f->tag($label, $tags)->withNameFrom($this->name_source)->withRequired(true);
252 $tag2 = $tag->withInput(new DefInputData([$name => null]));
253 $value2 = $tag2->getContent();
254 $this->assertTrue($value2->isError());
255 }
if($format !==null) $name
Definition: metadata.php:247

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

+ Here is the call graph for this function:

◆ testRender()

TagInputTest::testRender ( )

Definition at line 71 of file TagInputTest.php.

71 : void
72 {
73 $f = $this->buildFactory();
74 $label = "label";
75 $byline = "byline";
76 $tags = ["lorem", "ipsum", "dolor",];
77 $text = $f->tag($label, $tags, $byline)->withNameFrom($this->name_source);
78
79 $r = $this->getDefaultRenderer();
80 $html = $this->brutallyTrimHTML($r->render($text));
81 $expected = $this->brutallyTrimHTML('
82 <div class="form-group row">
83 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">label</label>
84 <div class="col-sm-8 col-md-9 col-lg-10">
85 <div id="container-id_1" class="form-control form-control-sm il-input-tag-container">
86 <input id="id_1" name="name_0" class="form-control form-control-sm il-input-tag" value=""/>
87 </div>
88 <div class="help-block">byline</div>
89 </div>
90 </div>
91 ');
92 $this->assertEquals($expected, $html);
93 }
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:

◆ testRenderDisabled()

TagInputTest::testRenderDisabled ( )

Definition at line 167 of file TagInputTest.php.

167 : void
168 {
169 $f = $this->buildFactory();
170 $label = "label";
171 $tags = ["lorem", "ipsum", "dolor",];
172 $text = $f->tag($label, $tags)->withNameFrom($this->name_source)->withDisabled(true);
173
174 $r = $this->getDefaultRenderer();
175 $html = $this->brutallyTrimHTML($r->render($text));
176
177 $expected = $this->brutallyTrimHTML('
178 <div class="form-group row">
179 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">label</label>
180 <div class="col-sm-8 col-md-9 col-lg-10">
181 <div id="container-id_1" class="form-control form-control-sm il-input-tag-container disabled">
182 <input id="id_1" name="name_0" class="form-control form-control-sm il-input-tag" readonly value=""/>
183 </div>
184 </div>
185 </div>
186 ');
187
188 $this->assertEquals($expected, $html);
189 }

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

+ Here is the call graph for this function:

◆ testRenderError()

TagInputTest::testRenderError ( )

Definition at line 95 of file TagInputTest.php.

95 : void
96 {
97 $f = $this->buildFactory();
98 $label = "label";
99 $byline = "byline";
100 $tags = ["lorem", "ipsum", "dolor",];
101 $error = "an_error";
102 $text = $f->tag($label, $tags, $byline)->withNameFrom($this->name_source)->withError($error);
103
104 $r = $this->getDefaultRenderer();
105 $html = $this->brutallyTrimHTML($r->render($text));
106 $expected = $this->brutallyTrimHTML('
107 <div class="form-group row">
108 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">label</label>
109 <div class="col-sm-8 col-md-9 col-lg-10">
110 <div class="help-block alert alert-danger" aria-describedby="id_1" role="alert">an_error</div>
111 <div id="container-id_1" class="form-control form-control-sm il-input-tag-container">
112 <input id="id_1" name="name_0" class="form-control form-control-sm il-input-tag" value=""/>
113 </div>
114 <div class="help-block">byline</div>
115 </div>
116 </div>
117 ');
118 $this->assertEquals($expected, $html);
119 }

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

+ Here is the call graph for this function:

◆ testRenderNoByline()

TagInputTest::testRenderNoByline ( )

Definition at line 121 of file TagInputTest.php.

121 : void
122 {
123 $f = $this->buildFactory();
124 $label = "label";
125 $tags = ["lorem", "ipsum", "dolor",];
126 $text = $f->tag($label, $tags)->withNameFrom($this->name_source);
127
128 $r = $this->getDefaultRenderer();
129 $html = $this->brutallyTrimHTML($r->render($text));
130 $expected = $this->brutallyTrimHTML('
131 <div class="form-group row">
132 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">label</label>
133 <div class="col-sm-8 col-md-9 col-lg-10">
134 <div id="container-id_1" class="form-control form-control-sm il-input-tag-container">
135 <input id="id_1" name="name_0" class="form-control form-control-sm il-input-tag" value=""/>
136 </div>
137 </div>
138 </div>
139 ');
140 $this->assertEquals($expected, $html);
141 }

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

+ Here is the call graph for this function:

◆ testRenderRequired()

TagInputTest::testRenderRequired ( )

Definition at line 143 of file TagInputTest.php.

143 : void
144 {
145 $f = $this->buildFactory();
146 $label = "label";
147 $tags = ["lorem", "ipsum", "dolor",];
148 $text = $f->tag($label, $tags)->withNameFrom($this->name_source)->withRequired(true);
149
150 $r = $this->getDefaultRenderer();
151 $html = $this->brutallyTrimHTML($r->render($text));
152
153 $expected = $this->brutallyTrimHTML('
154 <div class="form-group row">
155 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">label<span class="asterisk">*</span></label>
156 <div class="col-sm-8 col-md-9 col-lg-10">
157 <div id="container-id_1" class="form-control form-control-sm il-input-tag-container">
158 <input id="id_1" name="name_0" class="form-control form-control-sm il-input-tag" value=""/>
159 </div>
160 </div>
161 </div>
162 ');
163
164 $this->assertEquals($expected, $html);
165 }

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

+ Here is the call graph for this function:

◆ testUserCreatedNotAllowed()

TagInputTest::testUserCreatedNotAllowed ( )

Definition at line 257 of file TagInputTest.php.

257 : void
258 {
259 $this->markTestSkipped("This is supposed to work, but currently does not.");
260
261 $f = $this->buildFactory();
262 $tags = ["lorem", "ipsum", "dolor",];
263 $tag = $f->tag("label", $tags)->withUserCreatedTagsAllowed(false)->withNameFrom($this->name_source);
264
265 $tag1 = $tag->withInput(
266 new DefInputData(
267 ["name_0" => "lorem,ipsum"]
268 )
269 );
270 $value1 = $tag1->getContent();
271 $this->assertTrue($value1->isOk());
272 $value = $value1->value();
273 $this->assertEquals(
274 ["lorem", "ipsum"],
275 $value
276 );
277
278 $tag1 = $tag->withInput(
279 new DefInputData(
280 ["name_0" => "conseptetuer,ipsum"]
281 )
282 );
283 $value1 = $tag1->getContent();
284 $this->assertTrue($value1->isError());
285 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $name_source

DefNamesource TagInputTest::$name_source
protected

Definition at line 37 of file TagInputTest.php.


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