WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/29/2015 04:04:16 AM (5 years ago)
Author:
wonderboymusic
Message:

XML-RPC: calculate the proper offset for GMT in wp.newPost, mw.newPost, and mw.editPost when post_date is set, wp.editComment when comment_date is set. post|comment_date is assumed to be GMT. This is only true if the timezone string for the site matches GMT.

Adds unit tests for each.

Props smerriman, justdaiv, wonderboymusic.
Fixes #30429.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/xmlrpc/wp/newPost.php

    r29063 r34681  
    384384    }
    385385
     386    /**
     387     * @ticket 30429
     388     */
     389    function test_post_date_timezone_conversion() {
     390        $tz = get_option( 'timezone_string' );
     391        update_option( 'timezone_string', 'America/New_York' );
     392
     393        $this->make_user_by_role( 'author' );
     394        $date_string = '1984-01-11 05:00:00';
     395        $post = array( 'post_title' => 'test', 'post_content' => 'test', 'post_date' => $date_string );
     396        $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) );
     397        $fetched_post = get_post( $result );
     398
     399        update_option( 'timezone_string', $tz );
     400
     401        $this->assertStringMatchesFormat( '%d', $result );
     402        $this->assertEquals( $date_string , $fetched_post->post_date );
     403    }
    386404}
Note: See TracChangeset for help on using the changeset viewer.