ILIAS  release_8 Revision v8.24
DateFormatTest Class Reference
+ Inheritance diagram for DateFormatTest:
+ Collaboration diagram for DateFormatTest:

Public Member Functions

 setUp ()
 
 testDateFormatFactory ()
 
 testDateFormatBuilderAndGetters ()
 
 testDateFormatInvalidTokens ()
 
 testDateFormatApplyTo ()
 
 testDateFormatApplyToWithTime ()
 
 testDateFormatExpand ()
 

Detailed Description

Definition at line 25 of file DateFormatTest.php.

Member Function Documentation

◆ setUp()

DateFormatTest::setUp ( )

Definition at line 27 of file DateFormatTest.php.

27 : void
28 {
29 $f = new ILIAS\Data\Factory();
30 $this->df = $f->dateFormat();
31 }
Builds data types.
Definition: Factory.php:21

References Vendor\Package\$f.

◆ testDateFormatApplyTo()

DateFormatTest::testDateFormatApplyTo ( )

Definition at line 76 of file DateFormatTest.php.

76 : void
77 {
78 $dt = new DateTimeImmutable("1985-04-05");
79 $format = $this->df->germanShort();
80 $this->assertEquals("05.04.1985", $format->applyTo($dt));
81 $this->assertEquals("05.04.1985", $dt->format((string) $format));
82 }
$format
Definition: metadata.php:235

References $format.

◆ testDateFormatApplyToWithTime()

DateFormatTest::testDateFormatApplyToWithTime ( )

Definition at line 84 of file DateFormatTest.php.

84 : void
85 {
86 $dt = new DateTimeImmutable("1985-04-05 21:12:30");
87 $format = $this->df->custom()
88 ->day()->dot()->month()->dot()->year()
89 ->space()->hours12()->colon()->minutes()->space()->meridiem()
90 ->get();
91 $this->assertEquals("05.04.1985 09:12 pm", $format->applyTo($dt));
92 $this->assertEquals("05.04.1985 09:12 pm", $dt->format((string) $format));
93 $format = $this->df->custom()
94 ->day()->dot()->month()->dot()->year()
95 ->space()->hours24()->colon()->minutes()->colon()->seconds()
96 ->get();
97 $this->assertEquals("05.04.1985 21:12:30", $format->applyTo($dt));
98 }

References $format.

◆ testDateFormatBuilderAndGetters()

DateFormatTest::testDateFormatBuilderAndGetters ( )

Definition at line 41 of file DateFormatTest.php.

41 : void
42 {
43 $expect = [
44 '.', ',', '-', '/', ' ', ':', 'd', 'jS', 'l', 'D', 'W', 'm', 'F', 'M', 'Y', 'y', 'h','H', 'i', 's', 'a'
45 ];
46 $format = $this->df->custom()
47 ->dot()->comma()->dash()->slash()->space()->colon()
48 ->day()->dayOrdinal()->weekday()->weekdayShort()
49 ->week()->month()->monthSpelled()->monthSpelledShort()
50 ->year()->twoDigitYear()
51 ->hours12()->hours24()->minutes()->seconds()->meridiem()
52 ->get();
53
54 $this->assertEquals(
55 $expect,
56 $format->toArray()
57 );
58
59 $this->assertEquals(
60 implode('', $expect),
61 $format->toString()
62 );
63
64 $this->assertEquals(
65 $format->toString(),
66 (string) $format
67 );
68 }

References $format.

◆ testDateFormatExpand()

DateFormatTest::testDateFormatExpand ( )

Definition at line 100 of file DateFormatTest.php.

100 : void
101 {
102 $format = $this->df->germanShort();
103 $appended = $this->df->amend($format)->dot()->dot()->get();
104 $this->assertInstanceOf(DateFormat\DateFormat::class, $appended);
105 $this->assertEquals(
106 array_merge($format->toArray(), ['.', '.']),
107 $appended->toArray()
108 );
109 }
A Date Format provides a format definition akin to PHP's date formatting options, but stores the sing...
Definition: DateFormat.php:27

References $format.

◆ testDateFormatFactory()

DateFormatTest::testDateFormatFactory ( )

Definition at line 33 of file DateFormatTest.php.

33 : void
34 {
35 $this->assertInstanceOf(DateFormat\DateFormat::class, $this->df->standard());
36 $this->assertInstanceOf(DateFormat\DateFormat::class, $this->df->germanShort());
37 $this->assertInstanceOf(DateFormat\DateFormat::class, $this->df->germanLong());
38 $this->assertInstanceOf(DateFormat\FormatBuilder::class, $this->df->custom());
39 }

◆ testDateFormatInvalidTokens()

DateFormatTest::testDateFormatInvalidTokens ( )

Definition at line 70 of file DateFormatTest.php.

70 : void
71 {
72 $this->expectException(InvalidArgumentException::class);
73 new DateFormat\DateFormat(['x', '2']);
74 }

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