@@ -104,7 +104,7 @@ public function test_DateTime_constructor_with_absolute_mocked_date()
104104 /**
105105 * @see https://github.com/slope-it/clock-mock/issues/26
106106 */
107- public function test_DateTime_constructor_with_absolute_date_and_timezone ()
107+ public function test_DateTime_constructor_with_absolute_date_and_canonical_timezone ()
108108 {
109109 // The mocked date, either aboslute or relative, is irrelevant for this test. Having a mocked date is enough.
110110 ClockMock::freeze (new \DateTime ('now ' ));
@@ -119,6 +119,25 @@ public function test_DateTime_constructor_with_absolute_date_and_timezone()
119119 $ this ->assertSame ('1986-06-05 12:13:14 ' , $ absoluteDateTimeWithTimezone ->format ('Y-m-d H:i:s ' ));
120120 }
121121
122+ /**
123+ * @see https://github.com/slope-it/clock-mock/issues/37
124+ * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
125+ */
126+ public function test_DateTime_constructor_with_absolute_date_and_non_canonical_timezone ()
127+ {
128+ // The mocked date, either aboslute or relative, is irrelevant for this test. Having a mocked date is enough.
129+ ClockMock::freeze (new \DateTime ('now ' ));
130+
131+ $ absoluteDateTimeWithTimezone = new \DateTime (
132+ '1986-06-05 12:13:14 ' ,
133+ $ usEasternTimezone = new \DateTimeZone ('US/Eastern ' )
134+ );
135+
136+ // Verification: when date is absolute and timezone is specified, the mocked clock should have no effect.
137+ $ this ->assertEquals ($ usEasternTimezone , $ absoluteDateTimeWithTimezone ->getTimezone ());
138+ $ this ->assertSame ('1986-06-05 12:13:14 ' , $ absoluteDateTimeWithTimezone ->format ('Y-m-d H:i:s ' ));
139+ }
140+
122141 /**
123142 * @see https://github.com/slope-it/clock-mock/issues/31
124143 */
0 commit comments