Definition at line 25 of file ChangeTimezoneTest.php.
◆ setUp()
ChangeTimezoneTest::setUp |
( |
| ) |
|
|
protected |
◆ testApplyToFail()
ChangeTimezoneTest::testApplyToFail |
( |
| ) |
|
Definition at line 102 of file ChangeTimezoneTest.php.
102 : void
103 {
104 $trans = $this->dt->changeTimezone('Europe/London');
105 $df = new DataFactory();
106 $ok = $df->ok('not_a_date');
107
108 $result = $trans->applyTo($ok);
109 $this->assertTrue($result->isError());
110 }
◆ testApplyToOK()
ChangeTimezoneTest::testApplyToOK |
( |
| ) |
|
Definition at line 87 of file ChangeTimezoneTest.php.
87 : void
88 {
89 $trans = $this->dt->changeTimezone('Europe/London');
90 $value = '2019/05/26';
91 $origin = new DateTimeImmutable($value);
92 $expected = new DateTimeImmutable($value, new DateTimeZone('Europe/London'));
93
94 $df = new DataFactory();
95 $ok = $df->ok($origin);
96
97 $result = $trans->applyTo($ok);
98 $this->assertEquals($expected, $result->value());
99 $this->assertFalse($result->isError());
100 }
◆ testInvalidTransform()
ChangeTimezoneTest::testInvalidTransform |
( |
| ) |
|
Definition at line 69 of file ChangeTimezoneTest.php.
69 : void
70 {
71 $this->expectException(InvalidArgumentException::class);
72 $trans = $this->dt->changeTimezone('Europe/Berlin');
73 $trans->transform('erroneous');
74 }
◆ testInvoke()
ChangeTimezoneTest::testInvoke |
( |
| ) |
|
Definition at line 76 of file ChangeTimezoneTest.php.
76 : void
77 {
78 $dat = '2019/05/26 16:05:22';
79 $origin_tz = 'Europe/Berlin';
80 $target_tz = 'Europe/London';
81 $origin = new DateTimeImmutable($dat, new DateTimeZone($origin_tz));
82 $expected = new DateTimeImmutable($dat, new DateTimeZone($target_tz));
83 $trans = $this->dt->changeTimezone($target_tz);
84 $this->assertEquals($expected, $trans($origin));
85 }
◆ testNullTransform()
ChangeTimezoneTest::testNullTransform |
( |
| ) |
|
Definition at line 62 of file ChangeTimezoneTest.php.
62 : void
63 {
64 $trans = $this->dt->changeTimezone('Europe/Berlin');
65 $this->expectException(InvalidArgumentException::class);
66 $trans->transform(null);
67 }
◆ testTransform()
ChangeTimezoneTest::testTransform |
( |
| ) |
|
Definition at line 34 of file ChangeTimezoneTest.php.
34 : void
35 {
36 $dat = '2019-05-26 13:15:01';
37 $origin_tz = 'Europe/Berlin';
38 $target_tz = 'Europe/London';
39 $origin = new DateTimeImmutable($dat, new DateTimeZone($origin_tz));
40 $expected = new DateTimeImmutable($dat, new DateTimeZone($target_tz));
41 $trans = $this->dt->changeTimezone($target_tz);
42
43 $this->assertEquals(
44 $expected,
45 $trans->transform($origin)
46 );
47 }
◆ testTransformValues()
ChangeTimezoneTest::testTransformValues |
( |
| ) |
|
Definition at line 49 of file ChangeTimezoneTest.php.
49 : void
50 {
51 $dat = '2019-05-26 13:15:01';
52 $origin_tz = 'Europe/Berlin';
53 $target_tz = 'America/El_Salvador';
54 $origin = new DateTimeImmutable($dat, new DateTimeZone($origin_tz));
55 $trans = $this->dt->changeTimezone($target_tz);
56 $this->assertEquals(
57 $dat,
58 date_format($trans->transform($origin), 'Y-m-d H:i:s')
59 );
60 }
◆ $dt
DateTime Group ChangeTimezoneTest::$dt |
|
private |
The documentation for this class was generated from the following file: