Make WordPress Core


Ignore:
Timestamp:
04/12/2017 02:58:33 PM (10 years ago)
Author:
johnbillion
Message:

Build/Test tools: Introduce and implement assertNotIXRError() and assertIXRError() assertion methods.

This aids in debugging XMLRPC tests which fail, by exposing the IXR_Error error message in the assertion failure message.

Fixes #40423

File:
1 edited

Legend:

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

    r38382 r40417  
    88        function test_invalid_username_password() {
    99                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'username', 'password', array() ) );
    10                 $this->assertInstanceOf( 'IXR_Error', $result );
     10                $this->assertIXRError( $result );
    1111                $this->assertEquals( 403, $result->code );
    1212        }
    … …  
    1616
    1717                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'subscriber', 'subscriber', array() ) );
    18                 $this->assertInstanceOf( 'IXR_Error', $result );
     18                $this->assertIXRError( $result );
    1919                $this->assertEquals( 401, $result->code );
    2020        }
    … …  
    2424
    2525                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', array() ) );
    26                 $this->assertInstanceOf( 'IXR_Error', $result );
     26                $this->assertIXRError( $result );
    2727                $this->assertEquals( 500, $result->code );
    2828                $this->assertEquals( 'Content, title, and excerpt are empty.', $result->message );
    … …  
    3434                $post = array( 'post_title' => 'Test' );
    3535                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) );
    36                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     36                $this->assertNotIXRError( $result );
    3737                $this->assertStringMatchesFormat( '%d', $result );
    3838        }
    … …  
    4343                $post = array( 'post_title' => 'Test', 'ID' => 103948 );
    4444                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) );
    45                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     45                $this->assertNotIXRError( $result );
    4646                $this->assertNotEquals( '103948', $result );
    4747        }
    … …  
    5252                $post = array( 'post_title' => 'Test', 'post_status' => 'publish' );
    5353                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) );
    54                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     54                $this->assertNotIXRError( $result );
    5555        }
    5656
    … …  
    6060                $post = array( 'post_title' => 'Test', 'post_status' => 'publish' );
    6161                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'contributor', 'contributor', $post ) );
    62                 $this->assertInstanceOf( 'IXR_Error', $result );
     62                $this->assertIXRError( $result );
    6363                $this->assertEquals( 401, $result->code );
    6464        }
    … …  
    6969                $post = array( 'post_title' => 'Test', 'post_status' => 'private' );
    7070                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
    71                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     71                $this->assertNotIXRError( $result );
    7272        }
    7373
    … …  
    7777                $post = array( 'post_title' => 'Test', 'post_status' => 'private' );
    7878                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'contributor', 'contributor', $post ) );
    79                 $this->assertInstanceOf( 'IXR_Error', $result );
     79                $this->assertIXRError( $result );
    8080                $this->assertEquals( 401, $result->code );
    8181        }
    … …  
    8787                $post = array( 'post_title' => 'Test', 'post_author' => $other_author_id );
    8888                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
    89                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     89                $this->assertNotIXRError( $result );
    9090        }
    9191
    … …  
    9696                $post = array( 'post_title' => 'Test', 'post_author' => $other_author_id );
    9797                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'contributor', 'contributor', $post ) );
    98                 $this->assertInstanceOf( 'IXR_Error', $result );
     98                $this->assertIXRError( $result );
    9999                $this->assertEquals( 401, $result->code );
    100100        }
    … …  
    105105                $post = array( 'post_title' => 'Test', 'post_author' => 99999999 );
    106106                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
    107                 $this->assertInstanceOf( 'IXR_Error', $result );
     107                $this->assertIXRError( $result );
    108108                $this->assertEquals( 404, $result->code );
    109109        }
    … …  
    114114                $post = array( 'post_title' => 'Test' );
    115115                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) );
    116                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     116                $this->assertNotIXRError( $result );
    117117                $this->assertStringMatchesFormat( '%d', $result );
    118118
    … …  
    133133                $post = array( 'post_title' => 'Post Thumbnail Test', 'post_thumbnail' => $attachment_id );
    134134                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) );
    135                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     135                $this->assertNotIXRError( $result );
    136136                $this->assertEquals( $attachment_id, get_post_meta( $result, '_thumbnail_id', true ) );
    137137
    … …  
    144144                $post = array( 'post_title' => 'Test', 'post_status' => 'foobar_status' );
    145145                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) );
    146                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     146                $this->assertNotIXRError( $result );
    147147                $this->assertEquals( 'draft', get_post_status( $result ) );
    148148        }
    … …  
    153153                $post = array( 'post_title' => 'Test', 'sticky' => true );
    154154                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'contributor', 'contributor', $post ) );
    155                 $this->assertInstanceOf( 'IXR_Error', $result );
     155                $this->assertIXRError( $result );
    156156                $this->assertEquals( 401, $result->code );
    157157        }
    … …  
    162162                $post = array( 'post_title' => 'Test', 'sticky' => true );
    163163                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
    164                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     164                $this->assertNotIXRError( $result );
    165165                $this->assertTrue( is_sticky( $result ) );
    166166        }
    … …  
    171171                $post = array( 'post_title' => 'Test', 'post_status' => 'private', 'sticky' => true );
    172172                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
    173                 $this->assertInstanceOf( 'IXR_Error', $result );
     173                $this->assertIXRError( $result );
    174174                $this->assertEquals( 401, $result->code );
    175175        }
    … …  
    180180                $post = array( 'post_title' => 'Test', 'post_format' => 'quote' );
    181181                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
    182                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     182                $this->assertNotIXRError( $result );
    183183                $this->assertEquals( 'quote', get_post_format( $result ) );
    184184        }
    … …  
    189189                $post = array( 'post_title' => 'Test', 'post_format' => 'tumblr' );
    190190                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
    191                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     191                $this->assertNotIXRError( $result );
    192192                $this->assertEquals( '', get_post_format( $result ) );
    193193        }
    … …  
    203203                );
    204204                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
    205                 $this->assertInstanceOf( 'IXR_Error', $result );
     205                $this->assertIXRError( $result );
    206206                $this->assertEquals( 401, $result->code );
    207207
    … …  
    213213                );
    214214                $result2 = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post2 ) );
    215                 $this->assertInstanceOf( 'IXR_Error', $result2 );
     215                $this->assertIXRError( $result2 );
    216216                $this->assertEquals( 401, $result2->code );
    217217        }
    … …  
    227227                );
    228228                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
    229                 $this->assertInstanceOf( 'IXR_Error', $result );
     229                $this->assertIXRError( $result );
    230230                $this->assertEquals( 403, $result->code );
    231231        }
    … …  
    248248                );
    249249                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
    250                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     250                $this->assertNotIXRError( $result );
    251251
    252252                $post_tags = wp_get_object_terms( $result, 'post_tag', array( 'fields' => 'ids' ) );
    … …  
    275275                );
    276276                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
    277                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     277                $this->assertNotIXRError( $result );
    278278                // verify that cat2 was created
    279279                $cat2 = get_term_by( 'name', $cat2_name, 'category' );
    … …  
    292292                );
    293293                $result2 = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post2 ) );
    294                 $this->assertInstanceOf( 'IXR_Error', $result2 );
     294                $this->assertIXRError( $result2 );
    295295                $this->assertEquals( 401, $result2->code );
    296296        }
Note: See TracChangeset for help on using the changeset viewer.