Make WordPress Core


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

    r37044 r40417  
    99        $post = array();
    1010        $result = $this->myxmlrpcserver->mw_editPost( array( 1, 'username', 'password', $post ) );
    11         $this->assertInstanceOf( 'IXR_Error', $result );
     11        $this->assertIXRError( $result );
    1212        $this->assertEquals( 403, $result->code );
    1313    }
     
    2121        $post2 = array( 'title' => $new_title );
    2222        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) );
    23         $this->assertNotInstanceOf( 'IXR_Error', $result );
     23        $this->assertNotIXRError( $result );
    2424        $this->assertTrue($result);
    2525
     
    3838        $post2 = array( 'title' => $new_title );
    3939        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', $post2 ) );
    40         $this->assertNotInstanceOf( 'IXR_Error', $result );
     40        $this->assertNotIXRError( $result );
    4141        $this->assertTrue($result);
    4242
     
    5656        $post2 = array( 'title' => $new_title );
    5757        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) );
    58         $this->assertInstanceOf( 'IXR_Error', $result );
     58        $this->assertIXRError( $result );
    5959        $this->assertEquals( 401, $result->code );
    6060
     
    7373        $post2 = array( 'wp_author_id' => $author_id );
    7474        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', $post2 ) );
    75         $this->assertNotInstanceOf( 'IXR_Error', $result );
     75        $this->assertNotIXRError( $result );
    7676        $this->assertTrue($result);
    7777
     
    8989        $post2 = array( 'wp_author_id' => $author_id );
    9090        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) );
    91         $this->assertInstanceOf( 'IXR_Error', $result );
     91        $this->assertIXRError( $result );
    9292        $this->assertEquals( 401, $result->code );
    9393
     
    108108        $post2 = array( 'wp_author_id' => $editor_id );
    109109        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', $post2 ) );
    110         $this->assertNotInstanceOf( 'IXR_Error', $result );
     110        $this->assertNotIXRError( $result );
    111111        $this->assertTrue($result);
    112112
     
    132132        $post2 = array( 'wp_post_thumbnail' => $attachment_id );
    133133        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $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
     
    138138        $post3 = array( 'post_content' => 'Updated post' );
    139139        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post3 ) );
    140         $this->assertNotInstanceOf( 'IXR_Error', $result );
     140        $this->assertNotIXRError( $result );
    141141        $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
    142142
     
    147147        $post4 = array( 'wp_post_thumbnail' => $attachment2_id );
    148148        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post4 ) );
    149         $this->assertNotInstanceOf( 'IXR_Error', $result );
     149        $this->assertNotIXRError( $result );
    150150        $this->assertEquals( $attachment2_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
    151151
     
    153153        $post5 = array( 'wp_post_thumbnail' => '' );
    154154        $result = $this->myxmlrpcserver->mw_editPost( array($post_id, 'author', 'author', $post5 ) );
    155         $this->assertNotInstanceOf( 'IXR_Error', $result );
     155        $this->assertNotIXRError( $result );
    156156        $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) );
    157157
     
    167167        $post2 = array( 'title' => 'New Title', 'post_author' => $contributor_id );
    168168        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) );
    169         $this->assertNotInstanceOf( 'IXR_Error', $result );
     169        $this->assertNotIXRError( $result );
    170170        $this->assertTrue($result);
    171171
     
    175175        $post3 = array( 'description' => 'New Content', 'post_author' => $contributor_id );
    176176        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post3 ) );
    177         $this->assertNotInstanceOf( 'IXR_Error', $result );
     177        $this->assertNotIXRError( $result );
    178178        $this->assertTrue($result);
    179179
     
    184184        $post4 = array( 'mt_excerpt' => 'New Excerpt', 'post_author' => $contributor_id );
    185185        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post4 ) );
    186         $this->assertNotInstanceOf( 'IXR_Error', $result );
     186        $this->assertNotIXRError( $result );
    187187        $this->assertTrue($result);
    188188
     
    203203
    204204        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', array( 'sticky' => '1' ) ) );
    205         $this->assertNotInstanceOf( 'IXR_Error', $result );
     205        $this->assertNotIXRError( $result );
    206206        $this->assertTrue( $result );
    207207    }
     
    216216        $post2 = array( 'post_type' => 'page' );
    217217        $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) );
    218         $this->assertInstanceOf( 'IXR_Error', $result );
     218        $this->assertIXRError( $result );
    219219        $this->assertEquals( $result->code, 401 );
    220220    }
Note: See TracChangeset for help on using the changeset viewer.