Testcase for timezone transformation.
More...
Testcase for timezone transformation.
Definition at line 12 of file ChangeTimezoneTest.php.
◆ setUp()
ChangeTimezoneTest::setUp |
( |
| ) |
|
|
protected |
◆ testApplyToFail()
ChangeTimezoneTest::testApplyToFail |
( |
| ) |
|
Definition at line 89 of file ChangeTimezoneTest.php.
90 {
91 $trans = $this->dt->changeTimezone('Europe/London');
92 $df = new \ILIAS\Data\Factory();
93 $ok = $df->ok(
'not_a_date');
94
96 $this->assertTrue(
$result->isError());
97 }
References $ok, and $result.
◆ testApplyToOK()
ChangeTimezoneTest::testApplyToOK |
( |
| ) |
|
Definition at line 74 of file ChangeTimezoneTest.php.
75 {
76 $trans = $this->dt->changeTimezone('Europe/London');
77 $value = '2019/05/26';
78 $origin = new \DateTimeImmutable($value);
79 $expected = new \DateTimeImmutable($value, new \DateTimeZone('Europe/London'));
80
81 $df = new \ILIAS\Data\Factory();
82 $ok = $df->ok($origin);
83
85 $this->assertEquals($expected,
$result->value());
86 $this->assertFalse(
$result->isError());
87 }
References $ok, and $result.
◆ testInvalidTransform()
ChangeTimezoneTest::testInvalidTransform |
( |
| ) |
|
Definition at line 56 of file ChangeTimezoneTest.php.
57 {
58 $this->expectException(\InvalidArgumentException::class);
59 $trans = $this->dt->changeTimezone('Europe/Berlin');
60 $trans->transform('erroneous');
61 }
◆ testInvoke()
ChangeTimezoneTest::testInvoke |
( |
| ) |
|
Definition at line 63 of file ChangeTimezoneTest.php.
64 {
65 $dat = '2019/05/26 16:05:22';
66 $origin_tz = 'Europe/Berlin';
67 $target_tz = 'Europe/London';
68 $origin = new \DateTimeImmutable($dat, new \DateTimeZone($origin_tz));
69 $expected = new \DateTimeImmutable($dat, new \DateTimeZone($target_tz));
70 $trans = $this->dt->changeTimezone($target_tz);
71 $this->assertEquals($expected, $trans($origin));
72 }
◆ testNullTransform()
ChangeTimezoneTest::testNullTransform |
( |
| ) |
|
Definition at line 49 of file ChangeTimezoneTest.php.
50 {
51 $trans = $this->dt->changeTimezone('Europe/Berlin');
52 $this->expectException(\InvalidArgumentException::class);
53 $trans->transform(null);
54 }
◆ testTransform()
ChangeTimezoneTest::testTransform |
( |
| ) |
|
Definition at line 21 of file ChangeTimezoneTest.php.
22 {
23 $dat = '2019-05-26 13:15:01';
24 $origin_tz = 'Europe/Berlin';
25 $target_tz = 'Europe/London';
26 $origin = new \DateTimeImmutable($dat, new \DateTimeZone($origin_tz));
27 $expected = new \DateTimeImmutable($dat, new \DateTimeZone($target_tz));
28 $trans = $this->dt->changeTimezone($target_tz);
29
30 $this->assertEquals(
31 $expected,
32 $trans->transform($origin)
33 );
34 }
◆ testTransformValues()
ChangeTimezoneTest::testTransformValues |
( |
| ) |
|
Definition at line 36 of file ChangeTimezoneTest.php.
37 {
38 $dat = '2019-05-26 13:15:01';
39 $origin_tz = 'Europe/Berlin';
40 $target_tz = 'America/El_Salvador';
41 $origin = new \DateTimeImmutable($dat, new \DateTimeZone($origin_tz));
42 $trans = $this->dt->changeTimezone($target_tz);
43 $this->assertEquals(
44 $dat,
45 date_format($trans->transform($origin), 'Y-m-d H:i:s')
46 );
47 }
The documentation for this class was generated from the following file: