ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SectionInputTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21require_once(__DIR__ . "/../../../../../../../vendor/composer/vendor/autoload.php");
22require_once(__DIR__ . "/../../../Base.php");
23require_once(__DIR__ . "/CommonFieldRendering.php");
24
26use ILIAS\Data;
27
29{
30 use CommonFieldRendering;
31
33
34 public function setUp(): void
35 {
36 $this->name_source = new DefNamesource();
37 }
38
39 public function testSectionRendering(): void
40 {
41 $f = $this->getFieldFactory();
42 $inputs = [
43 $f->text("input1", "in 1"),
44 $f->text("input2", "in 2")
45 ];
46 $label = 'section label';
47 $byline = 'section byline';
48 $section = $f->section($inputs, $label, $byline)->withNameFrom($this->name_source);
49 $f1 = $this->getFormWrappedHtml(
50 'text-field-input',
51 'input1',
52 '<input id="id_1" type="text" name="name_0/name_1" class="c-field-text" />',
53 'in 1',
54 'id_1',
55 null,
56 'name_0/name_1'
57 );
58 $f2 = $this->getFormWrappedHtml(
59 'text-field-input',
60 'input2',
61 '<input id="id_2" type="text" name="name_0/name_2" class="c-field-text" />',
62 'in 2',
63 'id_2',
64 null,
65 'name_0/name_2'
66 );
67 $expected = $this->getFormWrappedHtml(
68 'section-field-input',
69 $label,
70 $f1 . $f2,
71 $byline,
72 ''
73 );
74 $this->assertEquals($expected, $this->render($section));
75 }
76
77
78 public function testCommonRendering(): void
79 {
80 $f = $this->getFieldFactory();
81 $inputs = [
82 $f->text("input1")
83 ];
84 $label = 'section label';
85 $section = $f->section($inputs, $label)->withNameFrom($this->name_source);
86
87 $this->testWithError($section);
88 $this->testWithNoByline($section);
89 $this->testWithRequired($section);
90 $this->testWithDisabled($section);
91 $this->testWithAdditionalOnloadCodeRendersId($section);
92 }
93
94 public function testNestedSectionRendering(): void
95 {
96 $f = $this->getFieldFactory();
97 $inputs_level4 = [$f->text("input3", "input3 byline")];
98 $section_level4 = $f->section($inputs_level4, "Inner Section");
99
100 $inputs_level3 = [$f->text("input2", "input2 byline"), $section_level4];
101 $section_level3 = $f->section($inputs_level3, "Middle Section");
102
103 $inputs_level2 = [$f->text("input1", "input1 byline"), $section_level3];
104 $section_level2 = $f->section($inputs_level2, "Outermost Section");
105
106 $nested_sections_html = $this->render($section_level2);
107
108 $this->assertStringContainsString('<h2>Outermost Section</h2>', $nested_sections_html);
109 $this->assertStringContainsString('<h3>Middle Section</h3>', $nested_sections_html);
110 $this->assertStringContainsString('<h4>Inner Section</h4>', $nested_sections_html);
111 }
112}
Provides common functionality for UI tests.
Definition: Base.php:337
DefNamesource $name_source
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Checkbox.php:21