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/wp/newTerm.php

    r39189 r40417  
    1616    function test_invalid_username_password() {
    1717        $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'username', 'password', array() ) );
    18         $this->assertInstanceOf( 'IXR_Error', $result );
     18        $this->assertIXRError( $result );
    1919        $this->assertEquals( 403, $result->code );
    2020    }
     
    2424
    2525        $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => '' ) ) );
    26         $this->assertInstanceOf( 'IXR_Error', $result );
     26        $this->assertIXRError( $result );
    2727        $this->assertEquals( 403, $result->code );
    2828        $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
     
    3333
    3434        $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'not_existing' ) ) );
    35         $this->assertInstanceOf( 'IXR_Error', $result );
     35        $this->assertIXRError( $result );
    3636        $this->assertEquals( 403, $result->code );
    3737        $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
     
    4242
    4343        $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'subscriber', 'subscriber', array( 'taxonomy' => 'category' ) ) );
    44         $this->assertInstanceOf( 'IXR_Error', $result );
     44        $this->assertIXRError( $result );
    4545        $this->assertEquals( 401, $result->code );
    4646        $this->assertEquals( __( 'Sorry, you are not allowed to create terms in this taxonomy.' ), $result->message );
     
    5151
    5252        $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'name' => '' ) ) );
    53         $this->assertInstanceOf( 'IXR_Error', $result );
     53        $this->assertIXRError( $result );
    5454        $this->assertEquals( 403, $result->code );
    5555        $this->assertEquals( __( 'The term name cannot be empty.' ), $result->message );
     
    6060
    6161        $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'post_tag', 'parent' => self::$parent_term_id, 'name' => 'test' ) ) );
    62         $this->assertInstanceOf( 'IXR_Error', $result );
     62        $this->assertIXRError( $result );
    6363        $this->assertEquals( 403, $result->code );
    6464        $this->assertEquals( __( 'This taxonomy is not hierarchical.' ), $result->message );
     
    6969
    7070        $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'parent' => 'dasda', 'name' => 'test' ) ) );
    71         $this->assertInstanceOf( 'IXR_Error', $result );
     71        $this->assertIXRError( $result );
    7272        $this->assertEquals( 500, $result->code );
    7373    }
     
    7777
    7878        $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'parent' => 9999, 'name' => 'test' ) ) );
    79         $this->assertInstanceOf( 'IXR_Error', $result );
     79        $this->assertIXRError( $result );
    8080        $this->assertEquals( 403, $result->code );
    8181        $this->assertEquals( __( 'Parent term does not exist.' ), $result->message );
     
    8787
    8888        $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'name' => 'test' ) ) );
    89         $this->assertNotInstanceOf( 'IXR_Error', $result );
     89        $this->assertNotIXRError( $result );
    9090        $this->assertStringMatchesFormat( '%d', $result );
    9191    }
     
    9595
    9696        $result  = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'parent' => self::$parent_term_id, 'name' => 'test' ) ) );
    97         $this->assertNotInstanceOf( 'IXR_Error', $result );
     97        $this->assertNotIXRError( $result );
    9898        $this->assertStringMatchesFormat( '%d', $result );
    9999    }
     
    104104        $taxonomy = array( 'taxonomy' => 'category', 'parent' => self::$parent_term_id, 'name' => 'test_all', 'description' => 'Test all', 'slug' => 'test_all' );
    105105        $result  = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', $taxonomy ) );
    106         $this->assertNotInstanceOf( 'IXR_Error', $result );
     106        $this->assertNotIXRError( $result );
    107107        $this->assertStringMatchesFormat( '%d', $result );
    108108    }
Note: See TracChangeset for help on using the changeset viewer.