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/mw/newPost.php

    r36163 r40417  
    99                $post = array();
    1010                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'username', 'password', $post ) );
    11                 $this->assertInstanceOf( 'IXR_Error', $result );
     11                $this->assertIXRError( $result );
    1212                $this->assertEquals( 403, $result->code );
    1313        }
    … …  
    1818                $post = array();
    1919                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'subscriber', 'subscriber', $post ) );
    20                 $this->assertInstanceOf( 'IXR_Error', $result );
     20                $this->assertIXRError( $result );
    2121                $this->assertEquals( 401, $result->code );
    2222        }
    … …  
    2727                $post = array();
    2828                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) );
    29                 $this->assertInstanceOf( 'IXR_Error', $result );
     29                $this->assertIXRError( $result );
    3030                $this->assertEquals( 500, $result->code );
    3131                $this->assertEquals( 'Content, title, and excerpt are empty.', $result->message );
    … …  
    3737                $post = array( 'title' => 'Test' );
    3838                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) );
    39                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     39                $this->assertNotIXRError( $result );
    4040                $this->assertStringMatchesFormat( '%d', $result );
    4141        }
    … …  
    4646                $post = array( 'title' => 'Test', 'ID' => 103948 );
    4747                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) );
    48                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     48                $this->assertNotIXRError( $result );
    4949                $this->assertNotEquals( '103948', $result );
    5050        }
    … …  
    5555                $post = array( 'title' => 'Test', 'post_status' => 'publish' );
    5656                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) );
    57                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     57                $this->assertNotIXRError( $result );
    5858        }
    5959
    … …  
    6363                $post = array( 'title' => 'Test', 'post_status' => 'publish' );
    6464                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'contributor', 'contributor', $post ) );
    65                 $this->assertInstanceOf( 'IXR_Error', $result );
     65                $this->assertIXRError( $result );
    6666                $this->assertEquals( 401, $result->code );
    6767        }
    … …  
    7373                $post = array( 'title' => 'Test', 'wp_author_id' => $other_author_id );
    7474                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) );
    75                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     75                $this->assertNotIXRError( $result );
    7676        }
    7777
    … …  
    8282                $post = array( 'title' => 'Test', 'wp_author_id' => $other_author_id );
    8383                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'contributor', 'contributor', $post ) );
    84                 $this->assertInstanceOf( 'IXR_Error', $result );
     84                $this->assertIXRError( $result );
    8585                $this->assertEquals( 401, $result->code );
    8686        }
    … …  
    9494                $post = array( 'title' => 'Test', 'wp_author_id' => 99999999 );
    9595                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) );
    96                 $this->assertInstanceOf( 'IXR_Error', $result );
     96                $this->assertIXRError( $result );
    9797                $this->assertEquals( 404, $result->code );
    9898        }
    … …  
    103103                $post = array( 'title' => 'Test' );
    104104                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) );
    105                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     105                $this->assertNotIXRError( $result );
    106106                $this->assertStringMatchesFormat( '%d', $result );
    107107
    … …  
    122122                $post = array( 'title' => 'Post Thumbnail Test', 'wp_post_thumbnail' => $attachment_id );
    123123                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) );
    124                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     124                $this->assertNotIXRError( $result );
    125125                $this->assertEquals( $attachment_id, get_post_meta( $result, '_thumbnail_id', true ) );
    126126
    … …  
    133133                $post = array( 'title' => 'Test', 'post_type' => 'page' );
    134134                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) );
    135                 $this->assertInstanceOf( 'IXR_Error', $result );
     135                $this->assertIXRError( $result );
    136136                $this->assertEquals( 401, $result->code );
    137137        }
    … …  
    142142                $post = array( 'title' => 'Test', 'post_type' => 'page' );
    143143                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) );
    144                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     144                $this->assertNotIXRError( $result );
    145145                $this->assertStringMatchesFormat( '%d', $result );
    146146
    … …  
    163163                );
    164164                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) );
    165                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     165                $this->assertNotIXRError( $result );
    166166                $this->assertStringMatchesFormat( '%d', $result );
    167167
Note: See TracChangeset for help on using the changeset viewer.