ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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 63 of file DurationInputTest.php.

References buildLanguage(), and buildRefinery().

Referenced by setUp().

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

◆ buildLanguage()

DurationInputTest::buildLanguage ( )
protected

Definition at line 49 of file DurationInputTest.php.

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

Referenced by buildFactory(), and buildRefinery().

49  : Language
50  {
51  $this->lng = $this->createMock(Language::class);
52  $this->lng->method("txt")
53  ->will($this->returnArgument(0));
54 
55  return $this->lng;
56  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildRefinery()

DurationInputTest::buildRefinery ( )
protected

Definition at line 58 of file DurationInputTest.php.

References buildLanguage().

Referenced by buildFactory().

58  : Refinery
59  {
60  return new Refinery($this->data_factory, $this->buildLanguage());
61  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUIFactory()

DurationInputTest::getUIFactory ( )

Definition at line 75 of file DurationInputTest.php.

References ILIAS\Repository\symbol().

75  : NoUIFactory
76  {
77  return new class () extends NoUIFactory {
78  public function symbol(): I\Symbol\Factory
79  {
80  return new S\Factory(
81  new S\Icon\Factory(),
82  new S\Glyph\Factory(),
83  new S\Avatar\Factory()
84  );
85  }
86  };
87  }
Builds data types.
Definition: Factory.php:35
+ Here is the call graph for this function:

◆ setUp()

DurationInputTest::setUp ( )

Definition at line 42 of file DurationInputTest.php.

References buildFactory(), and factory().

42  : void
43  {
44  $this->name_source = new DefNamesource();
45  $this->data_factory = new Data\Factory();
46  $this->factory = $this->buildFactory();
47  }
factory()
+ Here is the call graph for this function:

◆ testCommonRendering()

DurationInputTest::testCommonRendering ( )

Definition at line 248 of file DurationInputTest.php.

References $duration, and factory().

248  : void
249  {
250  $duration = $this->factory->duration('label')
251  ->withNameFrom($this->name_source);
252  $this->testWithError($duration);
253  $this->testWithNoByline($duration);
254  $this->testWithRequired($duration);
255  $this->testWithDisabled($duration);
256  $this->testWithAdditionalOnloadCodeRendersId($duration);
257  }
factory()
$duration
+ Here is the call graph for this function:

◆ testRender()

DurationInputTest::testRender ( )

Definition at line 164 of file DurationInputTest.php.

References $duration, factory(), and null.

164  : \ILIAS\UI\Component\Input\Field\Duration
165  {
166  $duration = $this->factory->duration('label', 'byline')
167  ->withNameFrom($this->name_source);
168  $label_start = 'duration_default_label_start';
169  $label_end = 'duration_default_label_end';
170 
171  $f1 = $this->getFormWrappedHtml(
172  'date-time-field-input',
173  $label_start,
174  '<div class="c-input-group">
175  <input id="id_1" type="date" name="name_0/start_1" class="c-field-datetime" />
176  </div>
177  ',
178  null,
179  'id_1',
180  null,
181  'name_0/start_1'
182  );
183  $f2 = $this->getFormWrappedHtml(
184  'date-time-field-input',
185  $label_end,
186  '<div class="c-input-group">
187  <input id="id_2" type="date" name="name_0/end_2" class="c-field-datetime" />
188  </div>
189  ',
190  null,
191  'id_2',
192  null,
193  'name_0/end_2'
194  );
195 
196  $expected = $this->getFormWrappedHtml(
197  'duration-field-input',
198  'label',
199  '<div class="c-field-duration">' . $f1 . $f2 . '</div>',
200  'byline',
201  );
202  $this->assertEquals($expected, $this->render($duration));
203  return $duration;
204  }
factory()
$duration
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ testRenderWithDifferentLabels()

DurationInputTest::testRenderWithDifferentLabels (   $duration)

Definition at line 207 of file DurationInputTest.php.

References $duration, and null.

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

◆ testWithFormat()

DurationInputTest::testWithFormat ( )

Definition at line 89 of file DurationInputTest.php.

References $duration, and factory().

89  : void
90  {
91  $format = $this->data_factory->dateFormat()->germanShort();
92  $duration = $this->factory->duration('label', 'byline')
93  ->withFormat($format);
94 
95  $this->assertEquals(
96  $format,
97  $duration->getFormat()
98  );
99  }
factory()
$duration
+ Here is the call graph for this function:

◆ testWithInvalidTimeZone()

DurationInputTest::testWithInvalidTimeZone ( )

Definition at line 150 of file DurationInputTest.php.

References $datetime, and factory().

150  : void
151  {
152  $this->expectException(InvalidArgumentException::class);
153  $datetime = $this->factory->duration('label', 'byline');
154  $tz = 'NOT/aValidTZ';
155  $datetime->withTimeZone($tz);
156  }
factory()
$datetime
+ Here is the call graph for this function:

◆ testWithMaxValue()

DurationInputTest::testWithMaxValue ( )

Definition at line 113 of file DurationInputTest.php.

References $duration, and factory().

113  : void
114  {
115  $dat = new DateTimeImmutable('2019-01-09');
116  $duration = $this->factory->duration('label', 'byline')
117  ->withMaxValue($dat);
118 
119  $this->assertEquals(
120  $dat,
121  $duration->getMaxValue()
122  );
123  }
factory()
$duration
+ Here is the call graph for this function:

◆ testWithMinValue()

DurationInputTest::testWithMinValue ( )

Definition at line 101 of file DurationInputTest.php.

References $duration, and factory().

101  : void
102  {
103  $dat = new DateTimeImmutable('2019-01-09');
104  $duration = $this->factory->duration('label', 'byline')
105  ->withMinValue($dat);
106 
107  $this->assertEquals(
108  $dat,
109  $duration->getMinValue()
110  );
111  }
factory()
$duration
+ Here is the call graph for this function:

◆ testWithoutByline()

DurationInputTest::testWithoutByline ( )

Definition at line 158 of file DurationInputTest.php.

References $datetime, and factory().

158  : void
159  {
160  $datetime = $this->factory->duration('label');
161  $this->assertInstanceOf(C\Input\Field\Duration::class, $datetime);
162  }
factory()
$datetime
+ Here is the call graph for this function:

◆ testWithTimeOnly()

DurationInputTest::testWithTimeOnly ( )

Definition at line 132 of file DurationInputTest.php.

References $datetime, and factory().

132  : void
133  {
134  $datetime = $this->factory->duration('label', 'byline');
135  $this->assertFalse($datetime->getTimeOnly());
136  $this->assertTrue($datetime->withTimeOnly(true)->getTimeOnly());
137  }
factory()
$datetime
+ Here is the call graph for this function:

◆ testWithTimeZone()

DurationInputTest::testWithTimeZone ( )

Definition at line 139 of file DurationInputTest.php.

References $datetime, and factory().

139  : void
140  {
141  $datetime = $this->factory->duration('label', 'byline');
142  $this->assertNull($datetime->getTimeZone());
143  $tz = 'Europe/Moscow';
144  $this->assertEquals(
145  $tz,
146  $datetime->withTimeZone($tz)->getTimeZone()
147  );
148  }
factory()
$datetime
+ Here is the call graph for this function:

◆ testWithUseTime()

DurationInputTest::testWithUseTime ( )

Definition at line 125 of file DurationInputTest.php.

References $datetime, and factory().

125  : void
126  {
127  $datetime = $this->factory->duration('label', 'byline');
128  $this->assertFalse($datetime->getUseTime());
129  $this->assertTrue($datetime->withUseTime(true)->getUseTime());
130  }
factory()
$datetime
+ Here is the call graph for this function:

Field Documentation

◆ $data_factory

Data Factory DurationInputTest::$data_factory
protected

Definition at line 38 of file DurationInputTest.php.

◆ $factory

I Input Field Factory DurationInputTest::$factory
protected

Definition at line 39 of file DurationInputTest.php.

◆ $lng

Language DurationInputTest::$lng
protected

Definition at line 40 of file DurationInputTest.php.

Referenced by buildLanguage().

◆ $name_source

DefNamesource DurationInputTest::$name_source
protected

Definition at line 37 of file DurationInputTest.php.


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