Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/11/2015 07:48:42 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Core: Update tests for bp_format_time:

  • Include 2 new tests without localization, useful for maintaining sanity.
  • Update 2 existing tests to include WordPress core default options.
  • Update timezone_string test time to look for "2:00 pm" (as it is theoretically DST aware) though there is likely more to test here.

See #2693.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/core/functions.php

    r9608 r9616  
    191191     * @group bp_format_time
    192192     */
    193     public function test_bp_format_time_gmt_offset() {
     193    public function test_bp_format_time_gmt_offset_no_timezone_string() {
    194194        $time          = 1395169200;
    195195        $gmt_offset    = '-6';
     
    200200        update_option( 'time_format', 'g:i a' );
    201201        update_option( 'gmt_offset', $gmt_offset );
    202         delete_option( 'timezone_string' );
     202        update_option( 'timezone_string', '' );
    203203
    204204        $this->assertEquals( 'March 18, 2014 at 1:00 pm', bp_format_time( $time, $just_date, $localize_time ) );
     
    208208     * @group bp_format_time
    209209     */
    210     public function test_bp_format_time_timezone_string() {
     210    public function test_bp_format_time_timezone_string_no_gmt_offset() {
    211211        $time           = 1395169200;
    212212        $timzone_string = 'America/Chicago';
     
    217217        update_option( 'time_format', 'g:i a' );
    218218        update_option( 'timezone_string', $timzone_string );
    219         delete_option( 'gmt_offset' );
    220 
    221         $this->assertEquals( 'March 18, 2014 at 1:00 pm', bp_format_time( $time, $just_date, $localize_time ) );
     219        update_option( 'gmt_offset', '0' );
     220
     221        $this->assertEquals( 'March 18, 2014 at 2:00 pm', bp_format_time( $time, $just_date, $localize_time ) );
     222    }
     223
     224    /**
     225     * @group bp_format_time
     226     */
     227    public function test_bp_format_time_gmt_offset_no_localize() {
     228        $time          = 1395169200;
     229        $gmt_offset    = '-6';
     230        $just_date     = false;
     231        $localize_time = false;
     232
     233        update_option( 'date_format', 'F j, Y' );
     234        update_option( 'time_format', 'g:i a' );
     235        update_option( 'gmt_offset', $gmt_offset );
     236        update_option( 'timezone_string', '' );
     237
     238        $this->assertEquals( 'March 18, 2014 at 7:00 pm', bp_format_time( $time, $just_date, $localize_time ) );
     239    }
     240
     241    /**
     242     * @group bp_format_time
     243     */
     244    public function test_bp_format_time_timezone_string_no_localize() {
     245        $time           = 1395169200;
     246        $timzone_string = 'America/Chicago';
     247        $just_date      = false;
     248        $localize_time  = false;
     249
     250        update_option( 'date_format', 'F j, Y' );
     251        update_option( 'time_format', 'g:i a' );
     252        update_option( 'timezone_string', $timzone_string );
     253        update_option( 'gmt_offset', '0' );
     254
     255        $this->assertEquals( 'March 18, 2014 at 7:00 pm', bp_format_time( $time, $just_date, $localize_time ) );
    222256    }
    223257
Note: See TracChangeset for help on using the changeset viewer.