summaryrefslogtreecommitdiffstatshomepage
path: root/tests
diff options
context:
space:
mode:
authorJohn Blackbourn <johnbillion@git.wordpress.org>2025-03-04 14:56:14 +0000
committerJohn Blackbourn <johnbillion@git.wordpress.org>2025-03-04 14:56:14 +0000
commitdc21f5b889117deb63d358bd173b2237a8d9e5d2 (patch)
treeb07f0ba6ca716fc46e44d01aa19ed12007ed80e0 /tests
parent87953e10e4b0293d8fe4512da76c591a7fdc089c (diff)
downloadwordpress-dc21f5b889117deb63d358bd173b2237a8d9e5d2.tar.gz
wordpress-dc21f5b889117deb63d358bd173b2237a8d9e5d2.zip
Date/Time: Add tests that cover the `wp_timezone_override_offset()` function.
Props pbearne, audrasjb Fixes #59980 git-svn-id: https://develop.svn.wordpress.org/trunk@59931 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'tests')
-rw-r--r--tests/phpunit/tests/functions/wpTimezoneOverrideOffset.php53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/phpunit/tests/functions/wpTimezoneOverrideOffset.php b/tests/phpunit/tests/functions/wpTimezoneOverrideOffset.php
new file mode 100644
index 0000000000..3b92e8c6fe
--- /dev/null
+++ b/tests/phpunit/tests/functions/wpTimezoneOverrideOffset.php
@@ -0,0 +1,53 @@
+<?php
+
+/**
+ * Tests for the wp_timezone_override_offset function.
+ *
+ * @group Functions.php
+ *
+ * @covers ::wp_timezone_override_offset
+ */
+class Tests_Functions_wpTimezoneOverrideOffset extends WP_UnitTestCase {
+ /**
+ * @ticket 59980
+ */
+ public function test_wp_timezone_override_offset_with_no_timezone_string_option_set() {
+ $this->assertSame( '', get_option( 'timezone_string' ) );
+ $this->assertFalse( wp_timezone_override_offset() );
+ }
+
+ /**
+ * @ticket 59980
+ */
+ public function test_wp_timezone_override_offset_with_bad_option_set() {
+ update_option( 'timezone_string', 'BAD_TIME_ZONE' );
+ $this->assertFalse( wp_timezone_override_offset() );
+ }
+
+ /**
+ * @ticket 59980
+ */
+ public function test_wp_timezone_override_offset_with_UTC_option_set() {
+ update_option( 'timezone_string', 'UTC' );
+ $offset = wp_timezone_override_offset();
+ $this->assertSame( 0.0, $offset );
+ }
+
+ /**
+ * @ticket 59980
+ */
+ public function test_wp_timezone_override_offset_with_EST_option_set() {
+ update_option( 'timezone_string', 'EST' );
+ $offset = wp_timezone_override_offset();
+ $this->assertSame( -5.0, $offset );
+ }
+
+ /**
+ * @ticket 59980
+ */
+ public function test_wp_timezone_override_offset_with_NST_option_set() {
+ update_option( 'timezone_string', 'America/St_Johns' );
+ $offset = wp_timezone_override_offset();
+ $this->assertSame( -3.5, $offset );
+ }
+}