ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)
 testRender More...
 
 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\UploadLimitResolver::class),
67  new SignalGenerator(),
68  $this->data_factory,
69  $this->buildRefinery(),
70  $this->buildLanguage()
71  );
72  }
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 74 of file DurationInputTest.php.

References ILIAS\Repository\symbol().

74  : NoUIFactory
75  {
76  return new class () extends NoUIFactory {
77  public function symbol(): I\Symbol\Factory
78  {
79  return new S\Factory(
80  new S\Icon\Factory(),
81  new S\Glyph\Factory(),
82  new S\Avatar\Factory()
83  );
84  }
85  };
86  }
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 249 of file DurationInputTest.php.

References $duration, and factory().

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

◆ testRender()

DurationInputTest::testRender ( )

Definition at line 163 of file DurationInputTest.php.

References $duration, factory(), and null.

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

◆ testRenderWithDifferentLabels()

DurationInputTest::testRenderWithDifferentLabels (   $duration)

testRender

Definition at line 208 of file DurationInputTest.php.

References $duration, and null.

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

◆ testWithFormat()

DurationInputTest::testWithFormat ( )

Definition at line 88 of file DurationInputTest.php.

References $duration, and factory().

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

◆ testWithInvalidTimeZone()

DurationInputTest::testWithInvalidTimeZone ( )

Definition at line 149 of file DurationInputTest.php.

References $datetime, and factory().

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

◆ testWithMaxValue()

DurationInputTest::testWithMaxValue ( )

Definition at line 112 of file DurationInputTest.php.

References $duration, and factory().

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

◆ testWithMinValue()

DurationInputTest::testWithMinValue ( )

Definition at line 100 of file DurationInputTest.php.

References $duration, and factory().

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

◆ testWithoutByline()

DurationInputTest::testWithoutByline ( )

Definition at line 157 of file DurationInputTest.php.

References $datetime, and factory().

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

◆ testWithTimeOnly()

DurationInputTest::testWithTimeOnly ( )

Definition at line 131 of file DurationInputTest.php.

References $datetime, and factory().

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

◆ testWithTimeZone()

DurationInputTest::testWithTimeZone ( )

Definition at line 138 of file DurationInputTest.php.

References $datetime, and factory().

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

◆ testWithUseTime()

DurationInputTest::testWithUseTime ( )

Definition at line 124 of file DurationInputTest.php.

References $datetime, and factory().

124  : void
125  {
126  $datetime = $this->factory->duration('label', 'byline');
127  $this->assertFalse($datetime->getUseTime());
128  $this->assertTrue($datetime->withUseTime(true)->getUseTime());
129  }
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: