WordPress.org

Make WordPress Core

Ticket #48384: 48384.diff

File 48384.diff, 970 bytes (added by david.binda, 2 years ago)
  • tests/phpunit/tests/post.php

     
    14301430                $post = get_post( $post_id );
    14311431                self::assertEquals( strtotime( gmdate( 'Y-m-d H:i:s' ) ), strtotime( $post->post_date_gmt ), 'The dates should be equal', 2 );
    14321432        }
     1433
     1434        /**
     1435         * @ticket
     1436         */
     1437        function test_get_post_time_with_id_returns_correct_time_after_timezone_change() {
     1438                // Make sure WordPress is set to UTC+0 and create a new post.
     1439                update_option( 'gmt_offset', 0 );
     1440                $post_id = self::factory()->post->create( array( 'post_date' => '2019-10-21 11:20:58' ) );
     1441               
     1442                // Change the timezine to UTC+2
     1443                update_option( 'gmt_offset', 2 );
     1444               
     1445                // Attempt to obtain the GMT post date (should be identical with the original post_date set above).
     1446                $this->assertEquals( '11:20:58', get_post_time( 'H:i:s', true, $post_id ) );
     1447        }
    14331448}