ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
FileInputTest Class Reference
+ Inheritance diagram for FileInputTest:
+ Collaboration diagram for FileInputTest:

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 ()
 
 getUIFactory ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
- 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 ()
 
 buildButtonFactory ()
 
- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 

Private Member Functions

 getUploadHandler ()
 

Detailed Description

Definition at line 37 of file FileInputTest.php.

Member Function Documentation

◆ buildButtonFactory()

FileInputTest::buildButtonFactory ( )
protected

Definition at line 215 of file FileInputTest.php.

Referenced by getUIFactory().

+ Here is the caller graph for this function:

◆ buildFactory()

FileInputTest::buildFactory ( )
protected

Definition at line 45 of file FileInputTest.php.

46 {
47 $df = new Data\Factory();
48 $language = $this->createMock(\ilLanguage::class);
49
51 new SignalGenerator(),
52 $df,
53 new ILIAS\Refinery\Factory($df, $language),
54 $language
55 );
56 }
Builds data types.
Definition: Factory.php:20
Class ChatMainBarProvider \MainMenu\Provider.

Referenced by test_implements_factory_interface(), test_render(), test_render_disabled(), test_render_error(), test_render_no_byline(), test_render_required(), and test_render_value().

+ Here is the caller graph for this function:

◆ getDefaultRenderer()

FileInputTest::getDefaultRenderer ( JavaScriptBinding  $js_binding = null)

Reimplemented from ILIAS_UI_TestBase.

Definition at line 227 of file FileInputTest.php.

228 {
229 $ui_factory = $this->getUIFactory();
230 $tpl_factory = $this->getTemplateFactory();
231 $resource_registry = $this->getResourceRegistry();
232 $lng = $this->getLanguage();
233 if (!$js_binding) {
234 $js_binding = $this->getJavaScriptBinding();
235 }
236
237 $refinery = $this->getRefinery();
238
239 $component_renderer_loader
242 $resource_registry,
243 new FSLoader(
245 $ui_factory,
246 $tpl_factory,
247 $lng,
248 $js_binding,
249 $refinery
250 ),
252 $ui_factory,
253 $tpl_factory,
254 $lng,
255 $js_binding,
256 $refinery
257 ),
259 $ui_factory,
260 $tpl_factory,
261 $lng,
262 $js_binding,
263 $refinery
264 )
265 )
266 )
267 );
268
269 return new TestDefaultRenderer($component_renderer_loader);
270 }
Loads renderers for components from the file system.
Definition: FSLoader.php:21
Caches renderers loaded by another loader.
Registers resources for retreived renderers at a ResourceRegistry.
getJavaScriptBinding()
Definition: Base.php:256
getTemplateFactory()
Definition: Base.php:241
getResourceRegistry()
Definition: Base.php:246
$lng

References $lng, ILIAS_UI_TestBase\getJavaScriptBinding(), ILIAS_UI_TestBase\getLanguage(), ILIAS_UI_TestBase\getRefinery(), ILIAS_UI_TestBase\getResourceRegistry(), ILIAS_UI_TestBase\getTemplateFactory(), and getUIFactory().

Referenced by test_render(), test_render_disabled(), test_render_error(), test_render_no_byline(), test_render_required(), and test_render_value().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUIFactory()

FileInputTest::getUIFactory ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 221 of file FileInputTest.php.

References buildButtonFactory().

Referenced by getDefaultRenderer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUploadHandler()

FileInputTest::getUploadHandler ( )
private

@inheritDoc

@inheritDoc

Definition at line 59 of file FileInputTest.php.

59 : Field\UploadHandler
60 {
61 return new class implements Field\UploadHandler {
62 public function getFileIdentifierParameterName() : string
63 {
64 return 'file_id';
65 }
66
67
68 public function getUploadURL() : string
69 {
70 return 'uploadurl';
71 }
72
73
74 public function getFileRemovalURL() : string
75 {
76 return 'removalurl';
77 }
78
79
83 public function getExistingFileInfoURL() : string
84 {
85 return 'infourl';
86 }
87
88
92 public function getInfoForExistingFiles(array $file_ids) : array
93 {
94 return [];
95 }
96 };
97 }

Referenced by test_implements_factory_interface(), test_render(), test_render_disabled(), test_render_error(), test_render_no_byline(), test_render_required(), and test_render_value().

+ Here is the caller graph for this function:

◆ setUp()

FileInputTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 39 of file FileInputTest.php.

39 : void
40 {
41 $this->name_source = new DefNamesource();
42 }

◆ test_implements_factory_interface()

FileInputTest::test_implements_factory_interface ( )

Definition at line 100 of file FileInputTest.php.

101 {
102 $f = $this->buildFactory();
103
104 $text = $f->file($this->getUploadHandler(), "label", "byline");
105
106 $this->assertInstanceOf(Field\Input::class, $text);
107 $this->assertInstanceOf(Field\File::class, $text);
108 }

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

+ Here is the call graph for this function:

◆ test_render()

FileInputTest::test_render ( )

Definition at line 111 of file FileInputTest.php.

112 {
113 $f = $this->buildFactory();
114 $label = "label";
115 $byline = "byline";
116 $name = "name_0";
117 $text = $f->file($this->getUploadHandler(), $label, $byline)->withNameFrom($this->name_source);
118
119 $r = $this->getDefaultRenderer();
120 $html = $this->normalizeHTML($r->render($text));
121
122 $expected
123 = '<div class="form-group row"> <label for="name_0" class="control-label col-sm-3">label</label> <div class="col-sm-9"> <div class="il-input-file" id="id_2"><div class="il-input-file-dropzone"> <button class="btn btn-link" data-action="#" id="id_1">select_files_from_computer</button></div><div class="il-input-file-filelist"> <div class="il-input-file-template dz-preview dz-file-preview" style="display: block; border: 1px solid red" data-file-id=""> <div class="dz-details"> <div class="il-input-file-fileinfo"> <div class="il-input-file-fileinfo-title"><span data-dz-name></span></div> <div data-dz-size class="il-input-file-fileinfo-size"></div> <div class="il-input-file-fileinfo-close"> <button type="button" class="close" data-dz-remove> <span aria-hidden="true">&times;</span> <span class="sr-only">Close</span> </button> </div> </div> <!-- <div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div>--> <!-- <div class="dz-success-mark"><span>✔</span></div>--> <!-- <div class="dz-error-mark"><span>✘</span></div>--> <div class="dz-error-message il-input-file-error"><span data-dz-errormessage></span></div> </div> </div></div><input class="input-template" type="hidden" name="name_0[]" value="" data-file-id=""></div> <div class="help-block">byline</div> </div></div>';
124 $this->assertEquals($expected, $html);
125 }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
normalizeHTML($html)
Definition: Base.php:317
if($format !==null) $name
Definition: metadata.php:230

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

+ Here is the call graph for this function:

◆ test_render_disabled()

FileInputTest::test_render_disabled ( )

Definition at line 195 of file FileInputTest.php.

196 {
197 $f = $this->buildFactory();
198 $label = "label";
199 $name = "name_0";
200 $text = $f->file($this->getUploadHandler(), $label)->withNameFrom($this->name_source)->withDisabled(true);
201
202 $r = $this->getDefaultRenderer();
203 $html = $this->normalizeHTML($r->render($text));
204
205 $expected
206 = '<div class="form-group row"> <label for="name_0" class="control-label col-sm-3">label</label> <div class="col-sm-9"> <div class="il-input-file" id="id_2"><div class="il-input-file-dropzone"> <button class="btn btn-link" data-action="#" id="id_1">select_files_from_computer</button></div><div class="il-input-file-filelist"> <div class="il-input-file-template dz-preview dz-file-preview" style="display: block; border: 1px solid red" data-file-id=""> <div class="dz-details"> <div class="il-input-file-fileinfo"> <div class="il-input-file-fileinfo-title"><span data-dz-name></span></div> <div data-dz-size class="il-input-file-fileinfo-size"></div> <div class="il-input-file-fileinfo-close"> <button type="button" class="close" data-dz-remove> <span aria-hidden="true">&times;</span> <span class="sr-only">Close</span> </button> </div> </div> <!-- <div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div>--> <!-- <div class="dz-success-mark"><span>✔</span></div>--> <!-- <div class="dz-error-mark"><span>✘</span></div>--> <div class="dz-error-message il-input-file-error"><span data-dz-errormessage></span></div> </div> </div></div><input class="input-template" type="hidden" name="name_0[]" value="" data-file-id=""></div> </div></div>';
207
208 $this->assertEquals($expected, $html);
209 }

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

+ Here is the call graph for this function:

◆ test_render_error()

FileInputTest::test_render_error ( )

Definition at line 128 of file FileInputTest.php.

129 {
130 $f = $this->buildFactory();
131 $label = "label";
132 $byline = "byline";
133 $name = "name_0";
134 $error = "an_error";
135 $text = $f->file($this->getUploadHandler(), $label, $byline)->withNameFrom($this->name_source)->withError($error);
136
137 $r = $this->getDefaultRenderer();
138 $html = $this->normalizeHTML($r->render($text));
139
140 $expected
141 = '<div class="form-group row"> <label for="name_0" class="control-label col-sm-3">label</label> <div class="col-sm-9"> <div class="il-input-file" id="id_2"><div class="il-input-file-dropzone"> <button class="btn btn-link" data-action="#" id="id_1">select_files_from_computer</button></div><div class="il-input-file-filelist"> <div class="il-input-file-template dz-preview dz-file-preview" style="display: block; border: 1px solid red" data-file-id=""> <div class="dz-details"> <div class="il-input-file-fileinfo"> <div class="il-input-file-fileinfo-title"><span data-dz-name></span></div> <div data-dz-size class="il-input-file-fileinfo-size"></div> <div class="il-input-file-fileinfo-close"> <button type="button" class="close" data-dz-remove> <span aria-hidden="true">&times;</span> <span class="sr-only">Close</span> </button> </div> </div> <!-- <div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div>--> <!-- <div class="dz-success-mark"><span>✔</span></div>--> <!-- <div class="dz-error-mark"><span>✘</span></div>--> <div class="dz-error-message il-input-file-error"><span data-dz-errormessage></span></div> </div> </div></div><input class="input-template" type="hidden" name="name_0[]" value="" data-file-id=""></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>';
142 $this->assertEquals($expected, $html);
143 }

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

+ Here is the call graph for this function:

◆ test_render_no_byline()

FileInputTest::test_render_no_byline ( )

Definition at line 146 of file FileInputTest.php.

147 {
148 $f = $this->buildFactory();
149 $label = "label";
150 $name = "name_0";
151 $text = $f->file($this->getUploadHandler(), $label)->withNameFrom($this->name_source);
152
153 $r = $this->getDefaultRenderer();
154 $html = $this->normalizeHTML($r->render($text));
155
156 $expected
157 = '<div class="form-group row"> <label for="name_0" class="control-label col-sm-3">label</label> <div class="col-sm-9"> <div class="il-input-file" id="id_2"><div class="il-input-file-dropzone"> <button class="btn btn-link" data-action="#" id="id_1">select_files_from_computer</button></div><div class="il-input-file-filelist"> <div class="il-input-file-template dz-preview dz-file-preview" style="display: block; border: 1px solid red" data-file-id=""> <div class="dz-details"> <div class="il-input-file-fileinfo"> <div class="il-input-file-fileinfo-title"><span data-dz-name></span></div> <div data-dz-size class="il-input-file-fileinfo-size"></div> <div class="il-input-file-fileinfo-close"> <button type="button" class="close" data-dz-remove> <span aria-hidden="true">&times;</span> <span class="sr-only">Close</span> </button> </div> </div> <!-- <div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div>--> <!-- <div class="dz-success-mark"><span>✔</span></div>--> <!-- <div class="dz-error-mark"><span>✘</span></div>--> <div class="dz-error-message il-input-file-error"><span data-dz-errormessage></span></div> </div> </div></div><input class="input-template" type="hidden" name="name_0[]" value="" data-file-id=""></div> </div></div>';
158 $this->assertEquals($expected, $html);
159 }

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

+ Here is the call graph for this function:

◆ test_render_required()

FileInputTest::test_render_required ( )

Definition at line 179 of file FileInputTest.php.

180 {
181 $f = $this->buildFactory();
182 $label = "label";
183 $name = "name_0";
184 $text = $f->file($this->getUploadHandler(), $label)->withNameFrom($this->name_source)->withRequired(true);
185
186 $r = $this->getDefaultRenderer();
187 $html = $this->normalizeHTML($r->render($text));
188
189 $expected
190 = '<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 class="il-input-file" id="id_2"><div class="il-input-file-dropzone"> <button class="btn btn-link" data-action="#" id="id_1">select_files_from_computer</button></div><div class="il-input-file-filelist"> <div class="il-input-file-template dz-preview dz-file-preview" style="display: block; border: 1px solid red" data-file-id=""> <div class="dz-details"> <div class="il-input-file-fileinfo"> <div class="il-input-file-fileinfo-title"><span data-dz-name></span></div> <div data-dz-size class="il-input-file-fileinfo-size"></div> <div class="il-input-file-fileinfo-close"> <button type="button" class="close" data-dz-remove> <span aria-hidden="true">&times;</span> <span class="sr-only">Close</span> </button> </div> </div> <!-- <div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div>--> <!-- <div class="dz-success-mark"><span>✔</span></div>--> <!-- <div class="dz-error-mark"><span>✘</span></div>--> <div class="dz-error-message il-input-file-error"><span data-dz-errormessage></span></div> </div> </div></div><input class="input-template" type="hidden" name="name_0[]" value="" data-file-id=""></div> </div></div>';
191 $this->assertEquals($expected, $html);
192 }

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

+ Here is the call graph for this function:

◆ test_render_value()

FileInputTest::test_render_value ( )

Definition at line 162 of file FileInputTest.php.

163 {
164 $f = $this->buildFactory();
165 $label = "label";
166 $value = ["value"];
167 $name = "name_0";
168 $text = $f->file($this->getUploadHandler(), $label)->withValue($value)->withNameFrom($this->name_source);
169
170 $r = $this->getDefaultRenderer();
171 $html = $this->normalizeHTML($r->render($text));
172
173 $expected
174 = '<div class="form-group row"> <label for="name_0" class="control-label col-sm-3">label</label> <div class="col-sm-9"> <div class="il-input-file" id="id_2"><div class="il-input-file-dropzone"> <button class="btn btn-link" data-action="#" id="id_1">select_files_from_computer</button></div><div class="il-input-file-filelist"> <div class="il-input-file-template dz-preview dz-file-preview" style="display: block; border: 1px solid red" data-file-id=""> <div class="dz-details"> <div class="il-input-file-fileinfo"> <div class="il-input-file-fileinfo-title"><span data-dz-name></span></div> <div data-dz-size class="il-input-file-fileinfo-size"></div> <div class="il-input-file-fileinfo-close"> <button type="button" class="close" data-dz-remove> <span aria-hidden="true">&times;</span> <span class="sr-only">Close</span> </button> </div> </div> <!-- <div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div>--> <!-- <div class="dz-success-mark"><span>✔</span></div>--> <!-- <div class="dz-error-mark"><span>✘</span></div>--> <div class="dz-error-message il-input-file-error"><span data-dz-errormessage></span></div> </div> </div></div><input class="input-template" type="hidden" name="name_0[]" value="" data-file-id=""></div> </div></div>';
175 $this->assertEquals($expected, $html);
176 }

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

+ Here is the call graph for this function:

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