ILIAS  trunk Revision v11.0_alpha-1702-gfd3ecb7f852
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
FieldFactoryTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 require_once 'components/ILIAS/UI/tests/AbstractFactoryTestCase.php';
22 
26 use ILIAS\Data;
28 
30 {
31  public static array $kitchensink_info_settings = [
32  "text" => [
33  "context" => false,
34  ],
35  "numeric" => [
36  "context" => false,
37  ],
38  "group" => [
39  "context" => false,
40  ],
41  "section" => [
42  "context" => false,
43  ],
44  "optionalGroup" => [
45  "context" => false,
46  ],
47  "switchableGroup" => [
48  "context" => false,
49  ],
50  "checkbox" => [
51  "context" => false,
52  ],
53  "select" => [
54  "context" => false,
55  ],
56  "textarea" => [
57  "context" => false,
58  ],
59  "radio" => [
60  "context" => false,
61  ],
62  "multiSelect" => [
63  "context" => false,
64  ]
65  ];
66 
67  public static string $factory_title = 'ILIAS\\UI\\Component\\Input\\Field\\Factory';
68 
69 
70  final public function buildFactory(): I\Input\Field\Factory
71  {
72  $df = new Data\Factory();
73  $language = $this->createMock(ILIAS\Language\Language::class);
74  return new I\Input\Field\Factory(
75  $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
76  new SignalGenerator(),
77  $df,
78  new Refinery($df, $language),
79  $language
80  );
81  }
82 
83  public function testImplementsFactoryInterfaceForText(): void
84  {
85  $f = $this->buildFactory();
86 
87  $input = $f->text("label", "byline");
88  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
89  $this->assertInstanceOf(Field\Text::class, $input);
90  }
91 
93  {
94  $f = $this->buildFactory();
95 
96  $input = $f->numeric("label", "byline");
97  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
98  $this->assertInstanceOf(Field\Numeric::class, $input);
99  }
100 
102  {
103  $f = $this->buildFactory();
104 
105  $input = $f->section([], "label", "byline");
106  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
107  $this->assertInstanceOf(Field\Group::class, $input);
108  $this->assertInstanceOf(Field\Section::class, $input);
109  }
110 
112  {
113  $f = $this->buildFactory();
114 
115  $input = $f->group([]);
116  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
117  $this->assertInstanceOf(Field\Group::class, $input);
118  }
119 
121  {
122  $f = $this->buildFactory();
123 
124  $input = $f->checkbox("label", "byline");
125  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
126  $this->assertInstanceOf(Field\Checkbox::class, $input);
127  }
128 
129  public function testImplementsFactoryInterfaceForTag(): void
130  {
131  $f = $this->buildFactory();
132 
133  $input = $f->tag("label", [], "byline");
134  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
135  $this->assertInstanceOf(Field\Tag::class, $input);
136  }
137 
139  {
140  $f = $this->buildFactory();
141 
142  $input = $f->password("label", "byline");
143  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
144  $this->assertInstanceOf(Field\Password::class, $input);
145  }
146 
148  {
149  $f = $this->buildFactory();
150 
151  $input = $f->select("label", [], "byline");
152  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
153  $this->assertInstanceOf(Field\Select::class, $input);
154  }
155 
157  {
158  $f = $this->buildFactory();
159 
160  $input = $f->textarea("label", "byline");
161  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
162  $this->assertInstanceOf(Field\Textarea::class, $input);
163  }
164 
166  {
167  $f = $this->buildFactory();
168 
169  $input = $f->radio("label", "byline");
170  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
171  $this->assertInstanceOf(Field\Radio::class, $input);
172  }
173 
175  {
176  $f = $this->buildFactory();
177 
178  $input = $f->multiSelect("label", [], "byline");
179  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
180  $this->assertInstanceOf(Field\MultiSelect::class, $input);
181  }
182 
184  {
185  $f = $this->buildFactory();
186 
187  $input = $f->datetime("label", "byline");
188  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
189  }
190 
192  {
193  $f = $this->buildFactory();
194 
195  $input = $f->duration("label", "byline");
196  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
197  $this->assertInstanceOf(Field\Group::class, $input);
198  }
199 
200  public function testImplementsFactoryNoByLine(): void
201  {
202  $f = $this->buildFactory();
203 
204  $input = $f->text("label");
205  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
206  $this->assertInstanceOf(Field\Text::class, $input);
207 
208  $input = $f->numeric("label");
209  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
210  $this->assertInstanceOf(Field\Numeric::class, $input);
211 
212  $input = $f->section([], "label");
213  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
214  $this->assertInstanceOf(Field\Group::class, $input);
215  $this->assertInstanceOf(Field\Section::class, $input);
216 
217  $input = $f->checkbox("label");
218  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
219  $this->assertInstanceOf(Field\Checkbox::class, $input);
220 
221  $input = $f->tag("label", []);
222  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
223  $this->assertInstanceOf(Field\Tag::class, $input);
224 
225  $input = $f->password("label");
226  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
227  $this->assertInstanceOf(Field\Password::class, $input);
228 
229  $input = $f->select("label", []);
230  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
231  $this->assertInstanceOf(Field\Select::class, $input);
232 
233  $input = $f->textarea("label");
234  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
235  $this->assertInstanceOf(Field\Textarea::class, $input);
236 
237  $input = $f->radio("label");
238  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
239  $this->assertInstanceOf(Field\Radio::class, $input);
240 
241  $input = $f->multiSelect("label", []);
242  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
243  $this->assertInstanceOf(Field\MultiSelect::class, $input);
244  }
245 }
testImplementsFactoryInterfaceForPassword()
static string $factory_title
Interface Observer Contains several chained tasks and infos about them.
testImplementsFactoryInterfaceForNumeric()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Checkbox.php:21
testImplementsFactoryInterfaceForMultiselect()
testImplementsFactoryInterfaceForDuration()
Builds data types.
Definition: Factory.php:35
testImplementsFactoryInterfaceForDatetime()
testImplementsFactoryInterfaceForTextarea()
testImplementsFactoryInterfaceForSection()
testImplementsFactoryInterfaceForCheckbox()
Defines tests every SHOULD pass UI-factory.
static array $kitchensink_info_settings