ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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 76 of file DateTimeInputTest.php.

76 : I\Input\Field\Factory
77 {
78 $df = new Data\Factory();
79 $language = $this->createMock(ILIAS\Language\Language::class);
80
81 return new I\Input\Field\Factory(
82 $this->createMock(\ILIAS\UI\Implementation\Component\Input\Field\Node\Factory::class),
83 $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
84 new SignalGenerator(),
85 $this->data_factory,
86 new Refinery($df, $language),
87 $language
88 );
89 }
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

Referenced by setUp().

+ Here is the caller graph for this function:

◆ getLanguage()

DateTimeInputTest::getLanguage ( )

Definition at line 66 of file DateTimeInputTest.php.

67 {
68 return new class () extends LanguageMock {
69 public function getLangKey(): string
70 {
71 return 'en';
72 }
73 };
74 }

◆ getUIFactory()

DateTimeInputTest::getUIFactory ( )

Definition at line 48 of file DateTimeInputTest.php.

49 {
50 return new class ($this->createRelayArgumentLanguageStub()) extends NoUIFactory {
51 public function __construct(
52 protected \ILIAS\Language\Language $language,
53 ) {
54 }
55 public function symbol(): I\Symbol\Factory
56 {
57 return new S\Factory(
58 new S\Icon\Factory(),
59 new S\Glyph\Factory($this->language),
60 new S\Avatar\Factory()
61 );
62 }
63 };
64 }
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()

DateTimeInputTest::setUp ( )

Definition at line 41 of file DateTimeInputTest.php.

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

References buildFactory(), and factory().

+ Here is the call graph for this function:

◆ testCommonRendering()

DateTimeInputTest::testCommonRendering ( )

Definition at line 199 of file DateTimeInputTest.php.

199 : void
200 {
201 $datetime = $this->factory->dateTime('label')
202 ->withNameFrom($this->name_source);
203
204 $this->testWithError($datetime);
205 $this->testWithNoByline($datetime);
206 $this->testWithRequired($datetime);
207 $this->testWithDisabled($datetime);
208 $this->testWithAdditionalOnloadCodeRendersId($datetime);
209 }
$datetime

References $datetime, and factory().

+ Here is the call graph for this function:

◆ testRender()

DateTimeInputTest::testRender ( )

Definition at line 179 of file DateTimeInputTest.php.

179 : void
180 {
181 $datetime = $this->factory->dateTime('label', 'byline');
182 $r = $this->getDefaultRenderer();
183 $html = $this->brutallyTrimHTML($r->render($datetime));
184
185 $expected = $this->brutallyTrimHTML('
186 <fieldset class="c-input" data-il-ui-component="date-time-field-input" data-il-ui-input-name="">
187 <label for="id_1">label</label>
188 <div class="c-input__field">
189 <div class="c-input-group">
190 <input id="id_1" type="date" class="c-field-datetime" />
191 </div>
192 </div>
193 <div class="c-input__help-byline">byline</div>
194 </fieldset>
195 ');
196 $this->assertEquals($expected, $html);
197 }

References $datetime, and factory().

+ Here is the call graph for this function:

◆ testWithFormat()

DateTimeInputTest::testWithFormat ( )

Definition at line 91 of file DateTimeInputTest.php.

91 : void
92 {
93 $format = $this->data_factory->dateFormat()->germanShort();
94 $datetime = $this->factory->datetime('label', 'byline')
95 ->withFormat($format);
96
97 $this->assertEquals(
98 $format,
99 $datetime->getFormat()
100 );
101 }

References $datetime, and factory().

+ Here is the call graph for this function:

◆ testWithInvalidTimeZone()

DateTimeInputTest::testWithInvalidTimeZone ( )

Definition at line 152 of file DateTimeInputTest.php.

152 : void
153 {
154 $this->expectException(InvalidArgumentException::class);
155 $datetime = $this->factory->datetime('label', 'byline');
156 $tz = 'NOT/aValidTZ';
157 $datetime->withTimeZone($tz);
158 }

References $datetime, and factory().

+ Here is the call graph for this function:

◆ testWithInvalidValue()

DateTimeInputTest::testWithInvalidValue ( )

Definition at line 172 of file DateTimeInputTest.php.

172 : void
173 {
174 $this->expectException(InvalidArgumentException::class);
175 $datetime = $this->factory->datetime('label', 'byline')
176 ->withValue("this is no datetime...");
177 }

References $datetime, and factory().

+ Here is the call graph for this function:

◆ testWithMaxValue()

DateTimeInputTest::testWithMaxValue ( )

Definition at line 115 of file DateTimeInputTest.php.

115 : void
116 {
117 $dat = new DateTimeImmutable('2019-01-09');
118 $datetime = $this->factory->datetime('label', 'byline')
119 ->withMaxValue($dat);
120
121 $this->assertEquals(
122 $dat,
123 $datetime->getMaxValue()
124 );
125 }

References $datetime, and factory().

+ Here is the call graph for this function:

◆ testWithMinValue()

DateTimeInputTest::testWithMinValue ( )

Definition at line 103 of file DateTimeInputTest.php.

103 : void
104 {
105 $dat = new DateTimeImmutable('2019-01-09');
106 $datetime = $this->factory->datetime('label', 'byline')
107 ->withMinValue($dat);
108
109 $this->assertEquals(
110 $dat,
111 $datetime->getMinValue()
112 );
113 }

References $datetime, and factory().

+ Here is the call graph for this function:

◆ testWithTimeOnly()

DateTimeInputTest::testWithTimeOnly ( )

Definition at line 134 of file DateTimeInputTest.php.

134 : void
135 {
136 $datetime = $this->factory->datetime('label', 'byline');
137 $this->assertFalse($datetime->getTimeOnly());
138 $this->assertTrue($datetime->withTimeOnly(true)->getTimeOnly());
139 }

References $datetime, and factory().

+ Here is the call graph for this function:

◆ testWithTimeZone()

DateTimeInputTest::testWithTimeZone ( )

Definition at line 141 of file DateTimeInputTest.php.

141 : void
142 {
143 $datetime = $this->factory->datetime('label', 'byline');
144 $this->assertNull($datetime->getTimeZone());
145 $tz = 'Europe/Moscow';
146 $this->assertEquals(
147 $tz,
148 $datetime->withTimeZone($tz)->getTimeZone()
149 );
150 }

References $datetime, and factory().

+ Here is the call graph for this function:

◆ testWithUseTime()

DateTimeInputTest::testWithUseTime ( )

Definition at line 127 of file DateTimeInputTest.php.

127 : void
128 {
129 $datetime = $this->factory->datetime('label', 'byline');
130 $this->assertFalse($datetime->getUseTime());
131 $this->assertTrue($datetime->withUseTime(true)->getUseTime());
132 }

References $datetime, and factory().

+ Here is the call graph for this function:

◆ testWithValueThatIsDateTimeImmutable()

DateTimeInputTest::testWithValueThatIsDateTimeImmutable ( )

Definition at line 160 of file DateTimeInputTest.php.

160 : void
161 {
162 $string_value = "1985-05-04 00:00";
163 $value = new \DateTimeImmutable($string_value);
164 $datetime = $this->factory->datetime('label', 'byline')
165 ->withValue($value);
166 $this->assertEquals(
167 $string_value,
168 $datetime->getValue()
169 );
170 }

References $datetime, and factory().

+ Here is the call graph for this function:

Field Documentation

◆ $data_factory

Data Factory DateTimeInputTest::$data_factory
protected

Definition at line 38 of file DateTimeInputTest.php.

◆ $factory

I Input Field Factory DateTimeInputTest::$factory
protected

Definition at line 39 of file DateTimeInputTest.php.

◆ $name_source

DefNamesource DateTimeInputTest::$name_source
protected

Definition at line 37 of file DateTimeInputTest.php.


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