ILIAS  release_8 Revision v8.24
SectionInputTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21require_once(__DIR__ . "/../../../../../libs/composer/vendor/autoload.php");
22require_once(__DIR__ . "/../../../Base.php");
23
25use ILIAS\Data;
26
28{
29 public function getFieldFactory(): Field\Factory
30 {
32 $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
34 new Data\Factory(),
35 $this->getRefinery(),
36 $this->getLanguage()
37 );
38 return $factory;
39 }
40
41 public function testSectionRendering(): void
42 {
43 $f = $this->getFieldFactory();
44 $r = $this->getDefaultRenderer();
45 $inputs = [
46 $f->text("input1", "in 1"),
47 $f->text("input2", "in 2")
48 ];
49 $label = 'section label';
50 $byline = 'section byline';
51 $section = $f->section($inputs, $label, $byline);
52 $actual = $this->brutallyTrimHTML($r->render($section));
53 $expected = <<<EOT
54 <div class="il-section-input">
55 <div class="il-section-input-header">
56 <h2>section label</h2>
57 <div class="il-section-input-header-byline">section byline</div>
58 </div>
59 <div class="form-group row">
60 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">input1</label>
61 <div class="col-sm-8 col-md-9 col-lg-10">
62 <input id="id_1" type="text" name="" class="form-control form-control-sm" />
63 <div class="help-block">in 1</div>
64 </div>
65 </div>
66 <div class="form-group row">
67 <label for="id_2" class="control-label col-sm-4 col-md-3 col-lg-2">input2</label>
68 <div class="col-sm-8 col-md-9 col-lg-10">
69 <input id="id_2" type="text" name="" class="form-control form-control-sm" />
70 <div class="help-block">in 2</div>
71 </div>
72 </div>
73 </div>
74EOT;
75 $expected = $this->brutallyTrimHTML($expected);
76 $this->assertEquals($expected, $actual);
77 }
78
79 public function testSectionRenderingWithError(): void
80 {
81 $f = $this->getFieldFactory();
82 $r = $this->getDefaultRenderer();
83 $inputs = [
84 $f->text("input1", "in 1")
85 ];
86 $label = 'section label';
87 $byline = 'section byline';
88 $section = $f->section($inputs, $label, $byline);
89 $actual = $this->brutallyTrimHTML($r->render($section->withError("Some Error")));
90 $expected = <<<EOT
91 <div class="il-section-input">
92 <div class="il-section-input-header">
93 <h2>section label</h2>
94 <div class="il-section-input-header-byline">section byline</div>
95 </div>
96 <div class="help-block alert alert-danger" role="alert"> Some Error </div>
97 <div class="form-group row">
98 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">input1</label>
99 <div class="col-sm-8 col-md-9 col-lg-10">
100 <input id="id_1" type="text" name="" class="form-control form-control-sm" />
101 <div class="help-block">in 1</div>
102 </div>
103 </div>
104 </div>
105EOT;
106 $expected = $this->brutallyTrimHTML($expected);
107 $this->assertEquals($expected, $actual);
108 }
109}
Factory for Date Formats.
Definition: Factory.php:27
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Error.php:18
This is a legacy support of Implementation\Component\Input\Field\Input that has been moved to Impleme...
Definition: Input.php:32
Provides common functionality for UI tests.
Definition: Base.php:299
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:444
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
$factory
Definition: metadata.php:75
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Checkbox.php:21
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.