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

    r38382 r40417  
    88    function test_invalid_username_password() {
    99        $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'username', 'password' ) );
    10         $this->assertInstanceOf( 'IXR_Error', $result );
     10        $this->assertIXRError( $result );
    1111        $this->assertEquals( 403, $result->code );
    1212    }
     
    1919
    2020        $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'subscriber', 'subscriber' ) );
    21         $this->assertInstanceOf( 'IXR_Error', $result );
     21        $this->assertIXRError( $result );
    2222        $this->assertEquals( 401, $result->code );
    2323
    2424        $filter = array( 'post_type' => 'page' );
    2525        $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'subscriber', 'subscriber', $filter ) );
    26         $this->assertInstanceOf( 'IXR_Error', $result );
     26        $this->assertIXRError( $result );
    2727        $this->assertEquals( 401, $result->code );
    2828    }
     
    3232
    3333        $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor' ) );
    34         $this->assertNotInstanceOf( 'IXR_Error', $result );
     34        $this->assertNotIXRError( $result );
    3535    }
    3636
     
    4040        $filter = array( 'post_type' => 'invalid_post_type_name' );
    4141        $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) );
    42         $this->assertInstanceOf( 'IXR_Error', $result );
     42        $this->assertIXRError( $result );
    4343    }
    4444
     
    6363        $filter = array( 'post_type' => $cpt_name, 'number' => $num_posts + 10 );
    6464        $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) );
    65         $this->assertNotInstanceOf( 'IXR_Error', $results );
     65        $this->assertNotIXRError( $results );
    6666        $this->assertEquals( $num_posts, count( $results ) );
    6767
     
    8787        $filter2 = array( 'post_type' => $cpt_name, 'number' => $num_posts, 'orderby' => 'comment_count', 'order' => 'DESC' );
    8888        $results2 = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter2 ) );
    89         $this->assertNotInstanceOf( 'IXR_Error', $results2 );
     89        $this->assertNotIXRError( $results2 );
    9090        $last_comment_count = 100;
    9191        foreach ( $results2 as $post ) {
     
    101101        $filter3 = array( 'post_type' => $cpt_name, 'post_status' => 'draft' );
    102102        $results3 = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter3 ) );
    103         $this->assertNotInstanceOf( 'IXR_Error', $results3 );
     103        $this->assertNotIXRError( $results3 );
    104104        $this->assertEquals( 1, count( $results3 ) );
    105105        $this->assertEquals( $post->ID, $results3[0]['post_id'] );
     
    114114        // check default fields
    115115        $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor' ) );
    116         $this->assertNotInstanceOf( 'IXR_Error', $results );
     116        $this->assertNotIXRError( $results );
    117117        $expected_fields = array( 'post_id', 'post_title', 'terms', 'custom_fields', 'link' ); // subset of expected fields
    118118        foreach( $expected_fields as $field ) {
     
    124124        $fields = array( 'post_name', 'post_author', 'enclosure' );
    125125        $results2 = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter, $fields ) );
    126         $this->assertNotInstanceOf( 'IXR_Error', $results2 );
     126        $this->assertNotIXRError( $results2 );
    127127        $expected_fields = array_merge( $fields, array( 'post_id' ) );
    128128        foreach ( array_keys( $results2[0] ) as $field ) {
     
    143143        $filter = array( 's' => 'Third' );
    144144        $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) );
    145         $this->assertNotInstanceOf( 'IXR_Error', $results );
     145        $this->assertNotIXRError( $results );
    146146        $this->assertEquals( 0, count( $results ) );
    147147
     
    149149        $filter = array( 's' => 'First:' );
    150150        $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) );
    151         $this->assertNotInstanceOf( 'IXR_Error', $results );
     151        $this->assertNotIXRError( $results );
    152152        $this->assertEquals( 1, count( $results ) );
    153153    }
Note: See TracChangeset for help on using the changeset viewer.