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.
References $ok, and $result.
91 $trans = $this->dt->changeTimezone(
'Europe/London');
92 $df = new \ILIAS\Data\Factory();
93 $ok = $df->ok(
'not_a_date');
96 $this->assertTrue(
$result->isError());
◆ testApplyToOK()
ChangeTimezoneTest::testApplyToOK |
( |
| ) |
|
Definition at line 74 of file ChangeTimezoneTest.php.
References $ok, and $result.
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'));
81 $df = new \ILIAS\Data\Factory();
82 $ok = $df->ok($origin);
85 $this->assertEquals($expected,
$result->value());
86 $this->assertFalse(
$result->isError());
◆ testInvalidTransform()
ChangeTimezoneTest::testInvalidTransform |
( |
| ) |
|
Definition at line 56 of file ChangeTimezoneTest.php.
58 $this->expectException(\InvalidArgumentException::class);
59 $trans = $this->dt->changeTimezone(
'Europe/Berlin');
60 $trans->transform(
'erroneous');
◆ testInvoke()
ChangeTimezoneTest::testInvoke |
( |
| ) |
|
Definition at line 63 of file ChangeTimezoneTest.php.
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));
◆ testNullTransform()
ChangeTimezoneTest::testNullTransform |
( |
| ) |
|
Definition at line 49 of file ChangeTimezoneTest.php.
51 $trans = $this->dt->changeTimezone(
'Europe/Berlin');
52 $this->expectException(\InvalidArgumentException::class);
53 $trans->transform(null);
◆ testTransform()
ChangeTimezoneTest::testTransform |
( |
| ) |
|
Definition at line 21 of file ChangeTimezoneTest.php.
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);
32 $trans->transform($origin)
◆ testTransformValues()
ChangeTimezoneTest::testTransformValues |
( |
| ) |
|
Definition at line 36 of file ChangeTimezoneTest.php.
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);
45 date_format($trans->transform($origin),
'Y-m-d H:i:s')
The documentation for this class was generated from the following file: