ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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\Field\Node\Factory::class),
76  $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
77  new SignalGenerator(),
78  $df,
79  new Refinery($df, $language),
80  $language
81  );
82  }
83 
84  public function testImplementsFactoryInterfaceForText(): void
85  {
86  $f = $this->buildFactory();
87 
88  $input = $f->text("label", "byline");
89  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
90  $this->assertInstanceOf(Field\Text::class, $input);
91  }
92 
94  {
95  $f = $this->buildFactory();
96 
97  $input = $f->numeric("label", "byline");
98  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
99  $this->assertInstanceOf(Field\Numeric::class, $input);
100  }
101 
103  {
104  $f = $this->buildFactory();
105 
106  $input = $f->section([], "label", "byline");
107  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
108  $this->assertInstanceOf(Field\Group::class, $input);
109  $this->assertInstanceOf(Field\Section::class, $input);
110  }
111 
113  {
114  $f = $this->buildFactory();
115 
116  $input = $f->group([]);
117  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
118  $this->assertInstanceOf(Field\Group::class, $input);
119  }
120 
122  {
123  $f = $this->buildFactory();
124 
125  $input = $f->checkbox("label", "byline");
126  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
127  $this->assertInstanceOf(Field\Checkbox::class, $input);
128  }
129 
130  public function testImplementsFactoryInterfaceForTag(): void
131  {
132  $f = $this->buildFactory();
133 
134  $input = $f->tag("label", [], "byline");
135  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
136  $this->assertInstanceOf(Field\Tag::class, $input);
137  }
138 
140  {
141  $f = $this->buildFactory();
142 
143  $input = $f->password("label", "byline");
144  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
145  $this->assertInstanceOf(Field\Password::class, $input);
146  }
147 
149  {
150  $f = $this->buildFactory();
151 
152  $input = $f->select("label", [], "byline");
153  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
154  $this->assertInstanceOf(Field\Select::class, $input);
155  }
156 
158  {
159  $f = $this->buildFactory();
160 
161  $input = $f->textarea("label", "byline");
162  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
163  $this->assertInstanceOf(Field\Textarea::class, $input);
164  }
165 
167  {
168  $f = $this->buildFactory();
169 
170  $input = $f->radio("label", "byline");
171  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
172  $this->assertInstanceOf(Field\Radio::class, $input);
173  }
174 
176  {
177  $f = $this->buildFactory();
178 
179  $input = $f->multiSelect("label", [], "byline");
180  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
181  $this->assertInstanceOf(Field\MultiSelect::class, $input);
182  }
183 
185  {
186  $f = $this->buildFactory();
187 
188  $input = $f->datetime("label", "byline");
189  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
190  }
191 
193  {
194  $f = $this->buildFactory();
195 
196  $input = $f->duration("label", "byline");
197  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
198  $this->assertInstanceOf(Field\Group::class, $input);
199  }
200 
201  public function testImplementsFactoryNoByLine(): void
202  {
203  $f = $this->buildFactory();
204 
205  $input = $f->text("label");
206  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
207  $this->assertInstanceOf(Field\Text::class, $input);
208 
209  $input = $f->numeric("label");
210  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
211  $this->assertInstanceOf(Field\Numeric::class, $input);
212 
213  $input = $f->section([], "label");
214  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
215  $this->assertInstanceOf(Field\Group::class, $input);
216  $this->assertInstanceOf(Field\Section::class, $input);
217 
218  $input = $f->checkbox("label");
219  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
220  $this->assertInstanceOf(Field\Checkbox::class, $input);
221 
222  $input = $f->tag("label", []);
223  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
224  $this->assertInstanceOf(Field\Tag::class, $input);
225 
226  $input = $f->password("label");
227  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
228  $this->assertInstanceOf(Field\Password::class, $input);
229 
230  $input = $f->select("label", []);
231  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
232  $this->assertInstanceOf(Field\Select::class, $input);
233 
234  $input = $f->textarea("label");
235  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
236  $this->assertInstanceOf(Field\Textarea::class, $input);
237 
238  $input = $f->radio("label");
239  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
240  $this->assertInstanceOf(Field\Radio::class, $input);
241 
242  $input = $f->multiSelect("label", []);
243  $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $input);
244  $this->assertInstanceOf(Field\MultiSelect::class, $input);
245  }
246 }
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