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

    r39189 r40417  
    2323    function test_invalid_username_password() {
    2424        $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'username', 'password', 'category', 1 ) );
    25         $this->assertInstanceOf( 'IXR_Error', $result );
     25        $this->assertIXRError( $result );
    2626        $this->assertEquals( 403, $result->code );
    2727    }
     
    3131
    3232        $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', '', array( 'taxonomy' => '' ) ) );
    33         $this->assertInstanceOf( 'IXR_Error', $result );
     33        $this->assertIXRError( $result );
    3434        $this->assertEquals( 403, $result->code );
    3535        $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
     
    4040
    4141        $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', self::$parent_term, array( 'taxonomy' => 'not_existing' ) ) );
    42         $this->assertInstanceOf( 'IXR_Error', $result );
     42        $this->assertIXRError( $result );
    4343        $this->assertEquals( 403, $result->code );
    4444        $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
     
    4949
    5050        $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', self::$parent_term, array( 'taxonomy' => 'category' ) ) );
    51         $this->assertInstanceOf( 'IXR_Error', $result );
     51        $this->assertIXRError( $result );
    5252        $this->assertEquals( 401, $result->code );
    5353        $this->assertEquals( __( 'Sorry, you are not allowed to edit this term.' ), $result->message );
     
    5858
    5959        $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', 9999, array( 'taxonomy' => 'category' ) ) );
    60         $this->assertInstanceOf( 'IXR_Error', $result );
     60        $this->assertIXRError( $result );
    6161        $this->assertEquals( 404, $result->code );
    6262        $this->assertEquals(  __( 'Invalid term ID.' ), $result->message );
     
    6767
    6868        $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', '', array( 'taxonomy' => 'category' ) ) );
    69         $this->assertInstanceOf( 'IXR_Error', $result );
     69        $this->assertIXRError( $result );
    7070        $this->assertEquals( 500, $result->code );
    7171        $this->assertEquals( __('Empty Term'), $result->message );
     
    7676
    7777        $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$parent_term, array( 'taxonomy' => 'category', 'name' => '' ) ) );
    78         $this->assertInstanceOf( 'IXR_Error', $result );
     78        $this->assertIXRError( $result );
    7979        $this->assertEquals( 403, $result->code );
    8080        $this->assertEquals( __( 'The term name cannot be empty.' ), $result->message );
     
    8585
    8686        $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$post_tag, array( 'taxonomy' => 'post_tag', 'parent' => self::$parent_term ) ) );
    87         $this->assertInstanceOf( 'IXR_Error', $result );
     87        $this->assertIXRError( $result );
    8888        $this->assertEquals( 403, $result->code );
    8989        $this->assertEquals( __( "This taxonomy is not hierarchical so you can't set a parent." ), $result->message );
     
    9494
    9595        $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => '', 'name' => 'test' ) ) );
    96         $this->assertNotInstanceOf( 'IXR_Error', $result );
     96        $this->assertNotIXRError( $result );
    9797        $this->assertTrue( $result );
    9898    }
     
    103103        $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => NULL, 'name' => 'test' ) ) );
    104104
    105         $this->assertNotInstanceOf( 'IXR_Error', $result );
     105        $this->assertNotIXRError( $result );
    106106        $this->assertInternalType( 'boolean', $result );
    107107
     
    114114
    115115        $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => 'dasda', 'name' => 'test' ) ) );
    116         $this->assertInstanceOf( 'IXR_Error', $result );
     116        $this->assertIXRError( $result );
    117117        $this->assertEquals( 500, $result->code );
    118118    }
     
    122122
    123123        $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => 9999, 'name' => 'test' ) ) );
    124         $this->assertInstanceOf( 'IXR_Error', $result );
     124        $this->assertIXRError( $result );
    125125        $this->assertEquals( 403, $result->code );
    126126        $this->assertEquals( __( 'Parent term does not exist.' ), $result->message );
     
    132132        $parent_term = get_term_by( 'id', self::$parent_term, 'category' );
    133133        $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'slug' => $parent_term->slug ) ) );
    134         $this->assertInstanceOf( 'IXR_Error', $result );
     134        $this->assertIXRError( $result );
    135135        $this->assertEquals( 500, $result->code );
    136136        $this->assertEquals( htmlspecialchars( sprintf( __('The slug “%s” is already in use by another term'), $parent_term->slug ) ), $result->message );
     
    143143        $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, $fields ) );
    144144
    145         $this->assertNotInstanceOf( 'IXR_Error', $result );
     145        $this->assertNotIXRError( $result );
    146146        $this->assertInternalType( 'boolean', $result );
    147147    }
Note: See TracChangeset for help on using the changeset viewer.