ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
TagInputTest Class Reference

Class TagInputTest. More...

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

Public Member Functions

 setUp ()
 
 test_implements_factory_interface ()
 
 test_render ()
 
 test_render_error ()
 
 test_render_no_byline ()
 
 test_render_value ()
 
 test_render_required ()
 
 test_render_disabled ()
 
 test_null_value_leads_to_exception ()
 
 test_user_created_not_allowed ()
 
 test_max_tags_ok ()
 
 test_max_tags_not_ok ()
 
 test_max_taglength_tags_ok ()
 
 test_max_taglength_tags_not_ok ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
 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 33 of file TagInputTest.php.

Referenced by test_implements_factory_interface(), test_max_taglength_tags_not_ok(), test_max_taglength_tags_ok(), test_max_tags_not_ok(), test_max_tags_ok(), test_null_value_leads_to_exception(), test_render(), test_render_disabled(), test_render_error(), test_render_no_byline(), test_render_required(), test_render_value(), and test_user_created_not_allowed().

34  {
35  $df = new Data\Factory();
36  $language = $this->createMock(\ilLanguage::class);
38  new SignalGenerator(),
39  $df,
40  new \ILIAS\Refinery\Factory($df, $language),
41  $language
42  );
43  }
Class ChatMainBarProvider .
Builds data types.
Definition: Factory.php:19
+ Here is the caller graph for this function:

◆ setUp()

TagInputTest::setUp ( )

Definition at line 27 of file TagInputTest.php.

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

◆ test_implements_factory_interface()

TagInputTest::test_implements_factory_interface ( )

Definition at line 48 of file TagInputTest.php.

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

49  {
50  $f = $this->buildFactory();
51 
52  $tag = $f->tag(
53  "label",
54  ["lorem", "ipsum", "dolor",],
55  "byline"
56  );
57  }
+ Here is the call graph for this function:

◆ test_max_taglength_tags_not_ok()

TagInputTest::test_max_taglength_tags_not_ok ( )

Definition at line 277 of file TagInputTest.php.

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

278  {
279  $f = $this->buildFactory();
280 
281  $this->expectException(\InvalidArgumentException::class);
282  $f->tag("label", [])->withTagMaxLength(2)->withNameFrom($this->name_source)->withInput(
283  new DefInputData(
284  ["name_0" => ["lorem", "ipsum", "dolor",],]
285  )
286  );
287  }
+ Here is the call graph for this function:

◆ test_max_taglength_tags_ok()

TagInputTest::test_max_taglength_tags_ok ( )

Definition at line 265 of file TagInputTest.php.

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

266  {
267  $f = $this->buildFactory();
268 
269  $tag = $f->tag("label", [])->withTagMaxLength(10)->withNameFrom($this->name_source)->withInput(
270  new DefInputData(["name_0" => ["lorem", "ipsum",],])
271  );
272  $value = $tag->getContent();
273  $this->assertTrue($value->isOk());
274  }
+ Here is the call graph for this function:

◆ test_max_tags_not_ok()

TagInputTest::test_max_tags_not_ok ( )

Definition at line 252 of file TagInputTest.php.

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

253  {
254  $f = $this->buildFactory();
255 
256  $this->expectException(\InvalidArgumentException::class);
257  $f->tag("label", [])->withMaxTags(2)->withNameFrom($this->name_source)->withInput(
258  new DefInputData(
259  ["name_0" => ["lorem", "ipsum", "dolor",],]
260  )
261  );
262  }
+ Here is the call graph for this function:

◆ test_max_tags_ok()

TagInputTest::test_max_tags_ok ( )

Definition at line 240 of file TagInputTest.php.

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

241  {
242  $f = $this->buildFactory();
243 
244  $tag = $f->tag("label", [])->withMaxTags(3)->withNameFrom($this->name_source)->withInput(
245  new DefInputData(["name_0" => ["lorem", "ipsum",],])
246  );
247  $value = $tag->getContent();
248  $this->assertTrue($value->isOk());
249  }
+ Here is the call graph for this function:

◆ test_null_value_leads_to_exception()

TagInputTest::test_null_value_leads_to_exception ( )

Definition at line 197 of file TagInputTest.php.

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

198  {
199  $f = $this->buildFactory();
200  $label = "label";
201  $name = "name_0";
202  $tags = ["lorem", "ipsum", "dolor",];
203 
204  $tag = $f->tag($label, $tags)->withNameFrom($this->name_source)->withRequired(true);
205  $tag2 = $tag->withInput(new DefInputData([$name => null]));
206  $value2 = $tag2->getContent();
207  $this->assertTrue($value2->isError());
208  }
if($format !==null) $name
Definition: metadata.php:230
+ Here is the call graph for this function:

◆ test_render()

TagInputTest::test_render ( )

Definition at line 62 of file TagInputTest.php.

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

63  {
64  $f = $this->buildFactory();
65  $label = "label";
66  $byline = "byline";
67  $tags = ["lorem", "ipsum", "dolor",];
68  $name = "name_0";
69  $text = $f->tag($label, $tags, $byline)->withNameFrom($this->name_source);
70 
71  $r = $this->getDefaultRenderer();
72  $html = $this->normalizeHTML($r->render($text));
73 
74  $expected = "<div class=\"form-group row\"> <label for=\"name_0\" class=\"control-label col-sm-3\">label</label> <div class=\"col-sm-9\"> <div id=\"container-id_1\" class=\"form-control form-control-sm il-input-tag\"> <input type=\"text\" id=\"id_1\" value=\"\" class=\"form-control form-control-sm\"/> <input type=\"hidden\" id=\"template-id_1\" value='name_0[]'> </div> <div class=\"help-block\">byline</div> </div></div>";
75  $this->assertEquals($expected, $html);
76  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
if($format !==null) $name
Definition: metadata.php:230
+ Here is the call graph for this function:

◆ test_render_disabled()

TagInputTest::test_render_disabled ( )

Definition at line 149 of file TagInputTest.php.

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

150  {
151  $f = $this->buildFactory();
152  $label = "label";
153  $tags = ["lorem", "ipsum", "dolor",];
154  $text = $f->tag($label, $tags)->withNameFrom($this->name_source)->withDisabled(true);
155 
156  $r = $this->getDefaultRenderer();
157  $html = $this->normalizeHTML($r->render($text));
158 
159  $expected = "<div class=\"form-group row\"> <label for=\"name_0\" class=\"control-label col-sm-3\">label</label> <div class=\"col-sm-9\"> <div id=\"container-id_1\" class=\"form-control form-control-sm il-input-tag disabled\"> <input type=\"text\" id=\"id_1\" value=\"\" class=\"form-control form-control-sm\"/> <input type=\"hidden\" id=\"template-id_1\" value='name_0[]'> </div> </div></div>";
160 
161  $this->assertEquals($expected, $html);
162  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
+ Here is the call graph for this function:

◆ test_render_error()

TagInputTest::test_render_error ( )

Definition at line 79 of file TagInputTest.php.

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

80  {
81  $f = $this->buildFactory();
82  $label = "label";
83  $byline = "byline";
84  $name = "name_0";
85  $tags = ["lorem", "ipsum", "dolor",];
86  $error = "an_error";
87  $text = $f->tag($label, $tags, $byline)->withNameFrom($this->name_source)->withError($error);
88 
89  $r = $this->getDefaultRenderer();
90  $html = $this->normalizeHTML($r->render($text));
91 
92  $expected
93  = "<div class=\"form-group row\"> <label for=\"name_0\" class=\"control-label col-sm-3\">label</label> <div class=\"col-sm-9\"> <div id=\"container-id_1\" class=\"form-control form-control-sm il-input-tag\"> <input type=\"text\" id=\"id_1\" value=\"\" class=\"form-control form-control-sm\"/> <input type=\"hidden\" id=\"template-id_1\" value='name_0[]'> </div> <div class=\"help-block\">byline</div> <div class=\"help-block alert alert-danger\" role=\"alert\"> <img border=\"0\" src=\"./templates/default/images/icon_alert.svg\" alt=\"alert\" /> an_error </div> </div></div>";
94  $this->assertEquals($expected, $html);
95  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
if($format !==null) $name
Definition: metadata.php:230
+ Here is the call graph for this function:

◆ test_render_no_byline()

TagInputTest::test_render_no_byline ( )

Definition at line 98 of file TagInputTest.php.

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

99  {
100  $f = $this->buildFactory();
101  $label = "label";
102  $name = "name_0";
103  $tags = ["lorem", "ipsum", "dolor",];
104  $text = $f->tag($label, $tags)->withNameFrom($this->name_source);
105 
106  $r = $this->getDefaultRenderer();
107  $html = $this->normalizeHTML($r->render($text));
108 
109  $expected = "<div class=\"form-group row\"> <label for=\"name_0\" class=\"control-label col-sm-3\">label</label> <div class=\"col-sm-9\"> <div id=\"container-id_1\" class=\"form-control form-control-sm il-input-tag\"> <input type=\"text\" id=\"id_1\" value=\"\" class=\"form-control form-control-sm\"/> <input type=\"hidden\" id=\"template-id_1\" value='name_0[]'> </div> </div></div>";
110  $this->assertEquals($expected, $html);
111  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
if($format !==null) $name
Definition: metadata.php:230
+ Here is the call graph for this function:

◆ test_render_required()

TagInputTest::test_render_required ( )

Definition at line 132 of file TagInputTest.php.

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

133  {
134  $f = $this->buildFactory();
135  $label = "label";
136  $name = "name_0";
137  $tags = ["lorem", "ipsum", "dolor",];
138  $text = $f->tag($label, $tags)->withNameFrom($this->name_source)->withRequired(true);
139 
140  $r = $this->getDefaultRenderer();
141  $html = $this->normalizeHTML($r->render($text));
142 
143  $expected = "<div class=\"form-group row\"> <label for=\"name_0\" class=\"control-label col-sm-3\">label<span class=\"asterisk\">*</span></label> <div class=\"col-sm-9\"> <div id=\"container-id_1\" class=\"form-control form-control-sm il-input-tag\"> <input type=\"text\" id=\"id_1\" value=\"\" class=\"form-control form-control-sm\"/> <input type=\"hidden\" id=\"template-id_1\" value='name_0[]'> </div> </div></div>";
144 
145  $this->assertEquals($expected, $html);
146  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
if($format !==null) $name
Definition: metadata.php:230
+ Here is the call graph for this function:

◆ test_render_value()

TagInputTest::test_render_value ( )

Definition at line 114 of file TagInputTest.php.

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

115  {
116  $f = $this->buildFactory();
117  $label = "label";
118  $value = ["lorem", "ipsum",];
119  $name = "name_0";
120  $tags = ["lorem", "ipsum", "dolor",];
121  $text = $f->tag($label, $tags)->withValue($value)->withNameFrom($this->name_source);
122 
123  $r = $this->getDefaultRenderer();
124  $html = $this->normalizeHTML($r->render($text));
125 
126  $expected
127  = "<div class=\"form-group row\"> <label for=\"name_0\" class=\"control-label col-sm-3\">label</label> <div class=\"col-sm-9\"> <div id=\"container-id_1\" class=\"form-control form-control-sm il-input-tag\"> <input type=\"text\" id=\"id_1\" value=\"lorem,ipsum\" class=\"form-control form-control-sm\"/> <input type=\"hidden\" id=\"template-id_1\" value='name_0[]'> <input type=\"hidden\" id=\"tag-id_1-lorem\" name=\"name_0[]\" value='lorem'> <input type=\"hidden\" id=\"tag-id_1-ipsum\" name=\"name_0[]\" value='ipsum'> </div> </div></div>";
128  $this->assertEquals($expected, $html);
129  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
normalizeHTML($html)
Definition: Base.php:317
if($format !==null) $name
Definition: metadata.php:230
+ Here is the call graph for this function:

◆ test_user_created_not_allowed()

TagInputTest::test_user_created_not_allowed ( )

Definition at line 211 of file TagInputTest.php.

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

212  {
213  $f = $this->buildFactory();
214  $tags = ["lorem", "ipsum", "dolor",];
215  $tag = $f->tag("label", $tags)->withUserCreatedTagsAllowed(false)->withNameFrom($this->name_source);
216 
217  $tag1 = $tag->withInput(
218  new DefInputData(
219  ["name_0" => ["lorem", "ipsum",],]
220  )
221  );
222  $value1 = $tag1->getContent();
223  $this->assertTrue($value1->isOk());
224  $value = $value1->value();
225  $this->assertEquals(
226  ["lorem", "ipsum",],
227  $value
228  );
229 
230  $tag1 = $tag->withInput(
231  new DefInputData(
232  ["name_0" => ["conseptetuer", "ipsum",],]
233  )
234  );
235  $value1 = $tag1->getContent();
236  $this->assertTrue($value1->isError());
237  }
+ Here is the call graph for this function:

Field Documentation

◆ $name_source

TagInputTest::$name_source
private

Definition at line 24 of file TagInputTest.php.


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