Make WordPress Core

Changeset 41176


Ignore:
Timestamp:
07/27/2017 07:03:45 PM (7 years ago)
Author:
johnbillion
Message:

REST API: Add some missing assertions to various REST API tests.

See #41463

Location:
trunk/tests/phpunit/tests/rest-api
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-post-meta-fields.php

    r40061 r41176  
    394394        remove_filter( 'query', array( $this, 'error_insert_query' ) );
    395395        $wpdb->show_errors = true;
     396
     397        $this->assertErrorResponse( 'rest_meta_database_error', $response, 500 );
    396398    }
    397399
  • trunk/tests/phpunit/tests/rest-api/rest-post-statuses-controller.php

    r38832 r41176  
    102102    public function test_create_item() {
    103103        /** Post statuses can't be created **/
     104        $request = new WP_REST_Request( 'POST', '/wp/v2/statuses' );
     105        $response = $this->server->dispatch( $request );
     106        $this->assertEquals( 404, $response->get_status() );
    104107    }
    105108
    106109    public function test_update_item() {
    107110        /** Post statuses can't be updated **/
     111        $request = new WP_REST_Request( 'POST', '/wp/v2/statuses/draft' );
     112        $response = $this->server->dispatch( $request );
     113        $this->assertEquals( 404, $response->get_status() );
    108114    }
    109115
    110116    public function test_delete_item() {
    111117        /** Post statuses can't be deleted **/
     118        $request = new WP_REST_Request( 'DELETE', '/wp/v2/statuses/draft' );
     119        $response = $this->server->dispatch( $request );
     120        $this->assertEquals( 404, $response->get_status() );
    112121    }
    113122
  • trunk/tests/phpunit/tests/rest-api/rest-post-types-controller.php

    r39647 r41176  
    9696    public function test_create_item() {
    9797        /** Post types can't be created **/
     98        $request = new WP_REST_Request( 'POST', '/wp/v2/types' );
     99        $response = $this->server->dispatch( $request );
     100        $this->assertEquals( 404, $response->get_status() );
    98101    }
    99102
    100103    public function test_update_item() {
    101104        /** Post types can't be updated **/
     105        $request = new WP_REST_Request( 'POST', '/wp/v2/types/post' );
     106        $response = $this->server->dispatch( $request );
     107        $this->assertEquals( 404, $response->get_status() );
    102108    }
    103109
    104110    public function test_delete_item() {
    105111        /** Post types can't be deleted **/
     112        $request = new WP_REST_Request( 'DELETE', '/wp/v2/types/post' );
     113        $response = $this->server->dispatch( $request );
     114        $this->assertEquals( 404, $response->get_status() );
    106115    }
    107116
  • trunk/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php

    r39191 r41176  
    112112    public function test_create_item() {
    113113        /** Taxonomies can't be created **/
     114        $request = new WP_REST_Request( 'POST', '/wp/v2/taxonomies' );
     115        $response = $this->server->dispatch( $request );
     116        $this->assertEquals( 404, $response->get_status() );
    114117    }
    115118
    116119    public function test_update_item() {
    117120        /** Taxonomies can't be updated **/
     121        $request = new WP_REST_Request( 'POST', '/wp/v2/taxonomies/category' );
     122        $response = $this->server->dispatch( $request );
     123        $this->assertEquals( 404, $response->get_status() );
    118124    }
    119125
    120126    public function test_delete_item() {
    121127        /** Taxonomies can't be deleted **/
     128        $request = new WP_REST_Request( 'DELETE', '/wp/v2/taxonomies/category' );
     129        $response = $this->server->dispatch( $request );
     130        $this->assertEquals( 404, $response->get_status() );
    122131    }
    123132
Note: See TracChangeset for help on using the changeset viewer.