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/getTerms.php

    r38938 r40417  
    88        function test_invalid_username_password() {
    99                $result = $this->myxmlrpcserver->wp_getTerms( array( 1, 'username', 'password', 'category' ) );
    10                 $this->assertInstanceOf( 'IXR_Error', $result );
     10                $this->assertIXRError( $result );
    1111                $this->assertEquals( 403, $result->code );
    1212        }
    … …  
    1616
    1717                $result = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', '' ) );
    18                 $this->assertInstanceOf( 'IXR_Error', $result );
     18                $this->assertIXRError( $result );
    1919                $this->assertEquals( 403, $result->code );
    2020                $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
    … …  
    2525
    2626                $result = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'not_existing' ) );
    27                 $this->assertInstanceOf( 'IXR_Error', $result );
     27                $this->assertIXRError( $result );
    2828                $this->assertEquals( 403, $result->code );
    2929                $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
    … …  
    3434
    3535                $result = $this->myxmlrpcserver->wp_getTerms( array( 1, 'subscriber', 'subscriber', 'category' ) );
    36                 $this->assertInstanceOf( 'IXR_Error', $result );
     36                $this->assertIXRError( $result );
    3737                $this->assertEquals( 401, $result->code );
    3838                $this->assertEquals( __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ), $result->message );
    … …  
    4646
    4747                $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category' ) );
    48                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     48                $this->assertNotIXRError( $results );
    4949
    5050                foreach( $results as $term ) {
    … …  
    7272                // test fetching all terms
    7373                $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name ) );
    74                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     74                $this->assertNotIXRError( $results );
    7575
    7676                $this->assertEquals( $num_terms, count( $results ) );
    … …  
    8282                $filter = array( 'number' => 5 );
    8383                $results2 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) );
    84                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     84                $this->assertNotIXRError( $results );
    8585                $this->assertEquals( 5, count( $results2 ) );
    8686                $this->assertEquals( $results[1]['term_id'], $results2[1]['term_id'] ); // check one of the terms
    … …  
    8888                $filter['offset'] = 10;
    8989                $results3 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) );
    90                 $this->assertNotInstanceOf( 'IXR_Error', $results3 );
     90                $this->assertNotIXRError( $results3 );
    9191                $this->assertEquals( $num_terms - 10, count( $results3 ) );
    9292                $this->assertEquals( $results[11]['term_id'], $results3[1]['term_id'] );
    … …  
    9595                $filter = array( 'hide_empty' => true );
    9696                $results4 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) );
    97                 $this->assertNotInstanceOf( 'IXR_Error', $results4 );
     97                $this->assertNotIXRError( $results4 );
    9898                $this->assertEquals( 0, count( $results4 ) );
    9999
    … …  
    112112                $filter = array( 'orderby' => 'count', 'order' => 'DESC' );
    113113                $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) );
    114                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     114                $this->assertNotIXRError( $results );
    115115                $this->assertNotEquals( 0, count( $results ) );
    116116
    … …  
    134134                $filter = array( 'search' => $name );
    135135                $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) );
    136                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     136                $this->assertNotIXRError( $results );
    137137                $this->assertEquals( 1, count( $results ) );
    138138                $this->assertEquals( $name, $results[0]['name'] );
    … …  
    142142                $filter = array( 'search' => substr( $name, 0, 10 ) );
    143143                $results2 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) );
    144                 $this->assertNotInstanceOf( 'IXR_Error', $results2 );
     144                $this->assertNotIXRError( $results2 );
    145145                $this->assertEquals( 1, count( $results2 ) );
    146146                $this->assertEquals( $name, $results2[0]['name'] );
Note: See TracChangeset for help on using the changeset viewer.