ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
TagInputTest Class Reference

Class TagInputTest. More...

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

Public Member Functions

 setUp ()
 
 testImplementsFactoryInterface ()
 
 testRender ()
 
 testCommonRendering ()
 
 testNullValueLeadsToException ()
 
 testUserCreatedNotAllowed ()
 
 testMaxTagsOk ()
 
 testMaxTagsNotOk ()
 
 testMaxTaglengthTagsOk ()
 
 testMaxTaglengthTagsNotOk ()
 

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

Member Function Documentation

◆ setUp()

TagInputTest::setUp ( )

Definition at line 42 of file TagInputTest.php.

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

◆ testCommonRendering()

TagInputTest::testCommonRendering ( )

Definition at line 83 of file TagInputTest.php.

References Vendor\Package\$e, and Vendor\Package\$f.

83  : void
84  {
85  $f = $this->getFieldFactory();
86  $tag = $f->tag('label', [], null)->withNameFrom($this->name_source);
87 
88  $this->testWithError($tag);
89  $this->testWithNoByline($tag);
90  $this->testWithRequired($tag);
91  $this->testWithDisabled($tag);
92  $this->testWithAdditionalOnloadCodeRendersId($tag);
93  }

◆ testImplementsFactoryInterface()

TagInputTest::testImplementsFactoryInterface ( )

Definition at line 50 of file TagInputTest.php.

References Vendor\Package\$f.

50  : void
51  {
52  $f = $this->getFieldFactory();
53 
54  $f->tag(
55  "label",
56  ["lorem", "ipsum", "dolor"],
57  "byline"
58  );
59  }

◆ testMaxTaglengthTagsNotOk()

TagInputTest::testMaxTaglengthTagsNotOk ( )

Definition at line 225 of file TagInputTest.php.

References Vendor\Package\$f.

225  : void
226  {
227  $f = $this->getFieldFactory();
228 
229  $this->expectException(InvalidArgumentException::class);
230  $f->tag("label", [])->withTagMaxLength(2)->withNameFrom($this->name_source)->withInput(
231  new DefInputData(
232  ["name_0" => "lorem,ipsum,dolor"]
233  )
234  );
235  }

◆ testMaxTaglengthTagsOk()

TagInputTest::testMaxTaglengthTagsOk ( )

Definition at line 214 of file TagInputTest.php.

References Vendor\Package\$f.

214  : void
215  {
216  $f = $this->getFieldFactory();
217 
218  $tag = $f->tag("label", [])->withTagMaxLength(10)->withNameFrom($this->name_source)->withInput(
219  new DefInputData(["name_0" => "lorem,ipsum"])
220  );
221  $value = $tag->getContent();
222  $this->assertTrue($value->isOk());
223  }

◆ testMaxTagsNotOk()

TagInputTest::testMaxTagsNotOk ( )

Definition at line 202 of file TagInputTest.php.

References Vendor\Package\$f.

202  : void
203  {
204  $f = $this->getFieldFactory();
205 
206  $this->expectException(InvalidArgumentException::class);
207  $f->tag("label", [])->withMaxTags(2)->withNameFrom($this->name_source)->withInput(
208  new DefInputData(
209  ["name_0" => "lorem,ipsum,dolor"]
210  )
211  );
212  }

◆ testMaxTagsOk()

TagInputTest::testMaxTagsOk ( )

Definition at line 191 of file TagInputTest.php.

References Vendor\Package\$f.

191  : void
192  {
193  $f = $this->getFieldFactory();
194 
195  $tag = $f->tag("label", [])->withMaxTags(3)->withNameFrom($this->name_source)->withInput(
196  new DefInputData(["name_0" => "lorem,ipsum"])
197  );
198  $value = $tag->getContent();
199  $this->assertTrue($value->isOk());
200  }

◆ testNullValueLeadsToException()

TagInputTest::testNullValueLeadsToException ( )

Definition at line 148 of file TagInputTest.php.

References Vendor\Package\$f.

148  : void
149  {
150  $f = $this->getFieldFactory();
151  $label = "label";
152  $name = "name_0";
153  $tags = ["lorem", "ipsum", "dolor",];
154 
155  $tag = $f->tag($label, $tags)->withNameFrom($this->name_source)->withRequired(true);
156  $tag2 = $tag->withInput(new DefInputData([$name => null]));
157  $value2 = $tag2->getContent();
158  $this->assertTrue($value2->isError());
159  }

◆ testRender()

TagInputTest::testRender ( )

Definition at line 61 of file TagInputTest.php.

References Vendor\Package\$f.

61  : void
62  {
63  $f = $this->getFieldFactory();
64  $label = "label";
65  $byline = "byline";
66  $tags = ["lorem", "ipsum", "dolor",];
67  $tag = $f->tag($label, $tags, $byline)->withNameFrom($this->name_source);
68  $expected = $this->getFormWrappedHtml(
69  'tag-field-input',
70  $label,
71  '
72  <div class="c-field-tag__wrapper">
73  <input id="id_1" name="name_0" class="c-field-tag" value=""/>
74  </div>
75  ',
76  $byline,
77  'id_1',
78  'id_2'
79  );
80  $this->assertEquals($expected, $this->render($tag));
81  }

◆ testUserCreatedNotAllowed()

TagInputTest::testUserCreatedNotAllowed ( )

Definition at line 161 of file TagInputTest.php.

References Vendor\Package\$f.

161  : void
162  {
163  $this->markTestSkipped("This is supposed to work, but currently does not.");
164 
165  $f = $this->getFieldFactory();
166  $tags = ["lorem", "ipsum", "dolor",];
167  $tag = $f->tag("label", $tags)->withUserCreatedTagsAllowed(false)->withNameFrom($this->name_source);
168 
169  $tag1 = $tag->withInput(
170  new DefInputData(
171  ["name_0" => "lorem,ipsum"]
172  )
173  );
174  $value1 = $tag1->getContent();
175  $this->assertTrue($value1->isOk());
176  $value = $value1->value();
177  $this->assertEquals(
178  ["lorem", "ipsum"],
179  $value
180  );
181 
182  $tag1 = $tag->withInput(
183  new DefInputData(
184  ["name_0" => "conseptetuer,ipsum"]
185  )
186  );
187  $value1 = $tag1->getContent();
188  $this->assertTrue($value1->isError());
189  }

Field Documentation

◆ $name_source

DefNamesource TagInputTest::$name_source
protected

Definition at line 40 of file TagInputTest.php.


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