Make WordPress Core

Ticket #28601: unit-test-xmlrpc-wp_newPost.patch

File unit-test-xmlrpc-wp_newPost.patch, 1.3 KB (added by dllh, 11 years ago)

Unit tests to demonstrate the issue

  • tests/phpunit/tests/xmlrpc/wp/newPost.php

     
    55 */
    66class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
    77
     8        function test_invalid_post_date_does_not_fatal() {
     9                $this->make_user_by_role( 'author' );
     10                $date_string = '2014-01-01 10:10:10';
     11                $post = array( 'post_title' => 'test', 'post_content' => 'test', 'post_date' => $date_string );
     12                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) );
     13                $fetched_post = get_post( $result );
     14                $this->assertStringMatchesFormat( '%d', $result );
     15        }
     16
     17        function test_invalid_post_date_gmt_does_not_fatal() {
     18                $this->make_user_by_role( 'author' );
     19                $date_string = 'invalid date';
     20                $post = array( 'post_title' => 'test', 'post_content' => 'test', 'post_date_gmt' => $date_string );
     21                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) );
     22                $fetched_post = get_post( $result );
     23                $this->assertStringMatchesFormat( '%d', $result );
     24        }
     25
    826        function test_invalid_username_password() {
    927                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'username', 'password', array() ) );
    1028                $this->assertInstanceOf( 'IXR_Error', $result );