Make WordPress Core


Ignore:
Timestamp:
04/12/2017 02:58:33 PM (8 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/editPost.php

    r37044 r40417  
    88    function test_invalid_username_password() {
    99        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'username', 'password', 0, array() ) );
    10         $this->assertInstanceOf( 'IXR_Error', $result );
     10        $this->assertIXRError( $result );
    1111        $this->assertEquals( 403, $result->code );
    1212    }
     
    2121        $post2 = array( 'post_title' => $new_title );
    2222        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'contributor', 'contributor', $post_id, $post2 ) );
    23         $this->assertNotInstanceOf( 'IXR_Error', $result );
     23        $this->assertNotIXRError( $result );
    2424        $this->assertTrue($result);
    2525
     
    3838        $post2 = array( 'post_title' => $new_title );
    3939        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) );
    40         $this->assertNotInstanceOf( 'IXR_Error', $result );
     40        $this->assertNotIXRError( $result );
    4141        $this->assertTrue($result);
    4242
     
    5656        $post2 = array( 'post_title' => $new_title );
    5757        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'contributor', 'contributor', $post_id, $post2 ) );
    58         $this->assertInstanceOf( 'IXR_Error', $result );
     58        $this->assertIXRError( $result );
    5959        $this->assertEquals( 401, $result->code );
    6060
     
    7373        $post2 = array( 'post_author' => $author_id );
    7474        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) );
    75         $this->assertNotInstanceOf( 'IXR_Error', $result );
     75        $this->assertNotIXRError( $result );
    7676        $this->assertTrue($result);
    7777
     
    8989        $post2 = array( 'post_author' => $author_id );
    9090        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'contributor', 'contributor', $post_id, $post2 ) );
    91         $this->assertInstanceOf( 'IXR_Error', $result );
     91        $this->assertIXRError( $result );
    9292        $this->assertEquals( 401, $result->code );
    9393
     
    108108        $post2 = array( 'post_author' => $editor_id );
    109109        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) );
    110         $this->assertNotInstanceOf( 'IXR_Error', $result );
     110        $this->assertNotIXRError( $result );
    111111        $this->assertTrue($result);
    112112
     
    132132        $post2 = array( 'post_thumbnail' => $attachment_id );
    133133        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post2 ) );
    134         $this->assertNotInstanceOf( 'IXR_Error', $result );
     134        $this->assertNotIXRError( $result );
    135135        $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
    136136
    137137        // fetch the post to verify that it appears
    138138        $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'author', 'author', $post_id ) );
    139         $this->assertNotInstanceOf( 'IXR_Error', $result );
     139        $this->assertNotIXRError( $result );
    140140        $this->assertArrayHasKey( 'post_thumbnail', $result );
    141141        $this->assertInternalType( 'array', $result['post_thumbnail'] );
     
    145145        $post3 = array( 'post_content' => 'Updated post' );
    146146        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post3 ) );
    147         $this->assertNotInstanceOf( 'IXR_Error', $result );
     147        $this->assertNotIXRError( $result );
    148148        $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
    149149
     
    154154        $post4 = array( 'post_thumbnail' => $attachment2_id );
    155155        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post4 ) );
    156         $this->assertNotInstanceOf( 'IXR_Error', $result );
     156        $this->assertNotIXRError( $result );
    157157        $this->assertEquals( $attachment2_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
    158158
     
    160160        $post5 = array( 'post_thumbnail' => '' );
    161161        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post5 ) );
    162         $this->assertNotInstanceOf( 'IXR_Error', $result );
     162        $this->assertNotIXRError( $result );
    163163        $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) );
    164164
     
    166166        $post6 = array( 'post_thumbnail' => 398420983409 );
    167167        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post6 ) );
    168         $this->assertInstanceOf( 'IXR_Error', $result );
     168        $this->assertIXRError( $result );
    169169        $this->assertEquals( 404, $result->code );
    170170
     
    192192
    193193        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'contributor', 'contributor', $post_id, $post2 ) );
    194         $this->assertNotInstanceOf( 'IXR_Error', $result );
     194        $this->assertNotIXRError( $result );
    195195        $this->assertTrue($result);
    196196
     
    214214        $post2 = array( 'sticky' => false );
    215215        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) );
    216         $this->assertNotInstanceOf( 'IXR_Error', $result );
     216        $this->assertNotIXRError( $result );
    217217        $this->assertFalse( is_sticky( $post_id ) );
    218218    }
     
    226226        $post2 = array( 'post_password' => 'foobar',  'sticky' => false );
    227227        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) );
    228         $this->assertNotInstanceOf( 'IXR_Error', $result );
     228        $this->assertNotIXRError( $result );
    229229        $this->assertFalse( is_sticky( $post_id ) );
    230230    }
     
    246246        $struct = array( 'post_content' => 'First edit', 'if_not_modified_since' => new IXR_Date( $yesterday ) );
    247247        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $struct ) );
    248         $this->assertNotInstanceOf( 'IXR_Error', $result );
     248        $this->assertNotIXRError( $result );
    249249
    250250        // Make sure the edit went through.
     
    254254        $struct = array( 'post_content' => 'Second edit', 'if_not_modified_since' => new IXR_Date( $yesterday ) );
    255255        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $struct ) );
    256         $this->assertInstanceOf( 'IXR_Error', $result );
     256        $this->assertIXRError( $result );
    257257        $this->assertEquals( 409, $result->code );
    258258
     
    274274        $struct = array( 'post_content' => 'First edit' );
    275275        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $struct ) );
    276         $this->assertNotInstanceOf( 'IXR_Error', $result );
     276        $this->assertNotIXRError( $result );
    277277
    278278        // Make sure that the post status is still inherit
     
    291291        $struct = array( 'post_status' => 'doesnt_exists' );
    292292        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $struct ) );
    293         $this->assertNotInstanceOf( 'IXR_Error', $result );
     293        $this->assertNotIXRError( $result );
    294294
    295295        // Make sure that the post status is still inherit
     
    310310
    311311        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, array( 'ID' => $post_id, 'post_title' => 'Updated' ) ) );
    312         $this->assertNotInstanceOf( 'IXR_Error', $result );
     312        $this->assertNotIXRError( $result );
    313313        $this->assertEquals( 'Updated', get_post( $post_id )->post_title );
    314314
     
    337337        );
    338338        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $new_post_content ) );
    339         $this->assertNotInstanceOf( 'IXR_Error', $result );
     339        $this->assertNotIXRError( $result );
    340340        $this->assertEquals( 'Updated', get_post( $post_id )->post_title );
    341341
Note: See TracChangeset for help on using the changeset viewer.