ILIAS  release_7 Revision v7.30-3-g800a261c036
DurationInputTest Class Reference
+ Inheritance diagram for DurationInputTest:
+ Collaboration diagram for DurationInputTest:

Public Member Functions

 setUp ()
 
 getUIFactory ()
 
 test_withFormat ()
 
 test_withMinValue ()
 
 test_withMaxValue ()
 
 test_withUseTime ()
 
 test_withTimeOnly ()
 
 test_withTimeZone ()
 
 test_withInvalidTimeZone ()
 
 test_render ()
 
- 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

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

Detailed Description

Definition at line 16 of file DurationInputTest.php.

Member Function Documentation

◆ buildFactory()

DurationInputTest::buildFactory ( )
protected

Definition at line 38 of file DurationInputTest.php.

References buildLanguage(), and buildRefinery().

Referenced by setUp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildLanguage()

DurationInputTest::buildLanguage ( )
protected

Definition at line 25 of file DurationInputTest.php.

26 {
27 if (!isset($this->lng)) {
28 $this->lng = $this->createMock(\ilLanguage::class);
29 }
30 return $this->lng;
31 }
$lng

References $lng.

Referenced by buildFactory(), and buildRefinery().

+ Here is the caller graph for this function:

◆ buildRefinery()

DurationInputTest::buildRefinery ( )
protected

Definition at line 33 of file DurationInputTest.php.

34 {
35 return new \ILIAS\Refinery\Factory($this->data_factory, $this->buildLanguage());
36 }

References buildLanguage().

Referenced by buildFactory().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUIFactory()

DurationInputTest::getUIFactory ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 47 of file DurationInputTest.php.

48 {
49 $factory = new class extends NoUIFactory {
50 public function symbol() : \ILIAS\UI\Component\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 return $factory;
60 }
A component is the most general form of an entity in the UI.
Definition: Component.php:14
$factory
Definition: metadata.php:58
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.

References $factory.

◆ setUp()

DurationInputTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 18 of file DurationInputTest.php.

18 : void
19 {
20 $this->name_source = new DefNamesource();
21 $this->data_factory = new Data\Factory();
22 $this->factory = $this->buildFactory();
23 }

References buildFactory().

+ Here is the call graph for this function:

◆ test_render()

DurationInputTest::test_render ( )

Definition at line 131 of file DurationInputTest.php.

132 {
133 $datetime = $this->factory->duration('label', 'byline');
134 $r = $this->getDefaultRenderer();
135 $html = $this->brutallyTrimHTML($r->render($datetime));
136
137 $expected = $this->brutallyTrimHTML('
138<div class="form-group row">
139 <label for="id_1" class="control-label col-sm-3">label</label>
140 <div class="col-sm-9">
141 <div class="il-input-duration" id="id_1">
142 <div class="form-group row">
143 <label for="id_2" class="control-label col-sm-3">start</label>
144 <div class="col-sm-9">
145 <div class="input-group date il-input-datetime" id="id_2"><input type="text" name="" placeholder="YYYY-MM-DD" class="form-control form-control-sm" /><span class="input-group-addon"><a class="glyph" href="#" aria-label="calendar"><span class="glyphicon glyphicon-calendar" aria-hidden="true"></span></a></span></div>
146 </div>
147 </div>
148 <div class="form-group row">
149 <label for="id_3" class="control-label col-sm-3">end</label>
150 <div class="col-sm-9">
151 <div class="input-group date il-input-datetime" id="id_3"><input type="text" name="" placeholder="YYYY-MM-DD" class="form-control form-control-sm" /><span class="input-group-addon"><a class="glyph" href="#" aria-label="calendar"><span class="glyphicon glyphicon-calendar" aria-hidden="true"></span></a></span></div>
152 </div>
153 </div>
154 </div>
155 <div class="help-block">byline</div>
156 </div>
157</div>
158');
159 $this->assertEquals($expected, $html);
160 }
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392

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

+ Here is the call graph for this function:

◆ test_withFormat()

DurationInputTest::test_withFormat ( )

Definition at line 62 of file DurationInputTest.php.

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

References $format.

◆ test_withInvalidTimeZone()

DurationInputTest::test_withInvalidTimeZone ( )

Definition at line 123 of file DurationInputTest.php.

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

◆ test_withMaxValue()

DurationInputTest::test_withMaxValue ( )

Definition at line 86 of file DurationInputTest.php.

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

◆ test_withMinValue()

DurationInputTest::test_withMinValue ( )

Definition at line 74 of file DurationInputTest.php.

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

◆ test_withTimeOnly()

DurationInputTest::test_withTimeOnly ( )

Definition at line 105 of file DurationInputTest.php.

106 {
107 $datetime = $this->factory->duration('label', 'byline');
108 $this->assertFalse($datetime->getTimeOnly());
109 $this->assertTrue($datetime->withTimeOnly(true)->getTimeOnly());
110 }

◆ test_withTimeZone()

DurationInputTest::test_withTimeZone ( )

Definition at line 112 of file DurationInputTest.php.

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

◆ test_withUseTime()

DurationInputTest::test_withUseTime ( )

Definition at line 98 of file DurationInputTest.php.

99 {
100 $datetime = $this->factory->duration('label', 'byline');
101 $this->assertFalse($datetime->getUseTime());
102 $this->assertTrue($datetime->withUseTime(true)->getUseTime());
103 }

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