ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
DateTimeInputTest Class Reference
+ Inheritance diagram for DateTimeInputTest:
+ Collaboration diagram for DateTimeInputTest:

Public Member Functions

 setUp ()
 
 getUIFactory ()
 
 getLanguage ()
 
 test_withFormat ()
 
 test_withMinValue ()
 
 test_withMaxValue ()
 
 test_withUseTime ()
 
 test_withTimeOnly ()
 
 test_withTimeZone ()
 
 test_withInvalidTimeZone ()
 
 test_jsConfigRendering ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Protected Member Functions

 buildFactory ()
 
- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 

Detailed Description

Definition at line 17 of file DateTimeInputTest.php.

Member Function Documentation

◆ buildFactory()

DateTimeInputTest::buildFactory ( )
protected

Definition at line 52 of file DateTimeInputTest.php.

Referenced by setUp().

53  {
54  $df = new Data\Factory();
55  $language = $this->createMock(\ilLanguage::class);
56 
58  new SignalGenerator(),
59  $this->data_factory,
60  new \ILIAS\Refinery\Factory($df, $language),
61  $language
62  );
63  }
Class ChatMainBarProvider .
Builds data types.
Definition: Factory.php:19
+ Here is the caller graph for this function:

◆ getLanguage()

DateTimeInputTest::getLanguage ( )

Definition at line 41 of file DateTimeInputTest.php.

42  {
43  $languageMock = new class extends ilLanguageMock {
44  public function getLangKey() : string
45  {
46  return 'en';
47  }
48  };
49  return new $languageMock();
50  }

◆ getUIFactory()

DateTimeInputTest::getUIFactory ( )

Definition at line 26 of file DateTimeInputTest.php.

References $factory.

27  {
28  $factory = new class extends NoUIFactory {
29  public function symbol() : \ILIAS\UI\Component\Symbol\Factory
30  {
31  return new S\Factory(
32  new S\Icon\Factory(),
33  new S\Glyph\Factory(),
34  new S\Avatar\Factory()
35  );
36  }
37  };
38  return $factory;
39  }
Class Factory.
Class ChatMainBarProvider .
Builds data types.
Definition: Factory.php:19
$factory
Definition: metadata.php:58

◆ setUp()

DateTimeInputTest::setUp ( )

Definition at line 19 of file DateTimeInputTest.php.

References buildFactory().

19  : void
20  {
21  $this->name_source = new DefNamesource();
22  $this->data_factory = new Data\Factory();
23  $this->factory = $this->buildFactory();
24  }
+ Here is the call graph for this function:

◆ test_jsConfigRendering()

DateTimeInputTest::test_jsConfigRendering ( )

Definition at line 134 of file DateTimeInputTest.php.

References ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\getJavaScriptBinding().

135  {
136  $datetime = $this->factory->datetime('label', 'byline');
137  $js_binding = $this->getJavaScriptBinding();
138  $html = $this->getDefaultRenderer($js_binding)->render($datetime);
139 
140  $expected = '$("#id_1").datetimepicker({'
141  . '"showClear":true,'
142  . '"sideBySide":true,'
143  . '"format":"YYYY-MM-DD",'
144  . '"locale":"en"'
145  . '});';
146 
147  $onload_js = array_shift($js_binding->on_load_code);
148  $this->assertEquals($expected, $onload_js);
149  }
getJavaScriptBinding()
Definition: Base.php:294
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ test_withFormat()

DateTimeInputTest::test_withFormat ( )

Definition at line 65 of file DateTimeInputTest.php.

References $format.

66  {
67  $format = $this->data_factory->dateFormat()->germanShort();
68  $datetime = $this->factory->datetime('label', 'byline')
69  ->withFormat($format);
70 
71  $this->assertEquals(
72  $format,
73  $datetime->getFormat()
74  );
75  }
$format
Definition: metadata.php:218

◆ test_withInvalidTimeZone()

DateTimeInputTest::test_withInvalidTimeZone ( )

Definition at line 126 of file DateTimeInputTest.php.

127  {
128  $this->expectException(\InvalidArgumentException::class);
129  $datetime = $this->factory->datetime('label', 'byline');
130  $tz = 'NOT/aValidTZ';
131  $datetime->withTimeZone($tz);
132  }

◆ test_withMaxValue()

DateTimeInputTest::test_withMaxValue ( )

Definition at line 89 of file DateTimeInputTest.php.

90  {
91  $dat = new \DateTimeImmutable('2019-01-09');
92  $datetime = $this->factory->datetime('label', 'byline')
93  ->withMaxValue($dat);
94 
95  $this->assertEquals(
96  $dat,
97  $datetime->getMaxValue()
98  );
99  }

◆ test_withMinValue()

DateTimeInputTest::test_withMinValue ( )

Definition at line 77 of file DateTimeInputTest.php.

78  {
79  $dat = new \DateTimeImmutable('2019-01-09');
80  $datetime = $this->factory->datetime('label', 'byline')
81  ->withMinValue($dat);
82 
83  $this->assertEquals(
84  $dat,
85  $datetime->getMinValue()
86  );
87  }

◆ test_withTimeOnly()

DateTimeInputTest::test_withTimeOnly ( )

Definition at line 108 of file DateTimeInputTest.php.

109  {
110  $datetime = $this->factory->datetime('label', 'byline');
111  $this->assertFalse($datetime->getTimeOnly());
112  $this->assertTrue($datetime->withTimeOnly(true)->getTimeOnly());
113  }

◆ test_withTimeZone()

DateTimeInputTest::test_withTimeZone ( )

Definition at line 115 of file DateTimeInputTest.php.

116  {
117  $datetime = $this->factory->datetime('label', 'byline');
118  $this->assertNull($datetime->getTimeZone());
119  $tz = 'Europe/Moscow';
120  $this->assertEquals(
121  $tz,
122  $datetime->withTimeZone($tz)->getTimeZone()
123  );
124  }

◆ test_withUseTime()

DateTimeInputTest::test_withUseTime ( )

Definition at line 101 of file DateTimeInputTest.php.

102  {
103  $datetime = $this->factory->datetime('label', 'byline');
104  $this->assertFalse($datetime->getUseTime());
105  $this->assertTrue($datetime->withUseTime(true)->getUseTime());
106  }

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