ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
DurationInputTest Class Reference
+ Inheritance diagram for DurationInputTest:
+ Collaboration diagram for DurationInputTest:

Public Member Functions

 setUp ()
 
 getUIFactory ()
 
 testWithFormat ()
 
 testWithMinValue ()
 
 testWithMaxValue ()
 
 testWithUseTime ()
 
 testWithTimeOnly ()
 
 testWithTimeZone ()
 
 testWithInvalidTimeZone ()
 
 testWithoutByline ()
 
 testRender ()
 
 testRenderWithDifferentLabels ($duration)
 
 testCommonRendering ()
 

Protected Member Functions

 buildLanguage ()
 
 buildRefinery ()
 
 buildFactory ()
 

Protected Attributes

DefNamesource $name_source
 
Data Factory $data_factory
 
I Input Field Factory $factory
 
Language $lng
 

Detailed Description

Definition at line 33 of file DurationInputTest.php.

Member Function Documentation

◆ buildFactory()

DurationInputTest::buildFactory ( )
protected

Definition at line 64 of file DurationInputTest.php.

64 : I\Input\Field\Factory
65 {
66 return new I\Input\Field\Factory(
67 $this->createMock(\ILIAS\UI\Implementation\Component\Input\Field\Node\Factory::class),
68 $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
69 new SignalGenerator(),
70 $this->data_factory,
71 $this->buildRefinery(),
72 $this->buildLanguage()
73 );
74 }
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

References buildLanguage(), and buildRefinery().

Referenced by setUp().

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

◆ buildLanguage()

DurationInputTest::buildLanguage ( )
protected

Definition at line 50 of file DurationInputTest.php.

50 : Language
51 {
52 $this->lng = $this->createMock(Language::class);
53 $this->lng->method("txt")
54 ->willReturnCallback(fn($x) => $x);
55
56 return $this->lng;
57 }

References $lng, and ILIAS\Repository\lng().

Referenced by buildFactory(), and buildRefinery().

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

◆ buildRefinery()

DurationInputTest::buildRefinery ( )
protected

Definition at line 59 of file DurationInputTest.php.

59 : Refinery
60 {
61 return new Refinery($this->data_factory, $this->buildLanguage());
62 }

References buildLanguage().

Referenced by buildFactory().

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

◆ getUIFactory()

DurationInputTest::getUIFactory ( )

Definition at line 76 of file DurationInputTest.php.

77 {
78 return new class ($this->createRelayArgumentLanguageStub()) extends NoUIFactory {
79 public function __construct(
80 protected ILIAS\Language\Language $language,
81 ) {
82 }
83
84 public function symbol(): I\Symbol\Factory
85 {
86 return new S\Factory(
87 new S\Icon\Factory(),
88 new S\Glyph\Factory($this->language),
89 new S\Avatar\Factory()
90 );
91 }
92 };
93 }
Builds data types.
Definition: Factory.php:36
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), and ILIAS\Repository\symbol().

+ Here is the call graph for this function:

◆ setUp()

DurationInputTest::setUp ( )

Definition at line 43 of file DurationInputTest.php.

43 : void
44 {
45 $this->name_source = new DefNamesource();
46 $this->data_factory = new Data\Factory();
47 $this->factory = $this->buildFactory();
48 }
factory()

References buildFactory(), and factory().

+ Here is the call graph for this function:

◆ testCommonRendering()

DurationInputTest::testCommonRendering ( )

Definition at line 254 of file DurationInputTest.php.

254 : void
255 {
256 $duration = $this->factory->duration('label')
257 ->withNameFrom($this->name_source);
258 $this->testWithError($duration);
259 $this->testWithNoByline($duration);
260 $this->testWithRequired($duration);
261 $this->testWithDisabled($duration);
262 $this->testWithAdditionalOnloadCodeRendersId($duration);
263 }
$duration

References $duration, and factory().

+ Here is the call graph for this function:

◆ testRender()

DurationInputTest::testRender ( )

Definition at line 170 of file DurationInputTest.php.

171 {
172 $duration = $this->factory->duration('label', 'byline')
173 ->withNameFrom($this->name_source);
174 $label_start = 'duration_default_label_start';
175 $label_end = 'duration_default_label_end';
176
177 $f1 = $this->getFormWrappedHtml(
178 'date-time-field-input',
179 $label_start,
180 '<div class="c-input-group">
181 <input id="id_1" type="date" name="name_0/start_1" class="c-field-datetime" />
182 </div>
183 ',
184 null,
185 'id_1',
186 null,
187 'name_0/start_1'
188 );
189 $f2 = $this->getFormWrappedHtml(
190 'date-time-field-input',
191 $label_end,
192 '<div class="c-input-group">
193 <input id="id_2" type="date" name="name_0/end_2" class="c-field-datetime" />
194 </div>
195 ',
196 null,
197 'id_2',
198 null,
199 'name_0/end_2'
200 );
201
202 $expected = $this->getFormWrappedHtml(
203 'duration-field-input',
204 'label',
205 '<div class="c-field-duration">' . $f1 . $f2 . '</div>',
206 'byline',
207 );
208 $this->assertEquals($expected, $this->renderInsideContainer($duration));
209 return $duration;
210 }
This describes the duration input.
Definition: Duration.php:31

References $duration, and factory().

+ Here is the call graph for this function:

◆ testRenderWithDifferentLabels()

DurationInputTest::testRenderWithDifferentLabels (   $duration)

Definition at line 213 of file DurationInputTest.php.

213 : void
214 {
215 $other_start_label = 'other startlabel';
216 $other_end_label = 'other endlabel';
217
218 $duration = $duration->withLabels($other_start_label, $other_end_label);
219
220 $f1 = $this->getFormWrappedHtml(
221 'date-time-field-input',
222 $other_start_label,
223 '<div class="c-input-group">
224 <input id="id_1" type="date" name="name_0/start_1" class="c-field-datetime" />
225 </div>
226 ',
227 null,
228 'id_1',
229 null,
230 'name_0/start_1'
231 );
232 $f2 = $this->getFormWrappedHtml(
233 'date-time-field-input',
234 $other_end_label,
235 '<div class="c-input-group">
236 <input id="id_2" type="date" name="name_0/end_2" class="c-field-datetime" />
237 </div>
238 ',
239 null,
240 'id_2',
241 null,
242 'name_0/end_2'
243 );
244
245 $expected = $this->getFormWrappedHtml(
246 'duration-field-input',
247 'label',
248 '<div class="c-field-duration">' . $f1 . $f2 . '</div>',
249 'byline'
250 );
251 $this->assertEquals($expected, $this->renderInsideContainer($duration));
252 }

References $duration.

◆ testWithFormat()

DurationInputTest::testWithFormat ( )

Definition at line 95 of file DurationInputTest.php.

95 : void
96 {
97 $format = $this->data_factory->dateFormat()->germanShort();
98 $duration = $this->factory->duration('label', 'byline')
99 ->withFormat($format);
100
101 $this->assertEquals(
102 $format,
103 $duration->getFormat()
104 );
105 }

References $duration, and factory().

+ Here is the call graph for this function:

◆ testWithInvalidTimeZone()

DurationInputTest::testWithInvalidTimeZone ( )

Definition at line 156 of file DurationInputTest.php.

156 : void
157 {
158 $this->expectException(InvalidArgumentException::class);
159 $datetime = $this->factory->duration('label', 'byline');
160 $tz = 'NOT/aValidTZ';
161 $datetime->withTimeZone($tz);
162 }
$datetime

References $datetime, and factory().

+ Here is the call graph for this function:

◆ testWithMaxValue()

DurationInputTest::testWithMaxValue ( )

Definition at line 119 of file DurationInputTest.php.

119 : void
120 {
121 $dat = new DateTimeImmutable('2019-01-09');
122 $duration = $this->factory->duration('label', 'byline')
123 ->withMaxValue($dat);
124
125 $this->assertEquals(
126 $dat,
127 $duration->getMaxValue()
128 );
129 }

References $duration, and factory().

+ Here is the call graph for this function:

◆ testWithMinValue()

DurationInputTest::testWithMinValue ( )

Definition at line 107 of file DurationInputTest.php.

107 : void
108 {
109 $dat = new DateTimeImmutable('2019-01-09');
110 $duration = $this->factory->duration('label', 'byline')
111 ->withMinValue($dat);
112
113 $this->assertEquals(
114 $dat,
115 $duration->getMinValue()
116 );
117 }

References $duration, and factory().

+ Here is the call graph for this function:

◆ testWithoutByline()

DurationInputTest::testWithoutByline ( )

Definition at line 164 of file DurationInputTest.php.

164 : void
165 {
166 $datetime = $this->factory->duration('label');
167 $this->assertInstanceOf(C\Input\Field\Duration::class, $datetime);
168 }

References $datetime, and factory().

+ Here is the call graph for this function:

◆ testWithTimeOnly()

DurationInputTest::testWithTimeOnly ( )

Definition at line 138 of file DurationInputTest.php.

138 : void
139 {
140 $datetime = $this->factory->duration('label', 'byline');
141 $this->assertFalse($datetime->getTimeOnly());
142 $this->assertTrue($datetime->withTimeOnly(true)->getTimeOnly());
143 }

References $datetime, and factory().

+ Here is the call graph for this function:

◆ testWithTimeZone()

DurationInputTest::testWithTimeZone ( )

Definition at line 145 of file DurationInputTest.php.

145 : void
146 {
147 $datetime = $this->factory->duration('label', 'byline');
148 $this->assertNull($datetime->getTimeZone());
149 $tz = 'Europe/Moscow';
150 $this->assertEquals(
151 $tz,
152 $datetime->withTimeZone($tz)->getTimeZone()
153 );
154 }

References $datetime, and factory().

+ Here is the call graph for this function:

◆ testWithUseTime()

DurationInputTest::testWithUseTime ( )

Definition at line 131 of file DurationInputTest.php.

131 : void
132 {
133 $datetime = $this->factory->duration('label', 'byline');
134 $this->assertFalse($datetime->getUseTime());
135 $this->assertTrue($datetime->withUseTime(true)->getUseTime());
136 }

References $datetime, and factory().

+ Here is the call graph for this function:

Field Documentation

◆ $data_factory

Data Factory DurationInputTest::$data_factory
protected

Definition at line 39 of file DurationInputTest.php.

◆ $factory

I Input Field Factory DurationInputTest::$factory
protected

Definition at line 40 of file DurationInputTest.php.

◆ $lng

Language DurationInputTest::$lng
protected

Definition at line 41 of file DurationInputTest.php.

Referenced by buildLanguage().

◆ $name_source

DefNamesource DurationInputTest::$name_source
protected

Definition at line 38 of file DurationInputTest.php.


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