ILIAS  release_7 Revision v7.30-3-g800a261c036
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 ()
 
 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...
 

Private Attributes

 $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 18 of file TagInputTest.php.

Member Function Documentation

◆ buildFactory()

TagInputTest::buildFactory ( )
protected

Definition at line 30 of file TagInputTest.php.

31 {
32 $df = new Data\Factory();
33 $language = $this->createMock(\ilLanguage::class);
35 new SignalGenerator(),
36 $df,
37 new \ILIAS\Refinery\Factory($df, $language),
38 $language
39 );
40 }
Builds data types.
Definition: Factory.php:20
Class ChatMainBarProvider \MainMenu\Provider.

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 25 of file TagInputTest.php.

25 : void
26 {
27 $this->name_source = new DefNamesource();
28 }

◆ test_max_tags_not_ok()

TagInputTest::test_max_tags_not_ok ( )

Definition at line 289 of file TagInputTest.php.

289 : void
290 {
291 $f = $this->buildFactory();
292
293 $this->expectException(\InvalidArgumentException::class);
294 $f->tag("label", [])->withMaxTags(2)->withNameFrom($this->name_source)->withInput(
295 new DefInputData(
296 ["name_0" => "lorem,ipsum,dolor"]
297 )
298 );
299 }

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

+ Here is the call graph for this function:

◆ testImplementsFactoryInterface()

TagInputTest::testImplementsFactoryInterface ( )

@doesNotPerformAssertions

Definition at line 45 of file TagInputTest.php.

45 : void
46 {
47 $f = $this->buildFactory();
48
49 $tag = $f->tag(
50 "label",
51 ["lorem", "ipsum", "dolor",],
52 "byline"
53 );
54 }

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

+ Here is the call graph for this function:

◆ testMaxTaglengthTagsNotOk()

TagInputTest::testMaxTaglengthTagsNotOk ( )

Definition at line 314 of file TagInputTest.php.

314 : void
315 {
316 $f = $this->buildFactory();
317
318 $this->expectException(\InvalidArgumentException::class);
319 $f->tag("label", [])->withTagMaxLength(2)->withNameFrom($this->name_source)->withInput(
320 new DefInputData(
321 ["name_0" => "lorem,ipsum,dolor"]
322 )
323 );
324 }

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

+ Here is the call graph for this function:

◆ testMaxTaglengthTagsOk()

TagInputTest::testMaxTaglengthTagsOk ( )

Definition at line 302 of file TagInputTest.php.

302 : void
303 {
304 $f = $this->buildFactory();
305
306 $tag = $f->tag("label", [])->withTagMaxLength(10)->withNameFrom($this->name_source)->withInput(
307 new DefInputData(["name_0" => "lorem,ipsum"])
308 );
309 $value = $tag->getContent();
310 $this->assertTrue($value->isOk());
311 }

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

+ Here is the call graph for this function:

◆ testMaxTagsOk()

TagInputTest::testMaxTagsOk ( )

Definition at line 277 of file TagInputTest.php.

277 : void
278 {
279 $f = $this->buildFactory();
280
281 $tag = $f->tag("label", [])->withMaxTags(3)->withNameFrom($this->name_source)->withInput(
282 new DefInputData(["name_0" => "lorem,ipsum"])
283 );
284 $value = $tag->getContent();
285 $this->assertTrue($value->isOk());
286 }

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

+ Here is the call graph for this function:

◆ testNullValueLeadsToException()

TagInputTest::testNullValueLeadsToException ( )

Definition at line 233 of file TagInputTest.php.

233 : void
234 {
235 $f = $this->buildFactory();
236 $label = "label";
237 $name = "name_0";
238 $tags = ["lorem", "ipsum", "dolor",];
239
240 $tag = $f->tag($label, $tags)->withNameFrom($this->name_source)->withRequired(true);
241 $tag2 = $tag->withInput(new DefInputData([$name => null]));
242 $value2 = $tag2->getContent();
243 $this->assertTrue($value2->isError());
244 }
if($format !==null) $name
Definition: metadata.php:230

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

+ Here is the call graph for this function:

◆ testRender()

TagInputTest::testRender ( )

Definition at line 56 of file TagInputTest.php.

56 : void
57 {
58 $f = $this->buildFactory();
59 $label = "label";
60 $byline = "byline";
61 $tags = ["lorem", "ipsum", "dolor",];
62 $name = "name_0";
63 $text = $f->tag($label, $tags, $byline)->withNameFrom($this->name_source);
64
65 $r = $this->getDefaultRenderer();
66 $html = $this->brutallyTrimHTML($r->render($text));
67 $expected = $this->brutallyTrimHTML('
68 <div class="form-group row">
69 <label for="id_1" class="control-label col-sm-3">label</label>
70 <div class="col-sm-9">
71 <div id="container-id_1" class="form-control form-control-sm il-input-tag-container">
72 <input id="id_1" name="name_0" class="form-control form-control-sm il-input-tag" value=""/>
73 </div>
74 <div class="help-block">byline</div>
75 </div>
76 </div>
77 ');
78 $this->assertEquals($expected, $html);
79 }
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392

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

+ Here is the call graph for this function:

◆ testRenderDisabled()

TagInputTest::testRenderDisabled ( )

Definition at line 156 of file TagInputTest.php.

156 : void
157 {
158 $f = $this->buildFactory();
159 $label = "label";
160 $tags = ["lorem", "ipsum", "dolor",];
161 $text = $f->tag($label, $tags)->withNameFrom($this->name_source)->withDisabled(true);
162
163 $r = $this->getDefaultRenderer();
164 $html = $this->brutallyTrimHTML($r->render($text));
165
166 $expected = $this->brutallyTrimHTML('
167 <div class="form-group row">
168 <label for="id_1" class="control-label col-sm-3">label</label>
169 <div class="col-sm-9">
170 <div id="container-id_1" class="form-control form-control-sm il-input-tag-container disabled">
171 <input id="id_1" name="name_0" class="form-control form-control-sm il-input-tag" readonly value=""/>
172 </div>
173 </div>
174 </div>
175 ');
176
177 $this->assertEquals($expected, $html);
178 }

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 81 of file TagInputTest.php.

81 : void
82 {
83 $f = $this->buildFactory();
84 $label = "label";
85 $byline = "byline";
86 $name = "name_0";
87 $tags = ["lorem", "ipsum", "dolor",];
88 $error = "an_error";
89 $text = $f->tag($label, $tags, $byline)->withNameFrom($this->name_source)->withError($error);
90
91 $r = $this->getDefaultRenderer();
92 $html = $this->brutallyTrimHTML($r->render($text));
93 $expected = $this->brutallyTrimHTML('
94 <div class="form-group row">
95 <label for="id_1" class="control-label col-sm-3">label</label>
96 <div class="col-sm-9">
97 <div class="help-block alert alert-danger" role="alert">an_error</div>
98 <div id="container-id_1" class="form-control form-control-sm il-input-tag-container">
99 <input id="id_1" name="name_0" class="form-control form-control-sm il-input-tag" value=""/>
100 </div>
101 <div class="help-block">byline</div>
102 </div>
103 </div>
104 ');
105 $this->assertEquals($expected, $html);
106 }

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

+ Here is the call graph for this function:

◆ testRenderNoByline()

TagInputTest::testRenderNoByline ( )

Definition at line 108 of file TagInputTest.php.

108 : void
109 {
110 $f = $this->buildFactory();
111 $label = "label";
112 $name = "name_0";
113 $tags = ["lorem", "ipsum", "dolor",];
114 $text = $f->tag($label, $tags)->withNameFrom($this->name_source);
115
116 $r = $this->getDefaultRenderer();
117 $html = $this->brutallyTrimHTML($r->render($text));
118 $expected = $this->brutallyTrimHTML('
119 <div class="form-group row">
120 <label for="id_1" class="control-label col-sm-3">label</label>
121 <div class="col-sm-9">
122 <div id="container-id_1" class="form-control form-control-sm il-input-tag-container">
123 <input id="id_1" name="name_0" class="form-control form-control-sm il-input-tag" value=""/>
124 </div>
125 </div>
126 </div>
127 ');
128 $this->assertEquals($expected, $html);
129 }

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

+ Here is the call graph for this function:

◆ testRenderRequired()

TagInputTest::testRenderRequired ( )

Definition at line 131 of file TagInputTest.php.

131 : void
132 {
133 $f = $this->buildFactory();
134 $label = "label";
135 $name = "name_0";
136 $tags = ["lorem", "ipsum", "dolor",];
137 $text = $f->tag($label, $tags)->withNameFrom($this->name_source)->withRequired(true);
138
139 $r = $this->getDefaultRenderer();
140 $html = $this->brutallyTrimHTML($r->render($text));
141
142 $expected = $this->brutallyTrimHTML('
143 <div class="form-group row">
144 <label for="id_1" class="control-label col-sm-3">label<span class="asterisk">*</span></label>
145 <div class="col-sm-9">
146 <div id="container-id_1" class="form-control form-control-sm il-input-tag-container">
147 <input id="id_1" name="name_0" class="form-control form-control-sm il-input-tag" value=""/>
148 </div>
149 </div>
150 </div>
151 ');
152
153 $this->assertEquals($expected, $html);
154 }

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

+ Here is the call graph for this function:

◆ testUserCreatedNotAllowed()

TagInputTest::testUserCreatedNotAllowed ( )

Definition at line 246 of file TagInputTest.php.

246 : void
247 {
248 $this->markTestSkipped("This is supposed to work, but currently does not.");
249
250 $f = $this->buildFactory();
251 $tags = ["lorem", "ipsum", "dolor",];
252 $tag = $f->tag("label", $tags)->withUserCreatedTagsAllowed(false)->withNameFrom($this->name_source);
253
254 $tag1 = $tag->withInput(
255 new DefInputData(
256 ["name_0" => "lorem,ipsum"]
257 )
258 );
259 $value1 = $tag1->getContent();
260 $this->assertTrue($value1->isOk());
261 $value = $value1->value();
262 $this->assertEquals(
263 ["lorem", "ipsum"],
264 $value
265 );
266
267 $tag1 = $tag->withInput(
268 new DefInputData(
269 ["name_0" => "conseptetuer,ipsum"]
270 )
271 );
272 $value1 = $tag1->getContent();
273 $this->assertTrue($value1->isError());
274 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $name_source

TagInputTest::$name_source
private

Definition at line 23 of file TagInputTest.php.


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