Skip to content

Commit

Permalink
added test for wp_timezone_override_offset
Browse files Browse the repository at this point in the history
  • Loading branch information
pbearne committed Nov 28, 2023
1 parent a21f5a3 commit 7e6387f
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/phpunit/tests/functions/wpTimezoneOverrideOffset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

/**
* Tests for the wp_timezone_override_offset function.
*
* @group Functions.php
*
* @covers ::wp_timezone_override_offset
*/
class Tests_Functions_wpTimezoneOverrideOffset extends WP_UnitTestCase {

public function tear_down() {
delete_option( 'timezone_string' );
parent::tear_down();
}

/**
* @ticket 59980
*/
public function test_wp_timezone_override_offset() {
$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_EST_option_set() {
update_option( 'timezone_string', 'EST' );
$offset = wp_timezone_override_offset();
$this->assertIsFloat( $offset );
$this->assertEquals( -5, $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->assertIsFloat( $offset );
$this->assertEquals( -3.5, $offset );
}
}

0 comments on commit 7e6387f

Please sign in to comment.