Fix #5: ion\Timestamp crashes with string timezones
[awesomized/ext-ion] / tests / Timestamp / stringTZ.phpt
diff --git a/tests/Timestamp/stringTZ.phpt b/tests/Timestamp/stringTZ.phpt
new file mode 100644 (file)
index 0000000..a7f5c9b
--- /dev/null
@@ -0,0 +1,31 @@
+--TEST--
+ion\Timestamp with TZ as string
+--EXTENSIONS--
+ion
+--INI--
+date.timezone=UTC
+--FILE--
+TEST
+<?php
+$ts = new ion\Timestamp(
+       precision: ion\Timestamp\Precision::MinTZ,
+       format: \ion\Timestamp\Format::Min,
+       datetime: "2022-02-28T11:40",
+       timezone: "Europe/Madrid",
+);
+var_dump($ts->getTimezone());
+echo $ts, "\n";
+echo $ts->setTimezone(new DateTimeZone(("America/Toronto"))), "\n";
+?>
+DONE
+--EXPECTF--
+TEST
+object(DateTimeZone)#%d (2) {
+  ["timezone_type"]=>
+  int(3)
+  ["timezone"]=>
+  string(13) "Europe/Madrid"
+}
+2022-02-28T11:40+01:00
+2022-02-28T05:40-05:00
+DONE