- Timestamp:
- 02/21/2018 04:24:30 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-comments-controller.php
r42343 r42724 123 123 124 124 public function test_register_routes() { 125 $routes = $this->server->get_routes();125 $routes = rest_get_server()->get_routes(); 126 126 127 127 $this->assertArrayHasKey( '/wp/v2/comments', $routes ); … … 134 134 // Collection 135 135 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments' ); 136 $response = $this->server->dispatch( $request );136 $response = rest_get_server()->dispatch( $request ); 137 137 $data = $response->get_data(); 138 138 $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); … … 140 140 // Single 141 141 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments/' . self::$approved_id ); 142 $response = $this->server->dispatch( $request );142 $response = rest_get_server()->dispatch( $request ); 143 143 $data = $response->get_data(); 144 144 $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); … … 148 148 public function test_registered_query_params() { 149 149 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments' ); 150 $response = $this->server->dispatch( $request );150 $response = rest_get_server()->dispatch( $request ); 151 151 $data = $response->get_data(); 152 152 $keys = array_keys( $data['endpoints'][0]['args'] ); … … 183 183 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 184 184 185 $response = $this->server->dispatch( $request );185 $response = rest_get_server()->dispatch( $request ); 186 186 $this->assertEquals( 200, $response->get_status() ); 187 187 … … 207 207 $request->set_param( 'post', self::$password_id ); 208 208 209 $response = $this->server->dispatch( $request );209 $response = rest_get_server()->dispatch( $request ); 210 210 $this->assertEquals( 200, $response->get_status() ); 211 211 … … 228 228 $request->set_param( 'password', 'toomanysecrets' ); 229 229 230 $response = $this->server->dispatch( $request );230 $response = rest_get_server()->dispatch( $request ); 231 231 $this->assertEquals( 200, $response->get_status() ); 232 232 … … 250 250 $request->set_param( 'post', array( self::$password_id, self::$post_id ) ); 251 251 252 $response = $this->server->dispatch( $request );252 $response = rest_get_server()->dispatch( $request ); 253 253 $this->assertErrorResponse( 'rest_cannot_read_post', $response, 401 ); 254 254 } … … 265 265 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 266 266 267 $response = $this->server->dispatch( $request );267 $response = rest_get_server()->dispatch( $request ); 268 268 $this->assertEquals( 200, $response->get_status() ); 269 269 … … 283 283 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 284 284 285 $response = $this->server->dispatch( $request );285 $response = rest_get_server()->dispatch( $request ); 286 286 $this->assertEquals( 200, $response->get_status() ); 287 287 … … 301 301 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 302 302 303 $response = $this->server->dispatch( $request );303 $response = rest_get_server()->dispatch( $request ); 304 304 $this->assertEquals( 200, $response->get_status() ); 305 305 … … 319 319 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 320 320 321 $response = $this->server->dispatch( $request );321 $response = rest_get_server()->dispatch( $request ); 322 322 $this->assertEquals( 200, $response->get_status() ); 323 323 … … 338 338 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 339 339 340 $response = $this->server->dispatch( $request );340 $response = rest_get_server()->dispatch( $request ); 341 341 $this->assertEquals( 200, $response->get_status() ); 342 342 … … 359 359 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 360 360 361 $response = $this->server->dispatch( $request );361 $response = rest_get_server()->dispatch( $request ); 362 362 $this->assertEquals( 200, $response->get_status() ); 363 363 … … 372 372 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 373 373 $request->set_param( 'context', 'edit' ); 374 $response = $this->server->dispatch( $request );374 $response = rest_get_server()->dispatch( $request ); 375 375 $this->assertErrorResponse( 'rest_forbidden_context', $response, 401 ); 376 376 } … … 381 381 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 382 382 $request->set_param( 'post', 0 ); 383 $response = $this->server->dispatch( $request );383 $response = rest_get_server()->dispatch( $request ); 384 384 $this->assertEquals( 200, $response->get_status() ); 385 385 $comments = $response->get_data(); … … 391 391 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 392 392 $request->set_param( 'post', 0 ); 393 $response = $this->server->dispatch( $request );393 $response = rest_get_server()->dispatch( $request ); 394 394 $this->assertErrorResponse( 'rest_cannot_read', $response, 401 ); 395 395 } … … 399 399 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 400 400 $request->set_param( 'context', 'edit' ); 401 $response = $this->server->dispatch( $request );401 $response = rest_get_server()->dispatch( $request ); 402 402 $this->assertEquals( 200, $response->get_status() ); 403 403 } … … 414 414 ); 415 415 416 $response = $this->server->dispatch( $request );416 $response = rest_get_server()->dispatch( $request ); 417 417 $this->assertEquals( 200, $response->get_status() ); 418 418 … … 434 434 $request->set_param( 'order', 'asc' ); 435 435 $request->set_param( 'include', array( $id3, $id1 ) ); 436 $response = $this->server->dispatch( $request );436 $response = rest_get_server()->dispatch( $request ); 437 437 $data = $response->get_data(); 438 438 $this->assertEquals( 2, count( $data ) ); … … 440 440 // Orderby=>include 441 441 $request->set_param( 'orderby', 'include' ); 442 $response = $this->server->dispatch( $request );442 $response = rest_get_server()->dispatch( $request ); 443 443 $data = $response->get_data(); 444 444 $this->assertEquals( 2, count( $data ) ); … … 446 446 // Orderby=>invalid should fail. 447 447 $request->set_param( 'orderby', 'invalid' ); 448 $response = $this->server->dispatch( $request );448 $response = rest_get_server()->dispatch( $request ); 449 449 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 450 450 // fails on invalid id. 451 451 $request->set_param( 'orderby', array( 'include' ) ); 452 452 $request->set_param( 'include', array( 'invalid' ) ); 453 $response = $this->server->dispatch( $request );453 $response = rest_get_server()->dispatch( $request ); 454 454 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 455 455 } … … 464 464 $id2 = $this->factory->comment->create( $args ); 465 465 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 466 $response = $this->server->dispatch( $request );466 $response = rest_get_server()->dispatch( $request ); 467 467 $data = $response->get_data(); 468 468 $this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ), true ) ); 469 469 $this->assertTrue( in_array( $id2, wp_list_pluck( $data, 'id' ), true ) ); 470 470 $request->set_param( 'exclude', array( $id2 ) ); 471 $response = $this->server->dispatch( $request );471 $response = rest_get_server()->dispatch( $request ); 472 472 $data = $response->get_data(); 473 473 $this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ), true ) ); … … 476 476 // fails on invalid id. 477 477 $request->set_param( 'exclude', array( 'invalid' ) ); 478 $response = $this->server->dispatch( $request );478 $response = rest_get_server()->dispatch( $request ); 479 479 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 480 480 } … … 491 491 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 492 492 $request->set_param( 'offset', 1 ); 493 $response = $this->server->dispatch( $request );493 $response = rest_get_server()->dispatch( $request ); 494 494 $this->assertCount( 3, $response->get_data() ); 495 495 // 'offset' works with 'per_page' 496 496 $request->set_param( 'per_page', 2 ); 497 $response = $this->server->dispatch( $request );497 $response = rest_get_server()->dispatch( $request ); 498 498 $this->assertCount( 2, $response->get_data() ); 499 499 // 'offset' takes priority over 'page' 500 500 $request->set_param( 'page', 3 ); 501 $response = $this->server->dispatch( $request );501 $response = rest_get_server()->dispatch( $request ); 502 502 $this->assertCount( 2, $response->get_data() ); 503 503 // 'offset' with invalid value errors. 504 504 $request->set_param( 'offset', 'moreplease' ); 505 $response = $this->server->dispatch( $request );505 $response = rest_get_server()->dispatch( $request ); 506 506 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 507 507 } … … 518 518 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 519 519 // order defaults to 'desc' 520 $response = $this->server->dispatch( $request );520 $response = rest_get_server()->dispatch( $request ); 521 521 $data = $response->get_data(); 522 522 $this->assertEquals( $id3, $data[0]['id'] ); 523 523 // order=>asc 524 524 $request->set_param( 'order', 'asc' ); 525 $response = $this->server->dispatch( $request );525 $response = rest_get_server()->dispatch( $request ); 526 526 $data = $response->get_data(); 527 527 $this->assertEquals( self::$approved_id, $data[0]['id'] ); 528 528 // order=>asc,id should fail 529 529 $request->set_param( 'order', 'asc,id' ); 530 $response = $this->server->dispatch( $request );530 $response = rest_get_server()->dispatch( $request ); 531 531 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 532 532 } … … 537 537 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 538 538 $request->set_param( 'post', $post_id ); 539 $response = $this->server->dispatch( $request );539 $response = rest_get_server()->dispatch( $request ); 540 540 $this->assertErrorResponse( 'rest_cannot_read_post', $response, 401 ); 541 541 } … … 558 558 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 559 559 $request->set_param( 'author', self::$author_id ); 560 $response = $this->server->dispatch( $request );560 $response = rest_get_server()->dispatch( $request ); 561 561 $this->assertEquals( 200, $response->get_status() ); 562 562 $comments = $response->get_data(); … … 564 564 // Multiple authors are supported 565 565 $request->set_param( 'author', array( self::$author_id, self::$subscriber_id ) ); 566 $response = $this->server->dispatch( $request );566 $response = rest_get_server()->dispatch( $request ); 567 567 $this->assertEquals( 200, $response->get_status() ); 568 568 $comments = $response->get_data(); … … 570 570 // Invalid author param errors 571 571 $request->set_param( 'author', 'skippy' ); 572 $response = $this->server->dispatch( $request );572 $response = rest_get_server()->dispatch( $request ); 573 573 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 574 574 // Unavailable to unauthenticated; defaults to error 575 575 wp_set_current_user( 0 ); 576 576 $request->set_param( 'author', array( self::$author_id, self::$subscriber_id ) ); 577 $response = $this->server->dispatch( $request );577 $response = rest_get_server()->dispatch( $request ); 578 578 $this->assertErrorResponse( 'rest_forbidden_param', $response, 401 ); 579 579 } … … 594 594 595 595 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 596 $response = $this->server->dispatch( $request );596 $response = rest_get_server()->dispatch( $request ); 597 597 $comments = $response->get_data(); 598 598 $this->assertCount( 4, $comments ); … … 601 601 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 602 602 $request->set_param( 'author_exclude', self::$author_id ); 603 $response = $this->server->dispatch( $request );603 $response = rest_get_server()->dispatch( $request ); 604 604 $this->assertEquals( 200, $response->get_status() ); 605 605 $comments = $response->get_data(); … … 608 608 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 609 609 $request->set_param( 'author_exclude', array( self::$author_id, self::$subscriber_id ) ); 610 $response = $this->server->dispatch( $request );610 $response = rest_get_server()->dispatch( $request ); 611 611 $this->assertEquals( 200, $response->get_status() ); 612 612 $comments = $response->get_data(); … … 615 615 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 616 616 $request->set_param( 'author_exclude', 'skippy' ); 617 $response = $this->server->dispatch( $request );617 $response = rest_get_server()->dispatch( $request ); 618 618 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 619 619 // Unavailable to unauthenticated; defaults to error 620 620 wp_set_current_user( 0 ); 621 621 $request->set_param( 'author_exclude', array( self::$author_id, self::$subscriber_id ) ); 622 $response = $this->server->dispatch( $request );622 $response = rest_get_server()->dispatch( $request ); 623 623 $this->assertErrorResponse( 'rest_forbidden_param', $response, 401 ); 624 624 } … … 637 637 // All comments in the database 638 638 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 639 $response = $this->server->dispatch( $request );639 $response = rest_get_server()->dispatch( $request ); 640 640 $this->assertCount( 5, $response->get_data() ); 641 641 // Limit to the parent 642 642 $request->set_param( 'parent', $parent_id ); 643 $response = $this->server->dispatch( $request );643 $response = rest_get_server()->dispatch( $request ); 644 644 $this->assertCount( 1, $response->get_data() ); 645 645 // Limit to two parents 646 646 $request->set_param( 'parent', array( $parent_id, $parent_id2 ) ); 647 $response = $this->server->dispatch( $request );647 $response = rest_get_server()->dispatch( $request ); 648 648 $this->assertCount( 2, $response->get_data() ); 649 649 // Invalid parent should error 650 650 $request->set_param( 'parent', 'invalid' ); 651 $response = $this->server->dispatch( $request );651 $response = rest_get_server()->dispatch( $request ); 652 652 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 653 653 } … … 666 666 // All comments in the database 667 667 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 668 $response = $this->server->dispatch( $request );668 $response = rest_get_server()->dispatch( $request ); 669 669 $this->assertCount( 5, $response->get_data() ); 670 670 // Exclude this particular parent 671 671 $request->set_param( 'parent_exclude', $parent_id ); 672 $response = $this->server->dispatch( $request );672 $response = rest_get_server()->dispatch( $request ); 673 673 $this->assertCount( 4, $response->get_data() ); 674 674 // Exclude both comment parents 675 675 $request->set_param( 'parent_exclude', array( $parent_id, $parent_id2 ) ); 676 $response = $this->server->dispatch( $request );676 $response = rest_get_server()->dispatch( $request ); 677 677 $this->assertCount( 3, $response->get_data() ); 678 678 // Invalid parent id should error 679 679 $request->set_param( 'parent_exclude', 'invalid' ); 680 $response = $this->server->dispatch( $request );680 $response = rest_get_server()->dispatch( $request ); 681 681 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 682 682 } … … 697 697 // 3 comments, plus 1 created in construct 698 698 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 699 $response = $this->server->dispatch( $request );699 $response = rest_get_server()->dispatch( $request ); 700 700 $this->assertCount( 4, $response->get_data() ); 701 701 // One matching comments 702 702 $request->set_param( 'search', 'foo' ); 703 $response = $this->server->dispatch( $request );703 $response = rest_get_server()->dispatch( $request ); 704 704 $data = $response->get_data(); 705 705 $this->assertCount( 1, $data ); … … 719 719 } 720 720 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 721 $response = $this->server->dispatch( $request );721 $response = rest_get_server()->dispatch( $request ); 722 722 $headers = $response->get_headers(); 723 723 $this->assertEquals( 50, $headers['X-WP-Total'] ); … … 739 739 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 740 740 $request->set_param( 'page', 3 ); 741 $response = $this->server->dispatch( $request );741 $response = rest_get_server()->dispatch( $request ); 742 742 $headers = $response->get_headers(); 743 743 $this->assertEquals( 51, $headers['X-WP-Total'] ); … … 758 758 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 759 759 $request->set_param( 'page', 6 ); 760 $response = $this->server->dispatch( $request );760 $response = rest_get_server()->dispatch( $request ); 761 761 $headers = $response->get_headers(); 762 762 $this->assertEquals( 51, $headers['X-WP-Total'] ); … … 772 772 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 773 773 $request->set_param( 'page', 8 ); 774 $response = $this->server->dispatch( $request );774 $response = rest_get_server()->dispatch( $request ); 775 775 $headers = $response->get_headers(); 776 776 $this->assertEquals( 51, $headers['X-WP-Total'] ); … … 789 789 $request->set_param( 'after', rand_str() ); 790 790 $request->set_param( 'before', rand_str() ); 791 $response = $this->server->dispatch( $request );791 $response = rest_get_server()->dispatch( $request ); 792 792 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 793 793 } … … 816 816 $request->set_param( 'after', '2016-01-15T00:00:00Z' ); 817 817 $request->set_param( 'before', '2016-01-17T00:00:00Z' ); 818 $response = $this->server->dispatch( $request );818 $response = rest_get_server()->dispatch( $request ); 819 819 $data = $response->get_data(); 820 820 $this->assertCount( 1, $data ); … … 825 825 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); 826 826 827 $response = $this->server->dispatch( $request );827 $response = rest_get_server()->dispatch( $request ); 828 828 $this->assertEquals( 200, $response->get_status() ); 829 829 … … 841 841 ); 842 842 843 $response = $this->server->dispatch( $request );843 $response = rest_get_server()->dispatch( $request ); 844 844 $this->assertEquals( 200, $response->get_status() ); 845 845 … … 851 851 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); 852 852 853 $response = $this->server->dispatch( $request );853 $response = rest_get_server()->dispatch( $request ); 854 854 855 855 $data = $response->get_data(); … … 869 869 $request = new WP_REST_Request( 'GET', '/wp/v2/comments/' . REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ); 870 870 871 $response = $this->server->dispatch( $request );871 $response = rest_get_server()->dispatch( $request ); 872 872 $this->assertErrorResponse( 'rest_comment_invalid_id', $response, 404 ); 873 873 } … … 877 877 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', self::$approved_id ) ); 878 878 $request->set_param( 'context', 'edit' ); 879 $response = $this->server->dispatch( $request );879 $response = rest_get_server()->dispatch( $request ); 880 880 $this->assertErrorResponse( 'rest_forbidden_context', $response, 401 ); 881 881 } … … 891 891 $request = new WP_REST_Request( 'GET', '/wp/v2/comments/' . $comment_id ); 892 892 893 $response = $this->server->dispatch( $request );893 $response = rest_get_server()->dispatch( $request ); 894 894 $this->assertErrorResponse( 'rest_post_invalid_id', $response, 404 ); 895 895 } … … 905 905 $request = new WP_REST_Request( 'GET', '/wp/v2/comments/' . $comment_id ); 906 906 907 $response = $this->server->dispatch( $request );907 $response = rest_get_server()->dispatch( $request ); 908 908 $this->assertErrorResponse( 'rest_post_invalid_id', $response, 404 ); 909 909 } … … 914 914 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', self::$hold_id ) ); 915 915 916 $response = $this->server->dispatch( $request );916 $response = rest_get_server()->dispatch( $request ); 917 917 $this->assertErrorResponse( 'rest_cannot_read', $response, 401 ); 918 918 } … … 923 923 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', self::$hold_id ) ); 924 924 925 $response = $this->server->dispatch( $request );925 $response = rest_get_server()->dispatch( $request ); 926 926 $this->assertEquals( 200, $response->get_status() ); 927 927 } … … 946 946 947 947 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); 948 $response = $this->server->dispatch( $request );948 $response = rest_get_server()->dispatch( $request ); 949 949 $this->assertEquals( 200, $response->get_status() ); 950 950 $this->assertArrayHasKey( 'children', $response->get_links() ); … … 961 961 962 962 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); 963 $response = $this->server->dispatch( $request );963 $response = rest_get_server()->dispatch( $request ); 964 964 $this->assertEquals( 200, $response->get_status() ); 965 965 $this->assertArrayNotHasKey( 'children', $response->get_links() ); … … 974 974 $password_comment = $this->factory->comment->create( $args ); 975 975 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $password_comment ) ); 976 $response = $this->server->dispatch( $request );976 $response = rest_get_server()->dispatch( $request ); 977 977 $this->assertErrorResponse( 'rest_cannot_read', $response, 403 ); 978 978 } … … 993 993 $request->set_param( 'password', 'toomanysecrets' ); 994 994 995 $response = $this->server->dispatch( $request );995 $response = rest_get_server()->dispatch( $request ); 996 996 $this->assertEquals( 200, $response->get_status() ); 997 997 } … … 1013 1013 $request->set_body( wp_json_encode( $params ) ); 1014 1014 1015 $response = $this->server->dispatch( $request );1015 $response = rest_get_server()->dispatch( $request ); 1016 1016 $this->assertEquals( 201, $response->get_status() ); 1017 1017 … … 1084 1084 $request->set_param( 'date_gmt', $params['date_gmt'] ); 1085 1085 } 1086 $response = $this->server->dispatch( $request );1086 $response = rest_get_server()->dispatch( $request ); 1087 1087 1088 1088 update_option( 'timezone_string', '' ); … … 1118 1118 $request->set_body( wp_json_encode( $params ) ); 1119 1119 1120 $response = $this->server->dispatch( $request );1120 $response = rest_get_server()->dispatch( $request ); 1121 1121 $this->assertEquals( 201, $response->get_status() ); 1122 1122 … … 1143 1143 $request->set_body( wp_json_encode( $params ) ); 1144 1144 1145 $response = $this->server->dispatch( $request );1145 $response = rest_get_server()->dispatch( $request ); 1146 1146 1147 1147 $this->assertErrorResponse( 'test_rest_premade_error', $response, 418 ); … … 1166 1166 $request->set_body( wp_json_encode( $params ) ); 1167 1167 1168 $response = $this->server->dispatch( $request );1168 $response = rest_get_server()->dispatch( $request ); 1169 1169 1170 1170 $this->assertErrorResponse( 'rest_comment_author_data_required', $response, 400 ); … … 1186 1186 $request->set_body( wp_json_encode( $params ) ); 1187 1187 1188 $response = $this->server->dispatch( $request );1188 $response = rest_get_server()->dispatch( $request ); 1189 1189 1190 1190 $this->assertErrorResponse( 'rest_comment_author_data_required', $response, 400 ); … … 1205 1205 $request->set_body( wp_json_encode( $params ) ); 1206 1206 1207 $response = $this->server->dispatch( $request );1207 $response = rest_get_server()->dispatch( $request ); 1208 1208 $this->assertErrorResponse( 'rest_comment_author_data_required', $response, 400 ); 1209 1209 } … … 1224 1224 $request->set_body( wp_json_encode( $params ) ); 1225 1225 1226 $response = $this->server->dispatch( $request );1226 $response = rest_get_server()->dispatch( $request ); 1227 1227 $this->assertErrorResponse( 'rest_comment_author_data_required', $response, 400 ); 1228 1228 } … … 1241 1241 $request->add_header( 'content-type', 'application/json' ); 1242 1242 $request->set_body( wp_json_encode( $params ) ); 1243 $response = $this->server->dispatch( $request );1243 $response = rest_get_server()->dispatch( $request ); 1244 1244 1245 1245 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); … … 1263 1263 $request->set_body( wp_json_encode( $params ) ); 1264 1264 1265 $response = $this->server->dispatch( $request );1265 $response = rest_get_server()->dispatch( $request ); 1266 1266 $this->assertErrorResponse( 'rest_comment_content_invalid', $response, 400 ); 1267 1267 1268 1268 $params['content'] = ''; 1269 1269 $request->set_body( wp_json_encode( $params ) ); 1270 $response = $this->server->dispatch( $request );1270 $response = rest_get_server()->dispatch( $request ); 1271 1271 $this->assertErrorResponse( 'rest_comment_content_invalid', $response, 400 ); 1272 1272 } … … 1288 1288 $request->set_body( wp_json_encode( $params ) ); 1289 1289 1290 $response = $this->server->dispatch( $request );1290 $response = rest_get_server()->dispatch( $request ); 1291 1291 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 1292 1292 } … … 1314 1314 $request->add_header( 'content-type', 'application/json' ); 1315 1315 $request->set_body( wp_json_encode( $params ) ); 1316 $response = $this->server->dispatch( $request );1316 $response = rest_get_server()->dispatch( $request ); 1317 1317 $this->assertEquals( 201, $response->get_status() ); 1318 1318 … … 1340 1340 $request->set_body( wp_json_encode( $params ) ); 1341 1341 1342 $response = $this->server->dispatch( $request );1342 $response = rest_get_server()->dispatch( $request ); 1343 1343 $this->assertEquals( 201, $response->get_status() ); 1344 1344 … … 1351 1351 $collection = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 1352 1352 $collection->set_param( 'post', $post_id ); 1353 $collection_response = $this->server->dispatch( $collection );1353 $collection_response = rest_get_server()->dispatch( $collection ); 1354 1354 $collection_data = $collection_response->get_data(); 1355 1355 $this->assertEquals( $comment_id, $collection_data[0]['id'] ); … … 1378 1378 $request->set_body( wp_json_encode( $params ) ); 1379 1379 1380 $response = $this->server->dispatch( $request );1380 $response = rest_get_server()->dispatch( $request ); 1381 1381 $this->assertErrorResponse( 'rest_invalid_comment_type', $response, 400 ); 1382 1382 } … … 1400 1400 $request->set_body( wp_json_encode( $params ) ); 1401 1401 1402 $response = $this->server->dispatch( $request );1402 $response = rest_get_server()->dispatch( $request ); 1403 1403 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 1404 1404 } … … 1426 1426 $request->add_header( 'content-type', 'application/json' ); 1427 1427 $request->set_body( wp_json_encode( $params ) ); 1428 $response = $this->server->dispatch( $request );1428 $response = rest_get_server()->dispatch( $request ); 1429 1429 1430 1430 $this->assertEquals( 201, $response->get_status() ); … … 1455 1455 $request->add_header( 'content-type', 'application/json' ); 1456 1456 $request->set_body( wp_json_encode( $params ) ); 1457 $response = $this->server->dispatch( $request );1457 $response = rest_get_server()->dispatch( $request ); 1458 1458 1459 1459 $this->assertEquals( 201, $response->get_status() ); … … 1480 1480 $request->add_header( 'content-type', 'application/json' ); 1481 1481 $request->set_body( wp_json_encode( $params ) ); 1482 $response = $this->server->dispatch( $request );1482 $response = rest_get_server()->dispatch( $request ); 1483 1483 1484 1484 $this->assertErrorResponse( 'rest_comment_invalid_author', $response, 403 ); … … 1500 1500 $request->add_header( 'content-type', 'application/json' ); 1501 1501 $request->set_body( wp_json_encode( $params ) ); 1502 $response = $this->server->dispatch( $request );1502 $response = rest_get_server()->dispatch( $request ); 1503 1503 1504 1504 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); … … 1521 1521 $request->add_header( 'content-type', 'application/json' ); 1522 1522 $request->set_body( wp_json_encode( $params ) ); 1523 $response = $this->server->dispatch( $request );1523 $response = rest_get_server()->dispatch( $request ); 1524 1524 1525 1525 $this->assertErrorResponse( 'rest_comment_invalid_status', $response, 403 ); … … 1545 1545 $request->set_body( wp_json_encode( $params ) ); 1546 1546 1547 $response = $this->server->dispatch( $request );1547 $response = rest_get_server()->dispatch( $request ); 1548 1548 $this->assertEquals( 201, $response->get_status() ); 1549 1549 … … 1570 1570 $request->set_body( wp_json_encode( $params ) ); 1571 1571 1572 $response = $this->server->dispatch( $request );1572 $response = rest_get_server()->dispatch( $request ); 1573 1573 $this->assertEquals( 201, $response->get_status() ); 1574 1574 … … 1594 1594 $request->add_header( 'content-type', 'application/json' ); 1595 1595 $request->set_body( wp_json_encode( $params ) ); 1596 $response = $this->server->dispatch( $request );1596 $response = rest_get_server()->dispatch( $request ); 1597 1597 $data = $response->get_data(); 1598 1598 $new_comment = get_comment( $data['id'] ); … … 1616 1616 $request->set_body( wp_json_encode( $params ) ); 1617 1617 1618 $response = $this->server->dispatch( $request );1618 $response = rest_get_server()->dispatch( $request ); 1619 1619 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 1620 1620 } … … 1633 1633 $request->add_header( 'content-type', 'application/json' ); 1634 1634 $request->set_body( wp_json_encode( $params ) ); 1635 $response = $this->server->dispatch( $request );1635 $response = rest_get_server()->dispatch( $request ); 1636 1636 $this->assertErrorResponse( 'rest_comment_invalid_author_ip', $response, 403 ); 1637 1637 } … … 1650 1650 $request->add_header( 'content-type', 'application/json' ); 1651 1651 $request->set_body( wp_json_encode( $params ) ); 1652 $response = $this->server->dispatch( $request );1652 $response = rest_get_server()->dispatch( $request ); 1653 1653 $data = $response->get_data(); 1654 1654 $new_comment = get_comment( $data['id'] ); … … 1670 1670 $request->set_body( wp_json_encode( $params ) ); 1671 1671 1672 $response = $this->server->dispatch( $request );1672 $response = rest_get_server()->dispatch( $request ); 1673 1673 1674 1674 $this->assertErrorResponse( 'rest_comment_invalid_post_id', $response, 403 ); … … 1689 1689 $request->set_body( wp_json_encode( $params ) ); 1690 1690 1691 $response = $this->server->dispatch( $request );1691 $response = rest_get_server()->dispatch( $request ); 1692 1692 $this->assertErrorResponse( 'rest_comment_invalid_post_id', $response, 403 ); 1693 1693 } … … 1709 1709 $request->set_body( wp_json_encode( $params ) ); 1710 1710 1711 $response = $this->server->dispatch( $request );1711 $response = rest_get_server()->dispatch( $request ); 1712 1712 $this->assertErrorResponse( 'rest_comment_invalid_post_id', $response, 403 ); 1713 1713 } … … 1728 1728 $request->set_body( wp_json_encode( $params ) ); 1729 1729 1730 $response = $this->server->dispatch( $request );1730 $response = rest_get_server()->dispatch( $request ); 1731 1731 1732 1732 $this->assertErrorResponse( 'rest_comment_draft_post', $response, 403 ); … … 1748 1748 $request->set_body( wp_json_encode( $params ) ); 1749 1749 1750 $response = $this->server->dispatch( $request );1750 $response = rest_get_server()->dispatch( $request ); 1751 1751 1752 1752 $this->assertErrorResponse( 'rest_comment_trash_post', $response, 403 ); … … 1768 1768 $request->set_body( wp_json_encode( $params ) ); 1769 1769 1770 $response = $this->server->dispatch( $request );1770 $response = rest_get_server()->dispatch( $request ); 1771 1771 1772 1772 $this->assertErrorResponse( 'rest_cannot_read_post', $response, 403 ); … … 1788 1788 $request->set_body( wp_json_encode( $params ) ); 1789 1789 1790 $response = $this->server->dispatch( $request );1790 $response = rest_get_server()->dispatch( $request ); 1791 1791 $this->assertErrorResponse( 'rest_cannot_read_post', $response, 403 ); 1792 1792 } … … 1813 1813 $request->add_header( 'content-type', 'application/json' ); 1814 1814 $request->set_body( wp_json_encode( $params ) ); 1815 $response = $this->server->dispatch( $request );1815 $response = rest_get_server()->dispatch( $request ); 1816 1816 1817 1817 $this->assertEquals( 409, $response->get_status() ); … … 1833 1833 $request->add_header( 'content-type', 'application/json' ); 1834 1834 $request->set_body( wp_json_encode( $params ) ); 1835 $response = $this->server->dispatch( $request );1835 $response = rest_get_server()->dispatch( $request ); 1836 1836 1837 1837 $this->assertEquals( 403, $response->get_status() ); … … 1844 1844 $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); 1845 1845 $request->set_param( 'post', self::$post_id ); 1846 $response = $this->server->dispatch( $request );1846 $response = rest_get_server()->dispatch( $request ); 1847 1847 $this->assertEquals( 401, $response->get_status() ); 1848 1848 $data = $response->get_data(); … … 1863 1863 $request->set_body( wp_json_encode( $params ) ); 1864 1864 1865 $response = $this->server->dispatch( $request );1865 $response = rest_get_server()->dispatch( $request ); 1866 1866 $this->assertErrorResponse( 'rest_comment_author_invalid', $response, 400 ); 1867 1867 } … … 1881 1881 $request->set_body( wp_json_encode( $params ) ); 1882 1882 1883 $response = $this->server->dispatch( $request );1883 $response = rest_get_server()->dispatch( $request ); 1884 1884 1885 1885 $result = $response->get_data(); … … 1905 1905 $request->set_body( wp_json_encode( $params ) ); 1906 1906 1907 $response = $this->server->dispatch( $request );1907 $response = rest_get_server()->dispatch( $request ); 1908 1908 $this->assertEquals( 201, $response->get_status() ); 1909 1909 … … 1920 1920 $request->set_body( wp_json_encode( $params ) ); 1921 1921 1922 $response = $this->server->dispatch( $request );1922 $response = rest_get_server()->dispatch( $request ); 1923 1923 $this->assertEquals( 400, $response->get_status() ); 1924 1924 } … … 1944 1944 $request->set_body( wp_json_encode( $params ) ); 1945 1945 1946 $response = $this->server->dispatch( $request );1946 $response = rest_get_server()->dispatch( $request ); 1947 1947 1948 1948 remove_filter( 'rest_allow_anonymous_comments', array( $this, 'anonymous_comments_callback_null' ), 10, 2 ); … … 1969 1969 $request->add_header( 'content-type', 'application/json' ); 1970 1970 $request->set_body( wp_json_encode( $params ) ); 1971 $response = $this->server->dispatch( $request );1971 $response = rest_get_server()->dispatch( $request ); 1972 1972 1973 1973 $this->assertErrorResponse( 'comment_author_column_length', $response, 400 ); … … 1992 1992 $request->add_header( 'content-type', 'application/json' ); 1993 1993 $request->set_body( wp_json_encode( $params ) ); 1994 $response = $this->server->dispatch( $request );1994 $response = rest_get_server()->dispatch( $request ); 1995 1995 1996 1996 $this->assertErrorResponse( 'comment_author_email_column_length', $response, 400 ); … … 2015 2015 $request->add_header( 'content-type', 'application/json' ); 2016 2016 $request->set_body( wp_json_encode( $params ) ); 2017 $response = $this->server->dispatch( $request );2017 $response = rest_get_server()->dispatch( $request ); 2018 2018 2019 2019 $this->assertErrorResponse( 'comment_author_url_column_length', $response, 400 ); … … 2038 2038 $request->add_header( 'content-type', 'application/json' ); 2039 2039 $request->set_body( wp_json_encode( $params ) ); 2040 $response = $this->server->dispatch( $request );2040 $response = rest_get_server()->dispatch( $request ); 2041 2041 2042 2042 $this->assertErrorResponse( 'comment_content_column_length', $response, 400 ); … … 2057 2057 $request->add_header( 'content-type', 'application/json' ); 2058 2058 $request->set_body( wp_json_encode( $params ) ); 2059 $response = $this->server->dispatch( $request );2059 $response = rest_get_server()->dispatch( $request ); 2060 2060 2061 2061 $this->assertErrorResponse( 'rest_cannot_read_post', $response, 403 ); … … 2077 2077 $request->add_header( 'content-type', 'application/json' ); 2078 2078 $request->set_body( wp_json_encode( $params ) ); 2079 $response = $this->server->dispatch( $request );2079 $response = rest_get_server()->dispatch( $request ); 2080 2080 $this->assertEquals( 201, $response->get_status() ); 2081 2081 } … … 2100 2100 $request->set_body( wp_json_encode( $params ) ); 2101 2101 2102 $response = $this->server->dispatch( $request );2102 $response = rest_get_server()->dispatch( $request ); 2103 2103 $this->assertEquals( 200, $response->get_status() ); 2104 2104 … … 2133 2133 $request->set_param( 'date_gmt', $params['date_gmt'] ); 2134 2134 } 2135 $response = $this->server->dispatch( $request );2135 $response = rest_get_server()->dispatch( $request ); 2136 2136 2137 2137 update_option( 'timezone_string', '' ); … … 2159 2159 2160 2160 // Sending a request without content is fine. 2161 $response = $this->server->dispatch( $request );2161 $response = rest_get_server()->dispatch( $request ); 2162 2162 $this->assertEquals( 200, $response->get_status() ); 2163 2163 … … 2165 2165 $request->set_param( 'author_email', 'yetanother@email.com' ); 2166 2166 $request->set_param( 'content', '' ); 2167 $response = $this->server->dispatch( $request );2167 $response = rest_get_server()->dispatch( $request ); 2168 2168 $this->assertErrorResponse( 'rest_comment_content_invalid', $response, 400 ); 2169 2169 } … … 2178 2178 // Run twice to make sure that the update still succeeds even if no DB 2179 2179 // rows are updated. 2180 $response = $this->server->dispatch( $request );2181 $this->assertEquals( 200, $response->get_status() ); 2182 2183 $response = $this->server->dispatch( $request );2180 $response = rest_get_server()->dispatch( $request ); 2181 $this->assertEquals( 200, $response->get_status() ); 2182 2183 $response = rest_get_server()->dispatch( $request ); 2184 2184 $this->assertEquals( 200, $response->get_status() ); 2185 2185 } … … 2202 2202 $request->set_body( wp_json_encode( $params ) ); 2203 2203 2204 $response = $this->server->dispatch( $request );2204 $response = rest_get_server()->dispatch( $request ); 2205 2205 $this->assertEquals( 200, $response->get_status() ); 2206 2206 … … 2229 2229 $request->set_body( wp_json_encode( $params ) ); 2230 2230 2231 $response = $this->server->dispatch( $request );2231 $response = rest_get_server()->dispatch( $request ); 2232 2232 $this->assertEquals( 200, $response->get_status() ); 2233 2233 … … 2250 2250 $request->set_body( wp_json_encode( $params ) ); 2251 2251 2252 $response = $this->server->dispatch( $request );2252 $response = rest_get_server()->dispatch( $request ); 2253 2253 $this->assertEquals( 200, $response->get_status() ); 2254 2254 … … 2273 2273 $request->set_body( wp_json_encode( $params ) ); 2274 2274 2275 $response = $this->server->dispatch( $request );2275 $response = rest_get_server()->dispatch( $request ); 2276 2276 $this->assertEquals( 200, $response->get_status() ); 2277 2277 } … … 2292 2292 $request->set_body( wp_json_encode( $params ) ); 2293 2293 2294 $response = $this->server->dispatch( $request );2294 $response = rest_get_server()->dispatch( $request ); 2295 2295 $this->assertEquals( 200, $response->get_status() ); 2296 2296 } … … 2310 2310 $request->set_body( wp_json_encode( $params ) ); 2311 2311 2312 $response = $this->server->dispatch( $request );2312 $response = rest_get_server()->dispatch( $request ); 2313 2313 $this->assertEquals( 200, $response->get_status() ); 2314 2314 } … … 2329 2329 $request->set_body( wp_json_encode( $params ) ); 2330 2330 2331 $response = $this->server->dispatch( $request );2331 $response = rest_get_server()->dispatch( $request ); 2332 2332 $this->assertEquals( 200, $response->get_status() ); 2333 2333 } … … 2346 2346 $request->add_header( 'content-type', 'application/json' ); 2347 2347 $request->set_body( wp_json_encode( $params ) ); 2348 $response = $this->server->dispatch( $request );2348 $response = rest_get_server()->dispatch( $request ); 2349 2349 2350 2350 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); … … 2363 2363 $request->set_body( wp_json_encode( $params ) ); 2364 2364 2365 $response = $this->server->dispatch( $request );2365 $response = rest_get_server()->dispatch( $request ); 2366 2366 $this->assertErrorResponse( 'rest_comment_invalid_type', $response, 404 ); 2367 2367 } … … 2379 2379 $request->set_body( wp_json_encode( $params ) ); 2380 2380 2381 $response = $this->server->dispatch( $request );2381 $response = rest_get_server()->dispatch( $request ); 2382 2382 2383 2383 $this->assertEquals( 200, $response->get_status() ); … … 2400 2400 $request->set_body( wp_json_encode( $params ) ); 2401 2401 2402 $response = $this->server->dispatch( $request );2402 $response = rest_get_server()->dispatch( $request ); 2403 2403 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 2404 2404 } … … 2416 2416 $request->set_body( wp_json_encode( $params ) ); 2417 2417 2418 $response = $this->server->dispatch( $request );2418 $response = rest_get_server()->dispatch( $request ); 2419 2419 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 2420 2420 } … … 2430 2430 $request->set_body( wp_json_encode( $params ) ); 2431 2431 2432 $response = $this->server->dispatch( $request );2432 $response = rest_get_server()->dispatch( $request ); 2433 2433 $this->assertErrorResponse( 'rest_comment_invalid_id', $response, 404 ); 2434 2434 } … … 2440 2440 $request->set_param( 'post', REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ); 2441 2441 2442 $response = $this->server->dispatch( $request );2442 $response = rest_get_server()->dispatch( $request ); 2443 2443 $this->assertErrorResponse( 'rest_comment_invalid_post_id', $response, 403 ); 2444 2444 } … … 2454 2454 $request->set_body( wp_json_encode( $params ) ); 2455 2455 2456 $response = $this->server->dispatch( $request );2456 $response = rest_get_server()->dispatch( $request ); 2457 2457 $this->assertErrorResponse( 'rest_cannot_edit', $response, 401 ); 2458 2458 } … … 2476 2476 $request->set_body( wp_json_encode( $params ) ); 2477 2477 2478 $response = $this->server->dispatch( $request );2478 $response = rest_get_server()->dispatch( $request ); 2479 2479 $this->assertErrorResponse( 'rest_cannot_edit', $response, 403 ); 2480 2480 } … … 2500 2500 // Check if comment 1 does not have the child link. 2501 2501 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); 2502 $response = $this->server->dispatch( $request );2502 $response = rest_get_server()->dispatch( $request ); 2503 2503 $this->assertEquals( 200, $response->get_status() ); 2504 2504 $this->assertArrayNotHasKey( 'children', $response->get_links() ); … … 2508 2508 $request->set_param( 'parent', $comment_id_1 ); 2509 2509 $request->set_param( 'content', rand_str() ); 2510 $response = $this->server->dispatch( $request );2510 $response = rest_get_server()->dispatch( $request ); 2511 2511 $this->assertEquals( 200, $response->get_status() ); 2512 2512 2513 2513 // Check if comment 1 now has the child link. 2514 2514 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); 2515 $response = $this->server->dispatch( $request );2515 $response = rest_get_server()->dispatch( $request ); 2516 2516 $this->assertEquals( 200, $response->get_status() ); 2517 2517 $this->assertArrayHasKey( 'children', $response->get_links() ); … … 2532 2532 $request->add_header( 'content-type', 'application/json' ); 2533 2533 $request->set_body( wp_json_encode( $params ) ); 2534 $response = $this->server->dispatch( $request );2534 $response = rest_get_server()->dispatch( $request ); 2535 2535 2536 2536 $this->assertErrorResponse( 'comment_author_column_length', $response, 400 ); … … 2551 2551 $request->add_header( 'content-type', 'application/json' ); 2552 2552 $request->set_body( wp_json_encode( $params ) ); 2553 $response = $this->server->dispatch( $request );2553 $response = rest_get_server()->dispatch( $request ); 2554 2554 2555 2555 $this->assertErrorResponse( 'comment_author_email_column_length', $response, 400 ); … … 2570 2570 $request->add_header( 'content-type', 'application/json' ); 2571 2571 $request->set_body( wp_json_encode( $params ) ); 2572 $response = $this->server->dispatch( $request );2572 $response = rest_get_server()->dispatch( $request ); 2573 2573 2574 2574 $this->assertErrorResponse( 'comment_author_url_column_length', $response, 400 ); … … 2588 2588 $request->add_header( 'content-type', 'application/json' ); 2589 2589 $request->set_body( wp_json_encode( $params ) ); 2590 $response = $this->server->dispatch( $request );2590 $response = rest_get_server()->dispatch( $request ); 2591 2591 2592 2592 $this->assertErrorResponse( 'comment_content_column_length', $response, 400 ); … … 2601 2601 $request->set_param( $name, $value ); 2602 2602 } 2603 $response = $this->server->dispatch( $request );2603 $response = rest_get_server()->dispatch( $request ); 2604 2604 $this->assertEquals( 201, $response->get_status() ); 2605 2605 $actual_output = $response->get_data(); … … 2627 2627 // See https://core.trac.wordpress.org/ticket/38700 2628 2628 $request->set_param( 'author_ip', '127.0.0.2' ); 2629 $response = $this->server->dispatch( $request );2629 $response = rest_get_server()->dispatch( $request ); 2630 2630 $this->assertEquals( 200, $response->get_status() ); 2631 2631 $actual_output = $response->get_data(); … … 2751 2751 $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%d', $comment_id ) ); 2752 2752 $request->set_param( 'force', 'false' ); 2753 $response = $this->server->dispatch( $request );2753 $response = rest_get_server()->dispatch( $request ); 2754 2754 $this->assertEquals( 200, $response->get_status() ); 2755 2755 … … 2771 2771 $request['force'] = true; 2772 2772 2773 $response = $this->server->dispatch( $request );2773 $response = rest_get_server()->dispatch( $request ); 2774 2774 $this->assertEquals( 200, $response->get_status() ); 2775 2775 $data = $response->get_data(); … … 2789 2789 ); 2790 2790 $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%d', $comment_id ) ); 2791 $response = $this->server->dispatch( $request );2791 $response = rest_get_server()->dispatch( $request ); 2792 2792 $this->assertEquals( 200, $response->get_status() ); 2793 2793 $data = $response->get_data(); 2794 $response = $this->server->dispatch( $request );2794 $response = rest_get_server()->dispatch( $request ); 2795 2795 $this->assertErrorResponse( 'rest_already_trashed', $response, 410 ); 2796 2796 } … … 2801 2801 $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%d', REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ) ); 2802 2802 2803 $response = $this->server->dispatch( $request );2803 $response = rest_get_server()->dispatch( $request ); 2804 2804 $this->assertErrorResponse( 'rest_comment_invalid_id', $response, 404 ); 2805 2805 } … … 2810 2810 $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); 2811 2811 2812 $response = $this->server->dispatch( $request );2812 $response = rest_get_server()->dispatch( $request ); 2813 2813 $this->assertErrorResponse( 'rest_cannot_delete', $response, 403 ); 2814 2814 } … … 2834 2834 2835 2835 $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%s', $child_comment ) ); 2836 $response = $this->server->dispatch( $request );2836 $response = rest_get_server()->dispatch( $request ); 2837 2837 $this->assertEquals( 200, $response->get_status() ); 2838 2838 2839 2839 // Verify children link is gone. 2840 2840 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); 2841 $response = $this->server->dispatch( $request );2841 $response = rest_get_server()->dispatch( $request ); 2842 2842 $this->assertEquals( 200, $response->get_status() ); 2843 2843 $this->assertArrayNotHasKey( 'children', $response->get_links() ); … … 2846 2846 public function test_get_item_schema() { 2847 2847 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments' ); 2848 $response = $this->server->dispatch( $request );2848 $response = rest_get_server()->dispatch( $request ); 2849 2849 $data = $response->get_data(); 2850 2850 $properties = $data['schema']['properties']; … … 2878 2878 update_option( 'show_avatars', false ); 2879 2879 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/users' ); 2880 $response = $this->server->dispatch( $request );2880 $response = rest_get_server()->dispatch( $request ); 2881 2881 $data = $response->get_data(); 2882 2882 $properties = $data['schema']['properties']; … … 2904 2904 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments' ); 2905 2905 2906 $response = $this->server->dispatch( $request );2906 $response = rest_get_server()->dispatch( $request ); 2907 2907 $data = $response->get_data(); 2908 2908 … … 2912 2912 $request = new WP_REST_Request( 'GET', '/wp/v2/comments/' . self::$approved_id ); 2913 2913 2914 $response = $this->server->dispatch( $request );2914 $response = rest_get_server()->dispatch( $request ); 2915 2915 $this->assertArrayHasKey( 'my_custom_int', $response->data ); 2916 2916 … … 2924 2924 2925 2925 wp_set_current_user( 1 ); 2926 $this->server->dispatch( $request );2926 rest_get_server()->dispatch( $request ); 2927 2927 $this->assertEquals( 123, get_comment_meta( self::$approved_id, 'my_custom_int', true ) ); 2928 2928 … … 2937 2937 ); 2938 2938 2939 $response = $this->server->dispatch( $request );2939 $response = rest_get_server()->dispatch( $request ); 2940 2940 2941 2941 $this->assertEquals( 123, $response->data['my_custom_int'] ); … … 2972 2972 ); 2973 2973 2974 $response = $this->server->dispatch( $request );2974 $response = rest_get_server()->dispatch( $request ); 2975 2975 2976 2976 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
Note: See TracChangeset
for help on using the changeset viewer.