ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
DateTimeInputTest Class Reference
+ Inheritance diagram for DateTimeInputTest:
+ Collaboration diagram for DateTimeInputTest:

Public Member Functions

 setUp ()
 
 getUIFactory ()
 
 getLanguage ()
 
 testWithFormat ()
 
 testWithMinValue ()
 
 testWithMaxValue ()
 
 testWithUseTime ()
 
 testWithTimeOnly ()
 
 testWithTimeZone ()
 
 testWithInvalidTimeZone ()
 
 testWithValueThatIsDateTimeImmutable ()
 
 testWithInvalidValue ()
 
 testRender ()
 
 testCommonRendering ()
 

Protected Member Functions

 buildFactory ()
 

Protected Attributes

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

Detailed Description

Definition at line 32 of file DateTimeInputTest.php.

Member Function Documentation

◆ buildFactory()

DateTimeInputTest::buildFactory ( )
protected

Definition at line 71 of file DateTimeInputTest.php.

Referenced by setUp().

71  : I\Input\Field\Factory
72  {
73  $df = new Data\Factory();
74  $language = $this->createMock(ILIAS\Language\Language::class);
75 
76  return new I\Input\Field\Factory(
77  $this->createMock(\ILIAS\UI\Implementation\Component\Input\Field\Node\Factory::class),
78  $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
79  new SignalGenerator(),
80  $this->data_factory,
81  new Refinery($df, $language),
82  $language
83  );
84  }
Interface Observer Contains several chained tasks and infos about them.
+ Here is the caller graph for this function:

◆ getLanguage()

DateTimeInputTest::getLanguage ( )

Definition at line 61 of file DateTimeInputTest.php.

61  : LanguageMock
62  {
63  return new class () extends LanguageMock {
64  public function getLangKey(): string
65  {
66  return 'en';
67  }
68  };
69  }

◆ getUIFactory()

DateTimeInputTest::getUIFactory ( )

Definition at line 47 of file DateTimeInputTest.php.

References ILIAS\Repository\symbol().

47  : NoUIFactory
48  {
49  return new class () extends NoUIFactory {
50  public function symbol(): I\Symbol\Factory
51  {
52  return new S\Factory(
53  new S\Icon\Factory(),
54  new S\Glyph\Factory(),
55  new S\Avatar\Factory()
56  );
57  }
58  };
59  }
Builds data types.
Definition: Factory.php:35
+ Here is the call graph for this function:

◆ setUp()

DateTimeInputTest::setUp ( )

Definition at line 40 of file DateTimeInputTest.php.

References buildFactory(), and factory().

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

◆ testCommonRendering()

DateTimeInputTest::testCommonRendering ( )

Definition at line 194 of file DateTimeInputTest.php.

References $datetime, and factory().

194  : void
195  {
196  $datetime = $this->factory->dateTime('label')
197  ->withNameFrom($this->name_source);
198 
199  $this->testWithError($datetime);
200  $this->testWithNoByline($datetime);
201  $this->testWithRequired($datetime);
202  $this->testWithDisabled($datetime);
203  $this->testWithAdditionalOnloadCodeRendersId($datetime);
204  }
factory()
$datetime
+ Here is the call graph for this function:

◆ testRender()

DateTimeInputTest::testRender ( )

Definition at line 174 of file DateTimeInputTest.php.

References $datetime, $r, and factory().

174  : void
175  {
176  $datetime = $this->factory->dateTime('label', 'byline');
177  $r = $this->getDefaultRenderer();
178  $html = $this->brutallyTrimHTML($r->render($datetime));
179 
180  $expected = $this->brutallyTrimHTML('
181  <fieldset class="c-input" data-il-ui-component="date-time-field-input" data-il-ui-input-name="">
182  <label for="id_1">label</label>
183  <div class="c-input__field">
184  <div class="c-input-group">
185  <input id="id_1" type="date" class="c-field-datetime" />
186  </div>
187  </div>
188  <div class="c-input__help-byline">byline</div>
189  </fieldset>
190  ');
191  $this->assertEquals($expected, $html);
192  }
factory()
$datetime
$r
+ Here is the call graph for this function:

◆ testWithFormat()

DateTimeInputTest::testWithFormat ( )

Definition at line 86 of file DateTimeInputTest.php.

References $datetime, and factory().

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

◆ testWithInvalidTimeZone()

DateTimeInputTest::testWithInvalidTimeZone ( )

Definition at line 147 of file DateTimeInputTest.php.

References $datetime, and factory().

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

◆ testWithInvalidValue()

DateTimeInputTest::testWithInvalidValue ( )

Definition at line 167 of file DateTimeInputTest.php.

References $datetime, and factory().

167  : void
168  {
169  $this->expectException(InvalidArgumentException::class);
170  $datetime = $this->factory->datetime('label', 'byline')
171  ->withValue("this is no datetime...");
172  }
factory()
$datetime
+ Here is the call graph for this function:

◆ testWithMaxValue()

DateTimeInputTest::testWithMaxValue ( )

Definition at line 110 of file DateTimeInputTest.php.

References $datetime, and factory().

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

◆ testWithMinValue()

DateTimeInputTest::testWithMinValue ( )

Definition at line 98 of file DateTimeInputTest.php.

References $datetime, and factory().

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

◆ testWithTimeOnly()

DateTimeInputTest::testWithTimeOnly ( )

Definition at line 129 of file DateTimeInputTest.php.

References $datetime, and factory().

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

◆ testWithTimeZone()

DateTimeInputTest::testWithTimeZone ( )

Definition at line 136 of file DateTimeInputTest.php.

References $datetime, and factory().

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

◆ testWithUseTime()

DateTimeInputTest::testWithUseTime ( )

Definition at line 122 of file DateTimeInputTest.php.

References $datetime, and factory().

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

◆ testWithValueThatIsDateTimeImmutable()

DateTimeInputTest::testWithValueThatIsDateTimeImmutable ( )

Definition at line 155 of file DateTimeInputTest.php.

References $datetime, and factory().

155  : void
156  {
157  $string_value = "1985-05-04 00:00";
158  $value = new \DateTimeImmutable($string_value);
159  $datetime = $this->factory->datetime('label', 'byline')
160  ->withValue($value);
161  $this->assertEquals(
162  $string_value,
163  $datetime->getValue()
164  );
165  }
factory()
$datetime
+ Here is the call graph for this function:

Field Documentation

◆ $data_factory

Data Factory DateTimeInputTest::$data_factory
protected

Definition at line 37 of file DateTimeInputTest.php.

◆ $factory

I Input Field Factory DateTimeInputTest::$factory
protected

Definition at line 38 of file DateTimeInputTest.php.

◆ $name_source

DefNamesource DateTimeInputTest::$name_source
protected

Definition at line 36 of file DateTimeInputTest.php.


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