Make WordPress Core


Ignore:
Timestamp:
02/21/2018 04:24:30 PM (8 years ago)
Author:
SergeyBiryukov
Message:

Tests: Replace use of $this->server with rest_get_server() for better memory recycling.

Props danielbachhuber.
Fixes #41641.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-tags-controller.php

    r42343 r42724  
    5151
    5252    public function test_register_routes() {
    53         $routes = $this->server->get_routes();
     53        $routes = rest_get_server()->get_routes();
    5454        $this->assertArrayHasKey( '/wp/v2/tags', $routes );
    5555        $this->assertArrayHasKey( '/wp/v2/tags/(?P<id>[\d]+)', $routes );
     
    5959        // Collection
    6060        $request  = new WP_REST_Request( 'OPTIONS', '/wp/v2/tags' );
    61         $response = $this->server->dispatch( $request );
     61        $response = rest_get_server()->dispatch( $request );
    6262        $data     = $response->get_data();
    6363        $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
     
    6666        $tag1     = $this->factory->tag->create( array( 'name' => 'Season 5' ) );
    6767        $request  = new WP_REST_Request( 'OPTIONS', '/wp/v2/tags/' . $tag1 );
    68         $response = $this->server->dispatch( $request );
     68        $response = rest_get_server()->dispatch( $request );
    6969        $data     = $response->get_data();
    7070        $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
     
    7474    public function test_registered_query_params() {
    7575        $request  = new WP_REST_Request( 'OPTIONS', '/wp/v2/tags' );
    76         $response = $this->server->dispatch( $request );
     76        $response = rest_get_server()->dispatch( $request );
    7777        $data     = $response->get_data();
    7878        $keys     = array_keys( $data['endpoints'][0]['args'] );
     
    9999        $this->factory->tag->create();
    100100        $request  = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    101         $response = $this->server->dispatch( $request );
     101        $response = rest_get_server()->dispatch( $request );
    102102        $this->check_get_taxonomy_terms_response( $response );
    103103    }
     
    107107        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    108108        $request->set_param( 'context', 'edit' );
    109         $response = $this->server->dispatch( $request );
     109        $response = rest_get_server()->dispatch( $request );
    110110        $this->assertErrorResponse( 'rest_forbidden_context', $response, 401 );
    111111    }
     
    118118        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    119119        $request->set_param( 'hide_empty', true );
    120         $response = $this->server->dispatch( $request );
     120        $response = rest_get_server()->dispatch( $request );
    121121        $data     = $response->get_data();
    122122        $this->assertEquals( 2, count( $data ) );
     
    125125        // invalid value should fail
    126126        $request->set_param( 'hide_empty', 'nothanks' );
    127         $response = $this->server->dispatch( $request );
     127        $response = rest_get_server()->dispatch( $request );
    128128        $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    129129    }
     
    136136        // Orderby=>asc
    137137        $request->set_param( 'include', array( $id3, $id1 ) );
    138         $response = $this->server->dispatch( $request );
     138        $response = rest_get_server()->dispatch( $request );
    139139        $data     = $response->get_data();
    140140        $this->assertEquals( 2, count( $data ) );
     
    142142        // Orderby=>include
    143143        $request->set_param( 'orderby', 'include' );
    144         $response = $this->server->dispatch( $request );
     144        $response = rest_get_server()->dispatch( $request );
    145145        $data     = $response->get_data();
    146146        $this->assertEquals( 2, count( $data ) );
     
    148148        // Include invalid value shoud fail
    149149        $request->set_param( 'include', array( 'myterm' ) );
    150         $response = $this->server->dispatch( $request );
     150        $response = rest_get_server()->dispatch( $request );
    151151        $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    152152    }
     
    156156        $id2      = $this->factory->tag->create();
    157157        $request  = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    158         $response = $this->server->dispatch( $request );
     158        $response = rest_get_server()->dispatch( $request );
    159159        $data     = $response->get_data();
    160160        $this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ), true ) );
    161161        $this->assertTrue( in_array( $id2, wp_list_pluck( $data, 'id' ), true ) );
    162162        $request->set_param( 'exclude', array( $id2 ) );
    163         $response = $this->server->dispatch( $request );
     163        $response = rest_get_server()->dispatch( $request );
    164164        $data     = $response->get_data();
    165165        $this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ), true ) );
     
    167167        // Invalid exclude value should fail
    168168        $request->set_param( 'exclude', array( 'invalid' ) );
    169         $response = $this->server->dispatch( $request );
     169        $response = rest_get_server()->dispatch( $request );
    170170        $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    171171    }
     
    178178        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    179179        $request->set_param( 'offset', 1 );
    180         $response = $this->server->dispatch( $request );
     180        $response = rest_get_server()->dispatch( $request );
    181181        $this->assertCount( 3, $response->get_data() );
    182182        // 'offset' works with 'per_page'
    183183        $request->set_param( 'per_page', 2 );
    184         $response = $this->server->dispatch( $request );
     184        $response = rest_get_server()->dispatch( $request );
    185185        $this->assertCount( 2, $response->get_data() );
    186186        // 'offset' takes priority over 'page'
    187187        $request->set_param( 'page', 3 );
    188         $response = $this->server->dispatch( $request );
     188        $response = rest_get_server()->dispatch( $request );
    189189        $this->assertCount( 2, $response->get_data() );
    190190        // 'offset' invalid value shoudl fail
    191191        $request->set_param( 'offset', 'moreplease' );
    192         $response = $this->server->dispatch( $request );
     192        $response = rest_get_server()->dispatch( $request );
    193193        $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    194194    }
     
    208208        $request->set_param( 'order', 'desc' );
    209209        $request->set_param( 'per_page', 1 );
    210         $response = $this->server->dispatch( $request );
     210        $response = rest_get_server()->dispatch( $request );
    211211        $this->assertEquals( 200, $response->get_status() );
    212212        $data = $response->get_data();
     
    217217        $request->set_param( 'order', 'asc' );
    218218        $request->set_param( 'per_page', 2 );
    219         $response = $this->server->dispatch( $request );
     219        $response = rest_get_server()->dispatch( $request );
    220220        $this->assertEquals( 200, $response->get_status() );
    221221        $data = $response->get_data();
     
    224224        // Invalid orderby should fail.
    225225        $request->set_param( 'orderby', 'invalid' );
    226         $response = $this->server->dispatch( $request );
     226        $response = rest_get_server()->dispatch( $request );
    227227        $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    228228    }
     
    234234        // defaults to orderby=name, order=asc
    235235        $request  = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    236         $response = $this->server->dispatch( $request );
     236        $response = rest_get_server()->dispatch( $request );
    237237        $this->assertEquals( 200, $response->get_status() );
    238238        $data = $response->get_data();
     
    243243        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    244244        $request->set_param( 'orderby', 'id' );
    245         $response = $this->server->dispatch( $request );
     245        $response = rest_get_server()->dispatch( $request );
    246246        $this->assertEquals( 200, $response->get_status() );
    247247        $data = $response->get_data();
     
    253253        $request->set_param( 'orderby', 'id' );
    254254        $request->set_param( 'order', 'desc' );
    255         $response = $this->server->dispatch( $request );
     255        $response = rest_get_server()->dispatch( $request );
    256256        $data     = $response->get_data();
    257257        $this->assertEquals( 200, $response->get_status() );
     
    269269        $request->set_param( 'orderby', 'include_slugs' );
    270270        $request->set_param( 'slug', array( 'taco', 'burrito', 'chalupa' ) );
    271         $response = $this->server->dispatch( $request );
     271        $response = rest_get_server()->dispatch( $request );
    272272        $data     = $response->get_data();
    273273        $this->assertEquals( 200, $response->get_status() );
     
    286286        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    287287        $request->set_param( 'post', $post_id );
    288         $response = $this->server->dispatch( $request );
     288        $response = rest_get_server()->dispatch( $request );
    289289        $this->assertEquals( 200, $response->get_status() );
    290290
     
    296296        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    297297        $request->set_param( 'post', 'invalid-post' );
    298         $response = $this->server->dispatch( $request );
     298        $response = rest_get_server()->dispatch( $request );
    299299        $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    300300    }
     
    318318        $request->set_param( 'per_page', 15 );
    319319        $request->set_param( 'orderby', 'id' );
    320         $response = $this->server->dispatch( $request );
     320        $response = rest_get_server()->dispatch( $request );
    321321        $tags     = $response->get_data();
    322322
     
    332332        $request->set_param( 'per_page', 15 );
    333333        $request->set_param( 'orderby', 'id' );
    334         $response = $this->server->dispatch( $request );
     334        $response = rest_get_server()->dispatch( $request );
    335335        $tags     = $response->get_data();
    336336
     
    346346        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    347347        $request->set_param( 'post', $post_id );
    348         $response = $this->server->dispatch( $request );
     348        $response = rest_get_server()->dispatch( $request );
    349349        $this->assertEquals( 200, $response->get_status() );
    350350
     
    380380        $request = new WP_REST_Request( 'GET', '/wp/v2/batman' );
    381381        $request->set_param( 'post', $post_id );
    382         $response = $this->server->dispatch( $request );
     382        $response = rest_get_server()->dispatch( $request );
    383383        $this->assertEquals( 200, $response->get_status() );
    384384
     
    397397        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    398398        $request->set_param( 'search', 'App' );
    399         $response = $this->server->dispatch( $request );
     399        $response = rest_get_server()->dispatch( $request );
    400400        $this->assertEquals( 200, $response->get_status() );
    401401        $data = $response->get_data();
     
    404404        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    405405        $request->set_param( 'search', 'Garbage' );
    406         $response = $this->server->dispatch( $request );
     406        $response = rest_get_server()->dispatch( $request );
    407407        $this->assertEquals( 200, $response->get_status() );
    408408        $data = $response->get_data();
     
    415415        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    416416        $request->set_param( 'slug', 'apple' );
    417         $response = $this->server->dispatch( $request );
     417        $response = rest_get_server()->dispatch( $request );
    418418        $this->assertEquals( 200, $response->get_status() );
    419419        $data = $response->get_data();
     
    435435            )
    436436        );
    437         $response = $this->server->dispatch( $request );
     437        $response = rest_get_server()->dispatch( $request );
    438438        $this->assertEquals( 200, $response->get_status() );
    439439        $data  = $response->get_data();
     
    450450        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    451451        $request->set_param( 'slug', 'taco,burrito, enchilada' );
    452         $response = $this->server->dispatch( $request );
     452        $response = rest_get_server()->dispatch( $request );
    453453        $this->assertEquals( 200, $response->get_status() );
    454454        $data  = $response->get_data();
     
    474474
    475475        $request  = new WP_REST_Request( 'GET', '/wp/v2/terms/robin' );
    476         $response = $this->server->dispatch( $request );
     476        $response = rest_get_server()->dispatch( $request );
    477477        $this->assertErrorResponse( 'rest_no_route', $response, 404 );
    478478    }
     
    488488        }
    489489        $request  = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    490         $response = $this->server->dispatch( $request );
     490        $response = rest_get_server()->dispatch( $request );
    491491        $headers  = $response->get_headers();
    492492        $this->assertEquals( 50, $headers['X-WP-Total'] );
     
    507507        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    508508        $request->set_param( 'page', 3 );
    509         $response = $this->server->dispatch( $request );
     509        $response = rest_get_server()->dispatch( $request );
    510510        $headers  = $response->get_headers();
    511511        $this->assertEquals( 51, $headers['X-WP-Total'] );
     
    526526        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    527527        $request->set_param( 'page', 6 );
    528         $response = $this->server->dispatch( $request );
     528        $response = rest_get_server()->dispatch( $request );
    529529        $headers  = $response->get_headers();
    530530        $this->assertEquals( 51, $headers['X-WP-Total'] );
     
    540540        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    541541        $request->set_param( 'page', 8 );
    542         $response = $this->server->dispatch( $request );
     542        $response = rest_get_server()->dispatch( $request );
    543543        $headers  = $response->get_headers();
    544544        $this->assertEquals( 51, $headers['X-WP-Total'] );
     
    556556        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    557557        $request->set_param( 'context', 'banana' );
    558         $response = $this->server->dispatch( $request );
     558        $response = rest_get_server()->dispatch( $request );
    559559        $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    560560    }
     
    563563        $id       = $this->factory->tag->create();
    564564        $request  = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $id );
    565         $response = $this->server->dispatch( $request );
     565        $response = rest_get_server()->dispatch( $request );
    566566        $this->check_get_taxonomy_term_response( $response, $id );
    567567    }
     
    569569    public function test_get_term_invalid_term() {
    570570        $request  = new WP_REST_Request( 'GET', '/wp/v2/tags/' . REST_TESTS_IMPOSSIBLY_HIGH_NUMBER );
    571         $response = $this->server->dispatch( $request );
     571        $response = rest_get_server()->dispatch( $request );
    572572        $this->assertErrorResponse( 'rest_term_invalid', $response, 404 );
    573573    }
     
    578578        $request = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $id );
    579579        $request->set_param( 'context', 'edit' );
    580         $response = $this->server->dispatch( $request );
     580        $response = rest_get_server()->dispatch( $request );
    581581        $this->assertErrorResponse( 'rest_forbidden_context', $response, 401 );
    582582    }
     
    592592
    593593        $request  = new WP_REST_Request( 'GET', '/wp/v2/terms/robin/' . $term1 );
    594         $response = $this->server->dispatch( $request );
     594        $response = rest_get_server()->dispatch( $request );
    595595        $this->assertErrorResponse( 'rest_no_route', $response, 404 );
    596596    }
     
    605605        );
    606606        $request  = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $term1 );
    607         $response = $this->server->dispatch( $request );
     607        $response = rest_get_server()->dispatch( $request );
    608608        $this->assertErrorResponse( 'rest_term_invalid', $response, 404 );
    609609    }
     
    615615        $request->set_param( 'description', 'This term is so awesome.' );
    616616        $request->set_param( 'slug', 'so-awesome' );
    617         $response = $this->server->dispatch( $request );
     617        $response = rest_get_server()->dispatch( $request );
    618618        $this->assertEquals( 201, $response->get_status() );
    619619        $headers = $response->get_headers();
     
    629629        $request = new WP_REST_Request( 'POST', '/wp/v2/tags' );
    630630        $request->set_param( 'name', 'Incorrect permissions' );
    631         $response = $this->server->dispatch( $request );
     631        $response = rest_get_server()->dispatch( $request );
    632632        $this->assertErrorResponse( 'rest_cannot_create', $response, 403 );
    633633    }
     
    636636        wp_set_current_user( self::$administrator );
    637637        $request  = new WP_REST_Request( 'POST', '/wp/v2/tags' );
    638         $response = $this->server->dispatch( $request );
     638        $response = rest_get_server()->dispatch( $request );
    639639        $this->assertErrorResponse( 'rest_missing_callback_param', $response, 400 );
    640640    }
     
    646646        $request->set_param( 'name', 'My Awesome Term' );
    647647        $request->set_param( 'parent', REST_TESTS_IMPOSSIBLY_HIGH_NUMBER );
    648         $response = $this->server->dispatch( $request );
     648        $response = rest_get_server()->dispatch( $request );
    649649        $this->assertErrorResponse( 'rest_taxonomy_not_hierarchical', $response, 400 );
    650650    }
     
    662662        $request->set_param( 'description', 'New Description' );
    663663        $request->set_param( 'slug', 'new-slug' );
    664         $response = $this->server->dispatch( $request );
     664        $response = rest_get_server()->dispatch( $request );
    665665        $this->assertEquals( 200, $response->get_status() );
    666666        $data = $response->get_data();
     
    676676        $request = new WP_REST_Request( 'PUT', '/wp/v2/tags/' . $term->term_id );
    677677
    678         $response = $this->server->dispatch( $request );
     678        $response = rest_get_server()->dispatch( $request );
    679679        $this->assertEquals( 200, $response->get_status() );
    680680        $request->set_param( 'slug', $term->slug );
     
    682682        // Run twice to make sure that the update still succeeds even if no DB
    683683        // rows are updated.
    684         $response = $this->server->dispatch( $request );
    685         $this->assertEquals( 200, $response->get_status() );
    686 
    687         $response = $this->server->dispatch( $request );
     684        $response = rest_get_server()->dispatch( $request );
     685        $this->assertEquals( 200, $response->get_status() );
     686
     687        $response = rest_get_server()->dispatch( $request );
    688688        $this->assertEquals( 200, $response->get_status() );
    689689    }
     
    693693        $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . REST_TESTS_IMPOSSIBLY_HIGH_NUMBER );
    694694        $request->set_param( 'name', 'Invalid Term' );
    695         $response = $this->server->dispatch( $request );
     695        $response = rest_get_server()->dispatch( $request );
    696696        $this->assertErrorResponse( 'rest_term_invalid', $response, 404 );
    697697    }
     
    702702        $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . $term->term_id );
    703703        $request->set_param( 'name', 'Incorrect permissions' );
    704         $response = $this->server->dispatch( $request );
     704        $response = rest_get_server()->dispatch( $request );
    705705        $this->assertErrorResponse( 'rest_cannot_update', $response, 403 );
    706706    }
     
    716716
    717717        add_filter( 'map_meta_cap', array( $this, 'grant_edit_term' ), 10, 2 );
    718         $response = $this->server->dispatch( $request );
     718        $response = rest_get_server()->dispatch( $request );
    719719        remove_filter( 'user_has_cap', array( $this, 'grant_edit_term' ), 10, 2 );
    720720
     
    741741
    742742        add_filter( 'map_meta_cap', array( $this, 'revoke_edit_term' ), 10, 2 );
    743         $response = $this->server->dispatch( $request );
     743        $response = rest_get_server()->dispatch( $request );
    744744        remove_filter( 'user_has_cap', array( $this, 'revoke_edit_term' ), 10, 2 );
    745745
     
    760760        $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . $term->term_id );
    761761        $request->set_param( 'parent', REST_TESTS_IMPOSSIBLY_HIGH_NUMBER );
    762         $response = $this->server->dispatch( $request );
     762        $response = rest_get_server()->dispatch( $request );
    763763        $this->assertErrorResponse( 'rest_taxonomy_not_hierarchical', $response, 400 );
    764764    }
     
    770770            $request->set_param( $name, $value );
    771771        }
    772         $response = $this->server->dispatch( $request );
     772        $response = rest_get_server()->dispatch( $request );
    773773        $this->assertEquals( 201, $response->get_status() );
    774774        $actual_output = $response->get_data();
     
    788788            $request->set_param( $name, $value );
    789789        }
    790         $response = $this->server->dispatch( $request );
     790        $response = rest_get_server()->dispatch( $request );
    791791        $this->assertEquals( 200, $response->get_status() );
    792792        $actual_output = $response->get_data();
     
    876876        $request = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id );
    877877        $request->set_param( 'force', true );
    878         $response = $this->server->dispatch( $request );
     878        $response = rest_get_server()->dispatch( $request );
    879879        $this->assertEquals( 200, $response->get_status() );
    880880        $data = $response->get_data();
     
    888888
    889889        $request  = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id );
    890         $response = $this->server->dispatch( $request );
     890        $response = rest_get_server()->dispatch( $request );
    891891        $this->assertErrorResponse( 'rest_trash_not_supported', $response, 501 );
    892892
    893893        $request->set_param( 'force', 'false' );
    894         $response = $this->server->dispatch( $request );
     894        $response = rest_get_server()->dispatch( $request );
    895895        $this->assertErrorResponse( 'rest_trash_not_supported', $response, 501 );
    896896    }
     
    899899        wp_set_current_user( self::$administrator );
    900900        $request  = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . REST_TESTS_IMPOSSIBLY_HIGH_NUMBER );
    901         $response = $this->server->dispatch( $request );
     901        $response = rest_get_server()->dispatch( $request );
    902902        $this->assertErrorResponse( 'rest_term_invalid', $response, 404 );
    903903    }
     
    907907        $term     = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );
    908908        $request  = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id );
    909         $response = $this->server->dispatch( $request );
     909        $response = rest_get_server()->dispatch( $request );
    910910        $this->assertErrorResponse( 'rest_cannot_delete', $response, 403 );
    911911    }
     
    921921
    922922        add_filter( 'map_meta_cap', array( $this, 'grant_delete_term' ), 10, 2 );
    923         $response = $this->server->dispatch( $request );
     923        $response = rest_get_server()->dispatch( $request );
    924924        remove_filter( 'map_meta_cap', array( $this, 'grant_delete_term' ), 10, 2 );
    925925
     
    947947
    948948        add_filter( 'map_meta_cap', array( $this, 'revoke_delete_term' ), 10, 2 );
    949         $response = $this->server->dispatch( $request );
     949        $response = rest_get_server()->dispatch( $request );
    950950        remove_filter( 'map_meta_cap', array( $this, 'revoke_delete_term' ), 10, 2 );
    951951
     
    963963        $term     = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );
    964964        $request  = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $term->term_id );
    965         $response = $this->server->dispatch( $request );
     965        $response = rest_get_server()->dispatch( $request );
    966966        $data     = $response->get_data();
    967967
     
    971971    public function test_get_item_schema() {
    972972        $request    = new WP_REST_Request( 'OPTIONS', '/wp/v2/tags' );
    973         $response   = $this->server->dispatch( $request );
     973        $response   = rest_get_server()->dispatch( $request );
    974974        $data       = $response->get_data();
    975975        $properties = $data['schema']['properties'];
     
    988988    public function test_get_item_schema_non_hierarchical() {
    989989        $request    = new WP_REST_Request( 'OPTIONS', '/wp/v2/tags' );
    990         $response   = $this->server->dispatch( $request );
     990        $response   = rest_get_server()->dispatch( $request );
    991991        $data       = $response->get_data();
    992992        $properties = $data['schema']['properties'];
     
    10131013        $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/tags' );
    10141014
    1015         $response = $this->server->dispatch( $request );
     1015        $response = rest_get_server()->dispatch( $request );
    10161016        $data     = $response->get_data();
    10171017        $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] );
     
    10211021        $request = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $tag_id );
    10221022
    1023         $response = $this->server->dispatch( $request );
     1023        $response = rest_get_server()->dispatch( $request );
    10241024        $this->assertArrayHasKey( 'my_custom_int', $response->data );
    10251025
     
    10541054        );
    10551055
    1056         $response = $this->server->dispatch( $request );
     1056        $response = rest_get_server()->dispatch( $request );
    10571057
    10581058        $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
     
    10741074        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    10751075        $request->set_param( 'post', $p );
    1076         $response = $this->server->dispatch( $request );
     1076        $response = rest_get_server()->dispatch( $request );
    10771077        $found_1  = wp_list_pluck( $response->data, 'id' );
    10781078
     
    10831083        $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    10841084        $request->set_param( 'post', $p );
    1085         $response = $this->server->dispatch( $request );
     1085        $response = rest_get_server()->dispatch( $request );
    10861086        $found_2  = wp_list_pluck( $response->data, 'id' );
    10871087
Note: See TracChangeset for help on using the changeset viewer.