- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-comments-controller.php
r40101 r42343 28 28 29 29 public static function wpSetUpBeforeClass( $factory ) { 30 self::$superadmin_id = $factory->user->create( array( 31 'role' => 'administrator', 32 'user_login' => 'superadmin', 33 ) ); 34 self::$admin_id = $factory->user->create( array( 35 'role' => 'administrator', 36 ) ); 37 self::$editor_id = $factory->user->create( array( 38 'role' => 'editor', 39 ) ); 40 self::$subscriber_id = $factory->user->create( array( 41 'role' => 'subscriber', 42 ) ); 43 self::$author_id = $factory->user->create( array( 44 'role' => 'author', 45 'display_name' => 'Sea Captain', 46 'first_name' => 'Horatio', 47 'last_name' => 'McCallister', 48 'user_email' => 'captain@thefryingdutchman.com', 49 'user_url' => 'http://thefryingdutchman.com', 50 ) ); 51 52 self::$post_id = $factory->post->create(); 53 self::$private_id = $factory->post->create( array( 54 'post_status' => 'private', 55 ) ); 56 self::$password_id = $factory->post->create( array( 57 'post_password' => 'toomanysecrets', 58 ) ); 59 self::$draft_id = $factory->post->create( array( 60 'post_status' => 'draft', 61 ) ); 62 self::$trash_id = $factory->post->create( array( 63 'post_status' => 'trash', 64 ) ); 65 66 self::$approved_id = $factory->comment->create( array( 67 'comment_approved' => 1, 68 'comment_post_ID' => self::$post_id, 69 'user_id' => 0, 70 ) ); 71 self::$hold_id = $factory->comment->create( array( 72 'comment_approved' => 0, 73 'comment_post_ID' => self::$post_id, 74 'user_id' => self::$subscriber_id, 75 ) ); 30 self::$superadmin_id = $factory->user->create( 31 array( 32 'role' => 'administrator', 33 'user_login' => 'superadmin', 34 ) 35 ); 36 self::$admin_id = $factory->user->create( 37 array( 38 'role' => 'administrator', 39 ) 40 ); 41 self::$editor_id = $factory->user->create( 42 array( 43 'role' => 'editor', 44 ) 45 ); 46 self::$subscriber_id = $factory->user->create( 47 array( 48 'role' => 'subscriber', 49 ) 50 ); 51 self::$author_id = $factory->user->create( 52 array( 53 'role' => 'author', 54 'display_name' => 'Sea Captain', 55 'first_name' => 'Horatio', 56 'last_name' => 'McCallister', 57 'user_email' => 'captain@thefryingdutchman.com', 58 'user_url' => 'http://thefryingdutchman.com', 59 ) 60 ); 61 62 self::$post_id = $factory->post->create(); 63 self::$private_id = $factory->post->create( 64 array( 65 'post_status' => 'private', 66 ) 67 ); 68 self::$password_id = $factory->post->create( 69 array( 70 'post_password' => 'toomanysecrets', 71 ) 72 ); 73 self::$draft_id = $factory->post->create( 74 array( 75 'post_status' => 'draft', 76 ) 77 ); 78 self::$trash_id = $factory->post->create( 79 array( 80 'post_status' => 'trash', 81 ) 82 ); 83 84 self::$approved_id = $factory->comment->create( 85 array( 86 'comment_approved' => 1, 87 'comment_post_ID' => self::$post_id, 88 'user_id' => 0, 89 ) 90 ); 91 self::$hold_id = $factory->comment->create( 92 array( 93 'comment_approved' => 0, 94 'comment_post_ID' => self::$post_id, 95 'user_id' => self::$subscriber_id, 96 ) 97 ); 76 98 } 77 99 … … 111 133 public function test_context_param() { 112 134 // Collection 113 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments' );114 $response = $this->server->dispatch( $request ); 115 $data = $response->get_data();135 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments' ); 136 $response = $this->server->dispatch( $request ); 137 $data = $response->get_data(); 116 138 $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); 117 139 $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 118 140 // Single 119 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments/' . self::$approved_id );120 $response = $this->server->dispatch( $request ); 121 $data = $response->get_data();141 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments/' . self::$approved_id ); 142 $response = $this->server->dispatch( $request ); 143 $data = $response->get_data(); 122 144 $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); 123 145 $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); … … 125 147 126 148 public function test_registered_query_params() { 127 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments' );128 $response = $this->server->dispatch( $request ); 129 $data = $response->get_data();130 $keys = array_keys( $data['endpoints'][0]['args'] );149 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments' ); 150 $response = $this->server->dispatch( $request ); 151 $data = $response->get_data(); 152 $keys = array_keys( $data['endpoints'][0]['args'] ); 131 153 sort( $keys ); 132 $this->assertEquals( array( 133 'after', 134 'author', 135 'author_email', 136 'author_exclude', 137 'before', 138 'context', 139 'exclude', 140 'include', 141 'offset', 142 'order', 143 'orderby', 144 'page', 145 'parent', 146 'parent_exclude', 147 'password', 148 'per_page', 149 'post', 150 'search', 151 'status', 152 'type', 153 ), $keys ); 154 $this->assertEquals( 155 array( 156 'after', 157 'author', 158 'author_email', 159 'author_exclude', 160 'before', 161 'context', 162 'exclude', 163 'include', 164 'offset', 165 'order', 166 'orderby', 167 'page', 168 'parent', 169 'parent_exclude', 170 'password', 171 'per_page', 172 'post', 173 'search', 174 'status', 175 'type', 176 ), $keys 177 ); 154 178 } 155 179 … … 173 197 wp_set_current_user( 0 ); 174 198 175 $args = array(199 $args = array( 176 200 'comment_approved' => 1, 177 201 'comment_post_ID' => self::$password_id, … … 195 219 public function test_get_items_with_password_without_post() { 196 220 wp_set_current_user( 0 ); 197 $args = array(221 $args = array( 198 222 'comment_approved' => 1, 199 223 'comment_post_ID' => self::$password_id, … … 216 240 public function test_get_items_with_password_with_multiple_post() { 217 241 wp_set_current_user( 0 ); 218 $args = array(242 $args = array( 219 243 'comment_approved' => 1, 220 244 'comment_post_ID' => self::$password_id, … … 233 257 wp_set_current_user( 0 ); 234 258 235 $args = array(259 $args = array( 236 260 'comment_approved' => 1, 237 261 'comment_post_ID' => self::$password_id, … … 251 275 wp_set_current_user( self::$admin_id ); 252 276 253 $args = array(277 $args = array( 254 278 'comment_approved' => 1, 255 279 'comment_post_ID' => self::$password_id, … … 269 293 wp_set_current_user( 0 ); 270 294 271 $args = array(295 $args = array( 272 296 'comment_approved' => 1, 273 297 'comment_post_ID' => self::$private_id, … … 287 311 wp_set_current_user( self::$admin_id ); 288 312 289 $args = array(313 $args = array( 290 314 'comment_approved' => 1, 291 315 'comment_post_ID' => self::$private_id, … … 305 329 wp_set_current_user( 0 ); 306 330 307 $comment_id = $this->factory->comment->create( array( 308 'comment_approved' => 1, 309 'comment_post_ID' => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, 310 )); 331 $comment_id = $this->factory->comment->create( 332 array( 333 'comment_approved' => 1, 334 'comment_post_ID' => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, 335 ) 336 ); 311 337 312 338 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); … … 324 350 wp_set_current_user( self::$admin_id ); 325 351 326 $comment_id = $this->factory->comment->create( array( 327 'comment_approved' => 1, 328 'comment_post_ID' => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, 329 )); 352 $comment_id = $this->factory->comment->create( 353 array( 354 'comment_approved' => 1, 355 'comment_post_ID' => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, 356 ) 357 ); 330 358 331 359 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); … … 380 408 381 409 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 382 $request->set_query_params( array( 383 'post' => $second_post_id, 384 ) ); 410 $request->set_query_params( 411 array( 412 'post' => $second_post_id, 413 ) 414 ); 385 415 386 416 $response = $this->server->dispatch( $request ); … … 397 427 'comment_post_ID' => self::$post_id, 398 428 ); 399 $id1 = $this->factory->comment->create( $args );429 $id1 = $this->factory->comment->create( $args ); 400 430 $this->factory->comment->create( $args ); 401 $id3 = $this->factory->comment->create( $args );431 $id3 = $this->factory->comment->create( $args ); 402 432 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 403 433 // Order=>asc … … 405 435 $request->set_param( 'include', array( $id3, $id1 ) ); 406 436 $response = $this->server->dispatch( $request ); 407 $data = $response->get_data();437 $data = $response->get_data(); 408 438 $this->assertEquals( 2, count( $data ) ); 409 439 $this->assertEquals( $id1, $data[0]['id'] ); … … 411 441 $request->set_param( 'orderby', 'include' ); 412 442 $response = $this->server->dispatch( $request ); 413 $data = $response->get_data();443 $data = $response->get_data(); 414 444 $this->assertEquals( 2, count( $data ) ); 415 445 $this->assertEquals( $id3, $data[0]['id'] ); … … 427 457 public function test_get_items_exclude_query() { 428 458 wp_set_current_user( self::$admin_id ); 429 $args = array(459 $args = array( 430 460 'comment_approved' => 1, 431 461 'comment_post_ID' => self::$post_id, 432 462 ); 433 $id1 = $this->factory->comment->create( $args );434 $id2 = $this->factory->comment->create( $args );435 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );436 $response = $this->server->dispatch( $request ); 437 $data = $response->get_data();463 $id1 = $this->factory->comment->create( $args ); 464 $id2 = $this->factory->comment->create( $args ); 465 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 466 $response = $this->server->dispatch( $request ); 467 $data = $response->get_data(); 438 468 $this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ), true ) ); 439 469 $this->assertTrue( in_array( $id2, wp_list_pluck( $data, 'id' ), true ) ); 440 470 $request->set_param( 'exclude', array( $id2 ) ); 441 471 $response = $this->server->dispatch( $request ); 442 $data = $response->get_data();472 $data = $response->get_data(); 443 473 $this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ), true ) ); 444 474 $this->assertFalse( in_array( $id2, wp_list_pluck( $data, 'id' ), true ) ); … … 485 515 $this->factory->comment->create( $args ); 486 516 $this->factory->comment->create( $args ); 487 $id3 = $this->factory->comment->create( $args );517 $id3 = $this->factory->comment->create( $args ); 488 518 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 489 519 // order defaults to 'desc' 490 520 $response = $this->server->dispatch( $request ); 491 $data = $response->get_data();521 $data = $response->get_data(); 492 522 $this->assertEquals( $id3, $data[0]['id'] ); 493 523 // order=>asc 494 524 $request->set_param( 'order', 'asc' ); 495 525 $response = $this->server->dispatch( $request ); 496 $data = $response->get_data();526 $data = $response->get_data(); 497 527 $this->assertEquals( self::$approved_id, $data[0]['id'] ); 498 528 // order=>asc,id should fail … … 563 593 $this->factory->comment->create( $args ); 564 594 565 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );595 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 566 596 $response = $this->server->dispatch( $request ); 567 597 $comments = $response->get_data(); … … 595 625 596 626 public function test_get_items_parent_arg() { 597 $args = array(598 'comment_approved' 599 'comment_post_ID' 600 ); 601 $parent_id = $this->factory->comment->create( $args );602 $parent_id2 = $this->factory->comment->create( $args );627 $args = array( 628 'comment_approved' => 1, 629 'comment_post_ID' => self::$post_id, 630 ); 631 $parent_id = $this->factory->comment->create( $args ); 632 $parent_id2 = $this->factory->comment->create( $args ); 603 633 $args['comment_parent'] = $parent_id; 604 634 $this->factory->comment->create( $args ); … … 606 636 $this->factory->comment->create( $args ); 607 637 // All comments in the database 608 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );638 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 609 639 $response = $this->server->dispatch( $request ); 610 640 $this->assertCount( 5, $response->get_data() ); … … 624 654 625 655 public function test_get_items_parent_exclude_arg() { 626 $args = array(627 'comment_approved' 628 'comment_post_ID' 629 ); 630 $parent_id = $this->factory->comment->create( $args );631 $parent_id2 = $this->factory->comment->create( $args );656 $args = array( 657 'comment_approved' => 1, 658 'comment_post_ID' => self::$post_id, 659 ); 660 $parent_id = $this->factory->comment->create( $args ); 661 $parent_id2 = $this->factory->comment->create( $args ); 632 662 $args['comment_parent'] = $parent_id; 633 663 $this->factory->comment->create( $args ); … … 635 665 $this->factory->comment->create( $args ); 636 666 // All comments in the database 637 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );667 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 638 668 $response = $this->server->dispatch( $request ); 639 669 $this->assertCount( 5, $response->get_data() ); … … 654 684 public function test_get_items_search_query() { 655 685 wp_set_current_user( self::$admin_id ); 656 $args = array(686 $args = array( 657 687 'comment_approved' => 1, 658 688 'comment_post_ID' => self::$post_id, … … 660 690 'comment_author' => 'Homer J Simpson', 661 691 ); 662 $id1 = $this->factory->comment->create( $args );692 $id1 = $this->factory->comment->create( $args ); 663 693 $args['comment_content'] = 'bar'; 664 694 $this->factory->comment->create( $args ); … … 666 696 $this->factory->comment->create( $args ); 667 697 // 3 comments, plus 1 created in construct 668 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );698 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 669 699 $response = $this->server->dispatch( $request ); 670 700 $this->assertCount( 4, $response->get_data() ); … … 672 702 $request->set_param( 'search', 'foo' ); 673 703 $response = $this->server->dispatch( $request ); 674 $data = $response->get_data();704 $data = $response->get_data(); 675 705 $this->assertCount( 1, $data ); 676 706 $this->assertEquals( $id1, $data[0]['id'] ); … … 681 711 // Start of the index 682 712 for ( $i = 0; $i < 49; $i++ ) { 683 $this->factory->comment->create( array( 684 'comment_content' => "Comment {$i}", 685 'comment_post_ID' => self::$post_id, 686 ) ); 713 $this->factory->comment->create( 714 array( 715 'comment_content' => "Comment {$i}", 716 'comment_post_ID' => self::$post_id, 717 ) 718 ); 687 719 } 688 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );689 $response = $this->server->dispatch( $request ); 690 $headers = $response->get_headers();720 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 721 $response = $this->server->dispatch( $request ); 722 $headers = $response->get_headers(); 691 723 $this->assertEquals( 50, $headers['X-WP-Total'] ); 692 724 $this->assertEquals( 5, $headers['X-WP-TotalPages'] ); 693 $next_link = add_query_arg( array( 694 'page' => 2, 695 ), rest_url( '/wp/v2/comments' ) ); 725 $next_link = add_query_arg( 726 array( 727 'page' => 2, 728 ), rest_url( '/wp/v2/comments' ) 729 ); 696 730 $this->assertFalse( stripos( $headers['Link'], 'rel="prev"' ) ); 697 731 $this->assertContains( '<' . $next_link . '>; rel="next"', $headers['Link'] ); 698 732 // 3rd page 699 $this->factory->comment->create( array( 700 'comment_content' => 'Comment 51', 701 'comment_post_ID' => self::$post_id, 702 ) ); 733 $this->factory->comment->create( 734 array( 735 'comment_content' => 'Comment 51', 736 'comment_post_ID' => self::$post_id, 737 ) 738 ); 703 739 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); 704 740 $request->set_param( 'page', 3 ); 705 741 $response = $this->server->dispatch( $request ); 706 $headers = $response->get_headers();742 $headers = $response->get_headers(); 707 743 $this->assertEquals( 51, $headers['X-WP-Total'] ); 708 744 $this->assertEquals( 6, $headers['X-WP-TotalPages'] ); 709 $prev_link = add_query_arg( array( 710 'page' => 2, 711 ), rest_url( '/wp/v2/comments' ) ); 745 $prev_link = add_query_arg( 746 array( 747 'page' => 2, 748 ), rest_url( '/wp/v2/comments' ) 749 ); 712 750 $this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] ); 713 $next_link = add_query_arg( array( 714 'page' => 4, 715 ), rest_url( '/wp/v2/comments' ) ); 751 $next_link = add_query_arg( 752 array( 753 'page' => 4, 754 ), rest_url( '/wp/v2/comments' ) 755 ); 716 756 $this->assertContains( '<' . $next_link . '>; rel="next"', $headers['Link'] ); 717 757 // Last page … … 719 759 $request->set_param( 'page', 6 ); 720 760 $response = $this->server->dispatch( $request ); 721 $headers = $response->get_headers();761 $headers = $response->get_headers(); 722 762 $this->assertEquals( 51, $headers['X-WP-Total'] ); 723 763 $this->assertEquals( 6, $headers['X-WP-TotalPages'] ); 724 $prev_link = add_query_arg( array( 725 'page' => 5, 726 ), rest_url( '/wp/v2/comments' ) ); 764 $prev_link = add_query_arg( 765 array( 766 'page' => 5, 767 ), rest_url( '/wp/v2/comments' ) 768 ); 727 769 $this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] ); 728 770 $this->assertFalse( stripos( $headers['Link'], 'rel="next"' ) ); … … 731 773 $request->set_param( 'page', 8 ); 732 774 $response = $this->server->dispatch( $request ); 733 $headers = $response->get_headers();775 $headers = $response->get_headers(); 734 776 $this->assertEquals( 51, $headers['X-WP-Total'] ); 735 777 $this->assertEquals( 6, $headers['X-WP-TotalPages'] ); 736 $prev_link = add_query_arg( array( 737 'page' => 6, 738 ), rest_url( '/wp/v2/comments' ) ); 778 $prev_link = add_query_arg( 779 array( 780 'page' => 6, 781 ), rest_url( '/wp/v2/comments' ) 782 ); 739 783 $this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] ); 740 784 $this->assertFalse( stripos( $headers['Link'], 'rel="next"' ) ); … … 750 794 751 795 public function test_get_comments_valid_date() { 752 $comment1 = $this->factory->comment->create( array( 753 'comment_date' => '2016-01-15T00:00:00Z', 754 'comment_post_ID' => self::$post_id, 755 ) ); 756 $comment2 = $this->factory->comment->create( array( 757 'comment_date' => '2016-01-16T00:00:00Z', 758 'comment_post_ID' => self::$post_id, 759 ) ); 760 $comment3 = $this->factory->comment->create( array( 761 'comment_date' => '2016-01-17T00:00:00Z', 762 'comment_post_ID' => self::$post_id, 763 ) ); 796 $comment1 = $this->factory->comment->create( 797 array( 798 'comment_date' => '2016-01-15T00:00:00Z', 799 'comment_post_ID' => self::$post_id, 800 ) 801 ); 802 $comment2 = $this->factory->comment->create( 803 array( 804 'comment_date' => '2016-01-16T00:00:00Z', 805 'comment_post_ID' => self::$post_id, 806 ) 807 ); 808 $comment3 = $this->factory->comment->create( 809 array( 810 'comment_date' => '2016-01-17T00:00:00Z', 811 'comment_post_ID' => self::$post_id, 812 ) 813 ); 764 814 765 815 $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); … … 767 817 $request->set_param( 'before', '2016-01-17T00:00:00Z' ); 768 818 $response = $this->server->dispatch( $request ); 769 $data = $response->get_data();819 $data = $response->get_data(); 770 820 $this->assertCount( 1, $data ); 771 821 $this->assertEquals( $comment2, $data[0]['id'] ); … … 785 835 wp_set_current_user( self::$admin_id ); 786 836 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); 787 $request->set_query_params( array( 788 'context' => 'edit', 789 ) ); 837 $request->set_query_params( 838 array( 839 'context' => 'edit', 840 ) 841 ); 790 842 791 843 $response = $this->server->dispatch( $request ); … … 802 854 803 855 $data = $response->get_data(); 804 $this->assertArrayHasKey( 24, 805 $this->assertArrayHasKey( 48, 806 $this->assertArrayHasKey( 96, 856 $this->assertArrayHasKey( 24, $data['author_avatar_urls'] ); 857 $this->assertArrayHasKey( 48, $data['author_avatar_urls'] ); 858 $this->assertArrayHasKey( 96, $data['author_avatar_urls'] ); 807 859 808 860 $comment = get_comment( self::$approved_id ); … … 831 883 public function test_get_comment_invalid_post_id() { 832 884 wp_set_current_user( 0 ); 833 $comment_id = $this->factory->comment->create( array( 834 'comment_approved' => 1, 835 'comment_post_ID' => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, 836 )); 837 $request = new WP_REST_Request( 'GET', '/wp/v2/comments/' . $comment_id ); 885 $comment_id = $this->factory->comment->create( 886 array( 887 'comment_approved' => 1, 888 'comment_post_ID' => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, 889 ) 890 ); 891 $request = new WP_REST_Request( 'GET', '/wp/v2/comments/' . $comment_id ); 838 892 839 893 $response = $this->server->dispatch( $request ); … … 843 897 public function test_get_comment_invalid_post_id_as_admin() { 844 898 wp_set_current_user( self::$admin_id ); 845 $comment_id = $this->factory->comment->create( array( 846 'comment_approved' => 1, 847 'comment_post_ID' => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, 848 )); 849 $request = new WP_REST_Request( 'GET', '/wp/v2/comments/' . $comment_id ); 899 $comment_id = $this->factory->comment->create( 900 array( 901 'comment_approved' => 1, 902 'comment_post_ID' => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, 903 ) 904 ); 905 $request = new WP_REST_Request( 'GET', '/wp/v2/comments/' . $comment_id ); 850 906 851 907 $response = $this->server->dispatch( $request ); … … 872 928 873 929 public function test_get_comment_with_children_link() { 874 $comment_id_1 = $this->factory->comment->create( array( 875 'comment_approved' => 1, 876 'comment_post_ID' => self::$post_id, 877 'user_id' => self::$subscriber_id, 878 ) ); 879 880 $child_comment = $this->factory->comment->create( array( 881 'comment_approved' => 1, 882 'comment_parent' => $comment_id_1, 883 'comment_post_ID' => self::$post_id, 884 'user_id' => self::$subscriber_id, 885 ) ); 886 887 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); 930 $comment_id_1 = $this->factory->comment->create( 931 array( 932 'comment_approved' => 1, 933 'comment_post_ID' => self::$post_id, 934 'user_id' => self::$subscriber_id, 935 ) 936 ); 937 938 $child_comment = $this->factory->comment->create( 939 array( 940 'comment_approved' => 1, 941 'comment_parent' => $comment_id_1, 942 'comment_post_ID' => self::$post_id, 943 'user_id' => self::$subscriber_id, 944 ) 945 ); 946 947 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); 888 948 $response = $this->server->dispatch( $request ); 889 949 $this->assertEquals( 200, $response->get_status() ); … … 892 952 893 953 public function test_get_comment_without_children_link() { 894 $comment_id_1 = $this->factory->comment->create( array( 895 'comment_approved' => 1, 896 'comment_post_ID' => self::$post_id, 897 'user_id' => self::$subscriber_id, 898 ) ); 899 900 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); 954 $comment_id_1 = $this->factory->comment->create( 955 array( 956 'comment_approved' => 1, 957 'comment_post_ID' => self::$post_id, 958 'user_id' => self::$subscriber_id, 959 ) 960 ); 961 962 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); 901 963 $response = $this->server->dispatch( $request ); 902 964 $this->assertEquals( 200, $response->get_status() ); … … 906 968 public function test_get_comment_with_password_without_edit_post_permission() { 907 969 wp_set_current_user( self::$subscriber_id ); 908 $args = array(970 $args = array( 909 971 'comment_approved' => 1, 910 972 'comment_post_ID' => self::$password_id, 911 973 ); 912 974 $password_comment = $this->factory->comment->create( $args ); 913 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $password_comment ) );914 $response = $this->server->dispatch( $request );975 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $password_comment ) ); 976 $response = $this->server->dispatch( $request ); 915 977 $this->assertErrorResponse( 'rest_cannot_read', $response, 403 ); 916 978 } … … 922 984 wp_set_current_user( self::$subscriber_id ); 923 985 924 $args = array(986 $args = array( 925 987 'comment_approved' => 1, 926 988 'comment_post_ID' => self::$password_id, … … 939 1001 940 1002 $params = array( 941 'post' => self::$post_id,1003 'post' => self::$post_id, 942 1004 'author_name' => 'Comic Book Guy', 943 1005 'author_email' => 'cbg@androidsdungeon.com', 944 1006 'author_url' => 'http://androidsdungeon.com', 945 'content' => 'Worst Comment Ever!',946 'date' => '2014-11-07T10:14:25',1007 'content' => 'Worst Comment Ever!', 1008 'date' => '2014-11-07T10:14:25', 947 1009 ); 948 1010 … … 963 1025 public function comment_dates_provider() { 964 1026 return array( 965 'set date without timezone' => array(966 'params' 1027 'set date without timezone' => array( 1028 'params' => array( 967 1029 'timezone_string' => 'America/New_York', 968 1030 'date' => '2016-12-12T14:00:00', 969 1031 ), 970 1032 'results' => array( 971 'date' 972 'date_gmt' 1033 'date' => '2016-12-12T14:00:00', 1034 'date_gmt' => '2016-12-12T19:00:00', 973 1035 ), 974 1036 ), 975 1037 'set date_gmt without timezone' => array( 976 'params' 1038 'params' => array( 977 1039 'timezone_string' => 'America/New_York', 978 1040 'date_gmt' => '2016-12-12T19:00:00', 979 1041 ), 980 1042 'results' => array( 981 'date' 982 'date_gmt' 1043 'date' => '2016-12-12T14:00:00', 1044 'date_gmt' => '2016-12-12T19:00:00', 983 1045 ), 984 1046 ), 985 'set date with timezone' => array(986 'params' 1047 'set date with timezone' => array( 1048 'params' => array( 987 1049 'timezone_string' => 'America/New_York', 988 1050 'date' => '2016-12-12T18:00:00-01:00', 989 1051 ), 990 1052 'results' => array( 991 'date' 992 'date_gmt' 1053 'date' => '2016-12-12T14:00:00', 1054 'date_gmt' => '2016-12-12T19:00:00', 993 1055 ), 994 1056 ), 995 'set date_gmt with timezone' => array(996 'params' 1057 'set date_gmt with timezone' => array( 1058 'params' => array( 997 1059 'timezone_string' => 'America/New_York', 998 1060 'date_gmt' => '2016-12-12T18:00:00-01:00', 999 1061 ), 1000 1062 'results' => array( 1001 'date' 1002 'date_gmt' 1063 'date' => '2016-12-12T14:00:00', 1064 'date_gmt' => '2016-12-12T19:00:00', 1003 1065 ), 1004 1066 ), … … 1027 1089 1028 1090 $this->assertEquals( 201, $response->get_status() ); 1029 $data = $response->get_data();1091 $data = $response->get_data(); 1030 1092 $comment = get_comment( $data['id'] ); 1031 1093 … … 1059 1121 $this->assertEquals( 201, $response->get_status() ); 1060 1122 1061 $data = $response->get_data();1123 $data = $response->get_data(); 1062 1124 $new_comment = get_comment( $data['id'] ); 1063 1125 $this->assertEquals( $params['content']['raw'], $new_comment->comment_content ); … … 1073 1135 'author_email' => 'homer@example.org', 1074 1136 'content' => array( 1075 'raw' => 'Aw, he loves beer. Here, little fella.' 1137 'raw' => 'Aw, he loves beer. Here, little fella.', 1076 1138 ), 1077 1139 ); … … 1232 1294 1233 1295 public function test_create_item_assign_different_user() { 1234 $subscriber_id = $this->factory->user->create( array( 1235 'role' => 'subscriber', 1236 'user_email' => 'cbg@androidsdungeon.com', 1237 )); 1238 1239 wp_set_current_user( self::$admin_id ); 1240 $params = array( 1241 'post' => self::$post_id, 1296 $subscriber_id = $this->factory->user->create( 1297 array( 1298 'role' => 'subscriber', 1299 'user_email' => 'cbg@androidsdungeon.com', 1300 ) 1301 ); 1302 1303 wp_set_current_user( self::$admin_id ); 1304 $params = array( 1305 'post' => self::$post_id, 1242 1306 'author_name' => 'Comic Book Guy', 1243 1307 'author_email' => 'cbg@androidsdungeon.com', 1244 1308 'author_url' => 'http://androidsdungeon.com', 1245 'author' => $subscriber_id,1246 'content' => 'Worst Comment Ever!',1247 'date' => '2014-11-07T10:14:25',1309 'author' => $subscriber_id, 1310 'content' => 'Worst Comment Ever!', 1311 'date' => '2014-11-07T10:14:25', 1248 1312 ); 1249 1313 $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); … … 1263 1327 1264 1328 $params = array( 1265 'post' => $post_id,1329 'post' => $post_id, 1266 1330 'author' => self::$admin_id, 1267 1331 'author_name' => 'Comic Book Guy', 1268 1332 'author_email' => 'cbg@androidsdungeon.com', 1269 1333 'author_url' => 'http://androidsdungeon.com', 1270 'content' => 'Worst Comment Ever!',1271 'date' => '2014-11-07T10:14:25',1334 'content' => 'Worst Comment Ever!', 1335 'date' => '2014-11-07T10:14:25', 1272 1336 ); 1273 1337 … … 1288 1352 $collection->set_param( 'post', $post_id ); 1289 1353 $collection_response = $this->server->dispatch( $collection ); 1290 $collection_data = $collection_response->get_data();1354 $collection_data = $collection_response->get_data(); 1291 1355 $this->assertEquals( $comment_id, $collection_data[0]['id'] ); 1292 1356 } … … 1300 1364 1301 1365 $params = array( 1302 'post' => $post_id,1366 'post' => $post_id, 1303 1367 'author' => self::$admin_id, 1304 1368 'author_name' => 'Comic Book Guy', 1305 1369 'author_email' => 'cbg@androidsdungeon.com', 1306 1370 'author_url' => 'http://androidsdungeon.com', 1307 'content' => 'Worst Comment Ever!',1308 'date' => '2014-11-07T10:14:25',1309 'type' => 'foo',1371 'content' => 'Worst Comment Ever!', 1372 'date' => '2014-11-07T10:14:25', 1373 'type' => 'foo', 1310 1374 ); 1311 1375 … … 1323 1387 1324 1388 $params = array( 1325 'post' 1326 'author' 1389 'post' => $post_id, 1390 'author' => self::$admin_id, 1327 1391 'author_name' => 'Comic Book Guy', 1328 1392 'author_email' => 'hello:)', 1329 1393 'author_url' => 'http://androidsdungeon.com', 1330 'content' => 'Worst Comment Ever!',1331 'date' 1394 'content' => 'Worst Comment Ever!', 1395 'date' => '2014-11-07T10:14:25', 1332 1396 ); 1333 1397 … … 1341 1405 1342 1406 public function test_create_item_current_user() { 1343 $user_id = $this->factory->user->create( array( 1344 'role' => 'subscriber', 1345 'user_email' => 'lylelanley@example.com', 1346 'first_name' => 'Lyle', 1347 'last_name' => 'Lanley', 1348 'display_name' => 'Lyle Lanley', 1349 'user_url' => 'http://simpsons.wikia.com/wiki/Lyle_Lanley', 1350 )); 1407 $user_id = $this->factory->user->create( 1408 array( 1409 'role' => 'subscriber', 1410 'user_email' => 'lylelanley@example.com', 1411 'first_name' => 'Lyle', 1412 'last_name' => 'Lanley', 1413 'display_name' => 'Lyle Lanley', 1414 'user_url' => 'http://simpsons.wikia.com/wiki/Lyle_Lanley', 1415 ) 1416 ); 1351 1417 1352 1418 wp_set_current_user( $user_id ); 1353 1419 1354 1420 $params = array( 1355 'post' => self::$post_id,1421 'post' => self::$post_id, 1356 1422 'content' => "Well sir, there's nothing on earth like a genuine, bona fide, electrified, six-car Monorail!", 1357 1423 ); … … 1367 1433 1368 1434 // Check author data matches 1369 $author = get_user_by( 'id', $user_id );1435 $author = get_user_by( 'id', $user_id ); 1370 1436 $comment = get_comment( $data['id'] ); 1371 1437 $this->assertEquals( $author->display_name, $comment->comment_author ); … … 1378 1444 1379 1445 $params = array( 1380 'post' => self::$post_id,1446 'post' => self::$post_id, 1381 1447 'author_name' => 'Homer Jay Simpson', 1382 1448 'author_email' => 'chunkylover53@aol.com', 1383 1449 'author_url' => 'http://compuglobalhypermeganet.com', 1384 'content' => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.',1385 'author' => self::$subscriber_id,1450 'content' => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.', 1451 'author' => self::$subscriber_id, 1386 1452 ); 1387 1453 … … 1423 1489 1424 1490 $params = array( 1425 'post' 1491 'post' => 'some-slug', 1426 1492 'author_name' => 'Homer Jay Simpson', 1427 1493 'author_email' => 'chunkylover53@aol.com', 1428 1494 'author_url' => 'http://compuglobalhypermeganet.com', 1429 'content' 1430 'author' 1495 'content' => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.', 1496 'author' => self::$subscriber_id, 1431 1497 ); 1432 1498 … … 1449 1515 'content' => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.', 1450 1516 'author' => self::$subscriber_id, 1451 'status' 1517 'status' => 'approved', 1452 1518 ); 1453 1519 … … 1465 1531 1466 1532 $params = array( 1467 'post' => $post_id,1468 'author_name' => 'Comic Book Guy',1469 'author_email' => 'cbg@androidsdungeon.com',1470 'author_ip' => '139.130.4.5',1471 'author_url' => 'http://androidsdungeon.com',1533 'post' => $post_id, 1534 'author_name' => 'Comic Book Guy', 1535 'author_email' => 'cbg@androidsdungeon.com', 1536 'author_ip' => '139.130.4.5', 1537 'author_url' => 'http://androidsdungeon.com', 1472 1538 'author_user_agent' => 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36', 1473 'content' => 'Worst Comment Ever!',1474 'status' => 'approved',1539 'content' => 'Worst Comment Ever!', 1540 'status' => 'approved', 1475 1541 ); 1476 1542 … … 1516 1582 wp_set_current_user( self::$admin_id ); 1517 1583 1518 $params = array(1584 $params = array( 1519 1585 'post' => self::$post_id, 1520 1586 'author_name' => 'Comic Book Guy', … … 1528 1594 $request->add_header( 'content-type', 'application/json' ); 1529 1595 $request->set_body( wp_json_encode( $params ) ); 1530 $response = $this->server->dispatch( $request );1531 $data = $response->get_data();1596 $response = $this->server->dispatch( $request ); 1597 $data = $response->get_data(); 1532 1598 $new_comment = get_comment( $data['id'] ); 1533 1599 $this->assertEquals( '127.0.0.3', $new_comment->comment_author_IP ); … … 1537 1603 wp_set_current_user( self::$admin_id ); 1538 1604 1539 $params = array(1605 $params = array( 1540 1606 'post' => self::$post_id, 1541 1607 'author_name' => 'Comic Book Guy', … … 1556 1622 public function test_create_comment_author_ip_no_permission() { 1557 1623 wp_set_current_user( self::$subscriber_id ); 1558 $params = array(1624 $params = array( 1559 1625 'author_name' => 'Comic Book Guy', 1560 1626 'author_email' => 'cbg@androidsdungeon.com', … … 1574 1640 wp_set_current_user( self::$admin_id ); 1575 1641 $_SERVER['REMOTE_ADDR'] = '127.0.0.2'; 1576 $params = array(1642 $params = array( 1577 1643 'post' => self::$post_id, 1578 1644 'author_name' => 'Comic Book Guy', … … 1581 1647 'content' => 'Worst Comment Ever!', 1582 1648 ); 1583 $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );1584 $request->add_header( 'content-type', 'application/json' ); 1585 $request->set_body( wp_json_encode( $params ) ); 1586 $response = $this->server->dispatch( $request );1587 $data = $response->get_data();1649 $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); 1650 $request->add_header( 'content-type', 'application/json' ); 1651 $request->set_body( wp_json_encode( $params ) ); 1652 $response = $this->server->dispatch( $request ); 1653 $data = $response->get_data(); 1588 1654 $new_comment = get_comment( $data['id'] ); 1589 1655 $this->assertEquals( '127.0.0.2', $new_comment->comment_author_IP ); … … 1593 1659 wp_set_current_user( self::$admin_id ); 1594 1660 1595 $params = array(1661 $params = array( 1596 1662 'author_name' => 'Comic Book Guy', 1597 1663 'author_email' => 'cbg@androidsdungeon.com', … … 1612 1678 wp_set_current_user( self::$subscriber_id ); 1613 1679 1614 $params = array(1680 $params = array( 1615 1681 'author_name' => 'Homer Jay Simpson', 1616 1682 'author_email' => 'chunkylover53@aol.com', … … 1650 1716 wp_set_current_user( self::$subscriber_id ); 1651 1717 1652 $params = array(1718 $params = array( 1653 1719 'post' => self::$draft_id, 1654 1720 'author_name' => 'Ishmael', … … 1670 1736 wp_set_current_user( self::$subscriber_id ); 1671 1737 1672 $params = array(1738 $params = array( 1673 1739 'post' => self::$trash_id, 1674 1740 'author_name' => 'Ishmael', … … 1690 1756 wp_set_current_user( self::$subscriber_id ); 1691 1757 1692 $params = array(1758 $params = array( 1693 1759 'post' => self::$private_id, 1694 1760 'author_name' => 'Homer Jay Simpson', … … 1710 1776 wp_set_current_user( self::$subscriber_id ); 1711 1777 1712 $params = array(1778 $params = array( 1713 1779 'post' => self::$password_id, 1714 1780 'author_name' => 'Homer Jay Simpson', … … 1738 1804 1739 1805 $params = array( 1740 'post' => self::$post_id,1806 'post' => self::$post_id, 1741 1807 'author_name' => 'Guy N. Cognito', 1742 1808 'author_email' => 'chunkylover53@aol.co.uk', 1743 'content' => 'Homer? Who is Homer? My name is Guy N. Cognito.',1809 'content' => 'Homer? Who is Homer? My name is Guy N. Cognito.', 1744 1810 ); 1745 1811 … … 1753 1819 1754 1820 public function test_create_comment_closed() { 1755 $post_id = $this->factory->post->create( array( 1756 'comment_status' => 'closed', 1757 )); 1821 $post_id = $this->factory->post->create( 1822 array( 1823 'comment_status' => 'closed', 1824 ) 1825 ); 1758 1826 wp_set_current_user( self::$subscriber_id ); 1759 1827 1760 1828 $params = array( 1761 'post' 1829 'post' => $post_id, 1762 1830 ); 1763 1831 … … 1786 1854 1787 1855 $params = array( 1788 'post' 1789 'author' 1790 'content' 1856 'post' => self::$post_id, 1857 'author' => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, 1858 'content' => 'It\'s all over\, people! We don\'t have a prayer!', 1791 1859 ); 1792 1860 … … 1804 1872 $author = new WP_User( self::$author_id ); 1805 1873 $params = array( 1806 'post' 1807 'author' 1808 'content' 1874 'post' => self::$post_id, 1875 'author' => self::$author_id, 1876 'content' => 'It\'s all over\, people! We don\'t have a prayer!', 1809 1877 ); 1810 1878 … … 1826 1894 1827 1895 $params = array( 1828 'post' => self::$post_id,1829 'author_name' => 'Comic Book Guy',1830 'author_email' => 'cbg@androidsdungeon.com',1831 'author_url' => 'http://androidsdungeon.com',1832 'content' => 'Worst Comment Ever!',1833 );1834 1835 $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );1836 $request->add_header( 'content-type', 'application/json' );1837 $request->set_body( wp_json_encode( $params ) );1838 1839 $response = $this->server->dispatch( $request );1840 $this->assertEquals( 201, $response->get_status() );1841 1842 $params = array(1843 'post' => self::$post_id,1844 'author_name' => 'Comic Book Guy',1845 'author_email' => 'cbg@androidsdungeon.com',1846 'author_url' => 'http://androidsdungeon.com',1847 'content' => 'Shakes fist at sky',1848 );1849 1850 $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );1851 $request->add_header( 'content-type', 'application/json' );1852 $request->set_body( wp_json_encode( $params ) );1853 1854 $response = $this->server->dispatch( $request );1855 $this->assertEquals( 400, $response->get_status() );1856 }1857 1858 public function anonymous_comments_callback_null() {1859 // I'm a plugin developer who forgot to include a return value for some1860 // code path in my 'rest_allow_anonymous_comments' filter.1861 }1862 1863 public function test_allow_anonymous_comments_null() {1864 add_filter( 'rest_allow_anonymous_comments', array( $this, 'anonymous_comments_callback_null' ), 10, 2 );1865 1866 $params = array(1867 1896 'post' => self::$post_id, 1868 1897 'author_name' => 'Comic Book Guy', … … 1877 1906 1878 1907 $response = $this->server->dispatch( $request ); 1908 $this->assertEquals( 201, $response->get_status() ); 1909 1910 $params = array( 1911 'post' => self::$post_id, 1912 'author_name' => 'Comic Book Guy', 1913 'author_email' => 'cbg@androidsdungeon.com', 1914 'author_url' => 'http://androidsdungeon.com', 1915 'content' => 'Shakes fist at sky', 1916 ); 1917 1918 $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); 1919 $request->add_header( 'content-type', 'application/json' ); 1920 $request->set_body( wp_json_encode( $params ) ); 1921 1922 $response = $this->server->dispatch( $request ); 1923 $this->assertEquals( 400, $response->get_status() ); 1924 } 1925 1926 public function anonymous_comments_callback_null() { 1927 // I'm a plugin developer who forgot to include a return value for some 1928 // code path in my 'rest_allow_anonymous_comments' filter. 1929 } 1930 1931 public function test_allow_anonymous_comments_null() { 1932 add_filter( 'rest_allow_anonymous_comments', array( $this, 'anonymous_comments_callback_null' ), 10, 2 ); 1933 1934 $params = array( 1935 'post' => self::$post_id, 1936 'author_name' => 'Comic Book Guy', 1937 'author_email' => 'cbg@androidsdungeon.com', 1938 'author_url' => 'http://androidsdungeon.com', 1939 'content' => 'Worst Comment Ever!', 1940 ); 1941 1942 $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); 1943 $request->add_header( 'content-type', 'application/json' ); 1944 $request->set_body( wp_json_encode( $params ) ); 1945 1946 $response = $this->server->dispatch( $request ); 1879 1947 1880 1948 remove_filter( 'rest_allow_anonymous_comments', array( $this, 'anonymous_comments_callback_null' ), 10, 2 ); … … 1889 1957 wp_set_current_user( self::$subscriber_id ); 1890 1958 1891 $params = array(1959 $params = array( 1892 1960 'post' => self::$post_id, 1893 1961 'author_name' => rand_long_str( 246 ), … … 1912 1980 wp_set_current_user( self::$subscriber_id ); 1913 1981 1914 $params = array(1982 $params = array( 1915 1983 'post' => self::$post_id, 1916 1984 'author_name' => 'Bleeding Gums Murphy', … … 1935 2003 wp_set_current_user( self::$subscriber_id ); 1936 2004 1937 $params = array(2005 $params = array( 1938 2006 'post' => self::$post_id, 1939 2007 'author_name' => 'Bleeding Gums Murphy', … … 1958 2026 wp_set_current_user( self::$subscriber_id ); 1959 2027 1960 $params = array(2028 $params = array( 1961 2029 'post' => self::$post_id, 1962 2030 'author_name' => 'Bleeding Gums Murphy', … … 1978 2046 wp_set_current_user( self::$subscriber_id ); 1979 2047 1980 $params = array(2048 $params = array( 1981 2049 'post' => self::$password_id, 1982 2050 'author_name' => 'Bleeding Gums Murphy', … … 1997 2065 add_filter( 'rest_allow_anonymous_comments', '__return_true' ); 1998 2066 1999 $params = array(2067 $params = array( 2000 2068 'post' => self::$password_id, 2001 2069 'author_name' => 'Bleeding Gums Murphy', … … 2018 2086 wp_set_current_user( self::$admin_id ); 2019 2087 2020 $params = array(2088 $params = array( 2021 2089 'author' => self::$subscriber_id, 2022 2090 'author_name' => 'Disco Stu', … … 2070 2138 2071 2139 $this->assertEquals( 200, $response->get_status() ); 2072 $data = $response->get_data();2140 $data = $response->get_data(); 2073 2141 $comment = get_comment( $data['id'] ); 2074 2142 … … 2120 2188 wp_set_current_user( self::$admin_id ); 2121 2189 2122 $comment_id = $this->factory->comment->create( array( 2123 'comment_approved' => 0, 2124 'comment_post_ID' => self::$post_id, 2125 )); 2126 2127 $params = array( 2190 $comment_id = $this->factory->comment->create( 2191 array( 2192 'comment_approved' => 0, 2193 'comment_post_ID' => self::$post_id, 2194 ) 2195 ); 2196 2197 $params = array( 2128 2198 'status' => 'approve', 2129 2199 ); … … 2144 2214 wp_set_current_user( self::$admin_id ); 2145 2215 2146 $comment_id = $this->factory->comment->create( array( 2147 'comment_approved' => 0, 2148 'comment_post_ID' => self::$post_id, 2149 'comment_content' => 'some content', 2150 )); 2151 2152 $params = array( 2216 $comment_id = $this->factory->comment->create( 2217 array( 2218 'comment_approved' => 0, 2219 'comment_post_ID' => self::$post_id, 2220 'comment_content' => 'some content', 2221 ) 2222 ); 2223 2224 $params = array( 2153 2225 'status' => 'approve', 2154 2226 ); … … 2170 2242 wp_set_current_user( self::$admin_id ); 2171 2243 2172 $params = array(2244 $params = array( 2173 2245 'date_gmt' => '2015-05-07T10:14:25', 2174 2246 'content' => 'I\'ll be deep in the cold, cold ground before I recognize Missouri.', … … 2284 2356 wp_set_current_user( self::$admin_id ); 2285 2357 2286 $params = array(2358 $params = array( 2287 2359 'type' => 'trackback', 2288 2360 ); … … 2298 2370 wp_set_current_user( self::$admin_id ); 2299 2371 2300 $params = array(2372 $params = array( 2301 2373 'content' => array( 2302 2374 'raw' => 'What the heck kind of name is Persephone?', … … 2351 2423 wp_set_current_user( self::$subscriber_id ); 2352 2424 2353 $params = array(2425 $params = array( 2354 2426 'content' => 'Oh, they have the internet on computers now!', 2355 2427 ); … … 2375 2447 add_filter( 'rest_allow_anonymous_comments', '__return_true' ); 2376 2448 2377 $params = array(2449 $params = array( 2378 2450 'content' => 'Disco Stu likes disco music.', 2379 2451 ); … … 2387 2459 2388 2460 public function test_update_comment_private_post_invalid_permission() { 2389 $private_comment_id = $this->factory->comment->create( array( 2390 'comment_approved' => 1, 2391 'comment_post_ID' => self::$private_id, 2392 'user_id' => 0, 2393 )); 2461 $private_comment_id = $this->factory->comment->create( 2462 array( 2463 'comment_approved' => 1, 2464 'comment_post_ID' => self::$private_id, 2465 'user_id' => 0, 2466 ) 2467 ); 2394 2468 2395 2469 wp_set_current_user( self::$subscriber_id ); 2396 2470 2397 $params = array(2471 $params = array( 2398 2472 'content' => 'Disco Stu likes disco music.', 2399 2473 ); … … 2408 2482 public function test_update_comment_with_children_link() { 2409 2483 wp_set_current_user( self::$admin_id ); 2410 $comment_id_1 = $this->factory->comment->create( array( 2411 'comment_approved' => 1, 2412 'comment_post_ID' => self::$post_id, 2413 'user_id' => self::$subscriber_id, 2414 ) ); 2415 2416 $child_comment = $this->factory->comment->create( array( 2417 'comment_approved' => 1, 2418 'comment_post_ID' => self::$post_id, 2419 'user_id' => self::$subscriber_id, 2420 ) ); 2484 $comment_id_1 = $this->factory->comment->create( 2485 array( 2486 'comment_approved' => 1, 2487 'comment_post_ID' => self::$post_id, 2488 'user_id' => self::$subscriber_id, 2489 ) 2490 ); 2491 2492 $child_comment = $this->factory->comment->create( 2493 array( 2494 'comment_approved' => 1, 2495 'comment_post_ID' => self::$post_id, 2496 'user_id' => self::$subscriber_id, 2497 ) 2498 ); 2421 2499 2422 2500 // Check if comment 1 does not have the child link. 2423 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) );2501 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); 2424 2502 $response = $this->server->dispatch( $request ); 2425 2503 $this->assertEquals( 200, $response->get_status() ); … … 2434 2512 2435 2513 // Check if comment 1 now has the child link. 2436 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) );2514 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); 2437 2515 $response = $this->server->dispatch( $request ); 2438 2516 $this->assertEquals( 200, $response->get_status() ); … … 2446 2524 wp_set_current_user( self::$admin_id ); 2447 2525 2448 $params = array(2526 $params = array( 2449 2527 'author_name' => rand_long_str( 246 ), 2450 2528 'content' => 'This isn\'t a saxophone. It\'s an umbrella.', … … 2465 2543 wp_set_current_user( self::$admin_id ); 2466 2544 2467 $params = array(2545 $params = array( 2468 2546 'author_email' => 'murphy@' . rand_long_str( 190 ) . '.com', 2469 2547 'content' => 'This isn\'t a saxophone. It\'s an umbrella.', … … 2484 2562 wp_set_current_user( self::$admin_id ); 2485 2563 2486 $params = array(2564 $params = array( 2487 2565 'author_url' => 'http://jazz.' . rand_long_str( 185 ) . '.com', 2488 2566 'content' => 'This isn\'t a saxophone. It\'s an umbrella.', … … 2503 2581 wp_set_current_user( self::$admin_id ); 2504 2582 2505 $params = array(2583 $params = array( 2506 2584 'content' => rand_long_str( 66525 ), 2507 2585 ); … … 2530 2608 $this->assertInternalType( 'array', $actual_output['content'] ); 2531 2609 $this->assertArrayHasKey( 'raw', $actual_output['content'] ); 2532 $this->assertEquals( $expected_output['content']['raw'] 2610 $this->assertEquals( $expected_output['content']['raw'], $actual_output['content']['raw'] ); 2533 2611 $this->assertEquals( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) ); 2534 $this->assertEquals( $expected_output['author_name'] 2535 $this->assertEquals( $expected_output['author_user_agent'] 2612 $this->assertEquals( $expected_output['author_name'], $actual_output['author_name'] ); 2613 $this->assertEquals( $expected_output['author_user_agent'], $actual_output['author_user_agent'] ); 2536 2614 2537 2615 // Compare expected API output to WP internal values 2538 2616 $comment = get_comment( $actual_output['id'] ); 2539 $this->assertEquals( $expected_output['content']['raw'] 2540 $this->assertEquals( $expected_output['author_name'] 2617 $this->assertEquals( $expected_output['content']['raw'], $comment->comment_content ); 2618 $this->assertEquals( $expected_output['author_name'], $comment->comment_author ); 2541 2619 $this->assertEquals( $expected_output['author_user_agent'], $comment->comment_agent ); 2542 2620 … … 2554 2632 2555 2633 // Compare expected API output to actual API output 2556 $this->assertEquals( $expected_output['content']['raw'] 2634 $this->assertEquals( $expected_output['content']['raw'], $actual_output['content']['raw'] ); 2557 2635 $this->assertEquals( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) ); 2558 $this->assertEquals( $expected_output['author_name'] 2559 $this->assertEquals( $expected_output['author_user_agent'] 2636 $this->assertEquals( $expected_output['author_name'], $actual_output['author_name'] ); 2637 $this->assertEquals( $expected_output['author_user_agent'], $actual_output['author_user_agent'] ); 2560 2638 2561 2639 // Compare expected API output to WP internal values 2562 2640 $comment = get_comment( $actual_output['id'] ); 2563 $this->assertEquals( $expected_output['content']['raw'] 2564 $this->assertEquals( $expected_output['author_name'] 2641 $this->assertEquals( $expected_output['content']['raw'], $comment->comment_content ); 2642 $this->assertEquals( $expected_output['author_name'], $comment->comment_author ); 2565 2643 $this->assertEquals( $expected_output['author_user_agent'], $comment->comment_agent ); 2566 2644 } … … 2569 2647 wp_set_current_user( self::$editor_id ); 2570 2648 $this->assertEquals( ! is_multisite(), current_user_can( 'unfiltered_html' ) ); 2571 $this->verify_comment_roundtrip( array( 2572 'content' => '\o/ ¯\_(ツ)_/¯', 2573 'author_name' => '\o/ ¯\_(ツ)_/¯', 2574 'author_user_agent' => '\o/ ¯\_(ツ)_/¯', 2575 ), array( 2576 'content' => array( 2577 'raw' => '\o/ ¯\_(ツ)_/¯', 2578 'rendered' => '<p>\o/ ¯\_(ツ)_/¯</p>', 2579 ), 2580 'author_name' => '\o/ ¯\_(ツ)_/¯', 2581 'author_user_agent' => '\o/ ¯\_(ツ)_/¯', 2582 ) ); 2649 $this->verify_comment_roundtrip( 2650 array( 2651 'content' => '\o/ ¯\_(ツ)_/¯', 2652 'author_name' => '\o/ ¯\_(ツ)_/¯', 2653 'author_user_agent' => '\o/ ¯\_(ツ)_/¯', 2654 ), array( 2655 'content' => array( 2656 'raw' => '\o/ ¯\_(ツ)_/¯', 2657 'rendered' => '<p>\o/ ¯\_(ツ)_/¯</p>', 2658 ), 2659 'author_name' => '\o/ ¯\_(ツ)_/¯', 2660 'author_user_agent' => '\o/ ¯\_(ツ)_/¯', 2661 ) 2662 ); 2583 2663 } 2584 2664 … … 2587 2667 if ( is_multisite() ) { 2588 2668 $this->assertFalse( current_user_can( 'unfiltered_html' ) ); 2589 $this->verify_comment_roundtrip( array( 2669 $this->verify_comment_roundtrip( 2670 array( 2671 'content' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2672 'author_name' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2673 'author_user_agent' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2674 ), array( 2675 'content' => array( 2676 'raw' => 'div <strong>strong</strong> oh noes', 2677 'rendered' => '<p>div <strong>strong</strong> oh noes</p>', 2678 ), 2679 'author_name' => 'div strong', 2680 'author_user_agent' => 'div strong', 2681 ) 2682 ); 2683 } else { 2684 $this->assertTrue( current_user_can( 'unfiltered_html' ) ); 2685 $this->verify_comment_roundtrip( 2686 array( 2687 'content' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2688 'author_name' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2689 'author_user_agent' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2690 ), array( 2691 'content' => array( 2692 'raw' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2693 'rendered' => "<div>div</div>\n<p> <strong>strong</strong> <script>oh noes</script></p>", 2694 ), 2695 'author_name' => 'div strong', 2696 'author_user_agent' => 'div strong', 2697 ) 2698 ); 2699 } 2700 } 2701 2702 public function test_comment_roundtrip_as_superadmin() { 2703 wp_set_current_user( self::$superadmin_id ); 2704 $this->assertTrue( current_user_can( 'unfiltered_html' ) ); 2705 $this->verify_comment_roundtrip( 2706 array( 2707 'content' => '\\\&\\\ & &invalid; < < &lt;', 2708 'author_name' => '\\\&\\\ & &invalid; < < &lt;', 2709 'author_user_agent' => '\\\&\\\ & &invalid; < < &lt;', 2710 ), array( 2711 'content' => array( 2712 'raw' => '\\\&\\\ & &invalid; < < &lt;', 2713 'rendered' => '<p>\\\&\\\ & &invalid; < < &lt;' . "\n</p>", 2714 ), 2715 'author_name' => '\\\&\\\ & &invalid; < < &lt;', 2716 'author_user_agent' => '\\\&\\\ & &invalid; < < &lt;', 2717 ) 2718 ); 2719 } 2720 2721 public function test_comment_roundtrip_as_superadmin_unfiltered_html() { 2722 wp_set_current_user( self::$superadmin_id ); 2723 $this->assertTrue( current_user_can( 'unfiltered_html' ) ); 2724 $this->verify_comment_roundtrip( 2725 array( 2590 2726 'content' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2591 2727 'author_name' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2592 2728 'author_user_agent' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2593 2729 ), array( 2594 'content' => array( 2595 'raw' => 'div <strong>strong</strong> oh noes', 2596 'rendered' => '<p>div <strong>strong</strong> oh noes</p>', 2597 ), 2598 'author_name' => 'div strong', 2599 'author_user_agent' => 'div strong', 2600 ) ); 2601 } else { 2602 $this->assertTrue( current_user_can( 'unfiltered_html' ) ); 2603 $this->verify_comment_roundtrip( array( 2604 'content' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2605 'author_name' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2606 'author_user_agent' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2607 ), array( 2608 'content' => array( 2730 'content' => array( 2609 2731 'raw' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2610 2732 'rendered' => "<div>div</div>\n<p> <strong>strong</strong> <script>oh noes</script></p>", … … 2612 2734 'author_name' => 'div strong', 2613 2735 'author_user_agent' => 'div strong', 2614 ) ); 2615 } 2616 } 2617 2618 public function test_comment_roundtrip_as_superadmin() { 2619 wp_set_current_user( self::$superadmin_id ); 2620 $this->assertTrue( current_user_can( 'unfiltered_html' ) ); 2621 $this->verify_comment_roundtrip( array( 2622 'content' => '\\\&\\\ & &invalid; < < &lt;', 2623 'author_name' => '\\\&\\\ & &invalid; < < &lt;', 2624 'author_user_agent' => '\\\&\\\ & &invalid; < < &lt;', 2625 ), array( 2626 'content' => array( 2627 'raw' => '\\\&\\\ & &invalid; < < &lt;', 2628 'rendered' => '<p>\\\&\\\ & &invalid; < < &lt;' . "\n</p>", 2629 ), 2630 'author_name' => '\\\&\\\ & &invalid; < < &lt;', 2631 'author_user_agent' => '\\\&\\\ & &invalid; < < &lt;', 2632 ) ); 2633 } 2634 2635 public function test_comment_roundtrip_as_superadmin_unfiltered_html() { 2636 wp_set_current_user( self::$superadmin_id ); 2637 $this->assertTrue( current_user_can( 'unfiltered_html' ) ); 2638 $this->verify_comment_roundtrip( array( 2639 'content' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2640 'author_name' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2641 'author_user_agent' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2642 ), array( 2643 'content' => array( 2644 'raw' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 2645 'rendered' => "<div>div</div>\n<p> <strong>strong</strong> <script>oh noes</script></p>", 2646 ), 2647 'author_name' => 'div strong', 2648 'author_user_agent' => 'div strong', 2649 ) ); 2736 ) 2737 ); 2650 2738 } 2651 2739 … … 2653 2741 wp_set_current_user( self::$admin_id ); 2654 2742 2655 $comment_id = $this->factory->comment->create( array( 2656 'comment_approved' => 1, 2657 'comment_post_ID' => self::$post_id, 2658 'user_id' => self::$subscriber_id, 2659 )); 2743 $comment_id = $this->factory->comment->create( 2744 array( 2745 'comment_approved' => 1, 2746 'comment_post_ID' => self::$post_id, 2747 'user_id' => self::$subscriber_id, 2748 ) 2749 ); 2660 2750 2661 2751 $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%d', $comment_id ) ); … … 2671 2761 wp_set_current_user( self::$admin_id ); 2672 2762 2673 $comment_id = $this->factory->comment->create( array( 2674 'comment_approved' => 1, 2675 'comment_post_ID' => self::$post_id, 2676 'user_id' => self::$subscriber_id, 2677 )); 2678 $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%d', $comment_id ) ); 2763 $comment_id = $this->factory->comment->create( 2764 array( 2765 'comment_approved' => 1, 2766 'comment_post_ID' => self::$post_id, 2767 'user_id' => self::$subscriber_id, 2768 ) 2769 ); 2770 $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%d', $comment_id ) ); 2679 2771 $request['force'] = true; 2680 2772 … … 2689 2781 wp_set_current_user( self::$admin_id ); 2690 2782 2691 $comment_id = $this->factory->comment->create( array( 2692 'comment_approved' => 1, 2693 'comment_post_ID' => self::$post_id, 2694 'user_id' => self::$subscriber_id, 2695 )); 2696 $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%d', $comment_id ) ); 2697 $response = $this->server->dispatch( $request ); 2698 $this->assertEquals( 200, $response->get_status() ); 2699 $data = $response->get_data(); 2783 $comment_id = $this->factory->comment->create( 2784 array( 2785 'comment_approved' => 1, 2786 'comment_post_ID' => self::$post_id, 2787 'user_id' => self::$subscriber_id, 2788 ) 2789 ); 2790 $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%d', $comment_id ) ); 2791 $response = $this->server->dispatch( $request ); 2792 $this->assertEquals( 200, $response->get_status() ); 2793 $data = $response->get_data(); 2700 2794 $response = $this->server->dispatch( $request ); 2701 2795 $this->assertErrorResponse( 'rest_already_trashed', $response, 410 ); … … 2722 2816 public function test_delete_child_comment_link() { 2723 2817 wp_set_current_user( self::$admin_id ); 2724 $comment_id_1 = $this->factory->comment->create( array( 2725 'comment_approved' => 1, 2726 'comment_post_ID' => self::$post_id, 2727 'user_id' => self::$subscriber_id, 2728 ) ); 2729 2730 $child_comment = $this->factory->comment->create( array( 2731 'comment_approved' => 1, 2732 'comment_parent' => $comment_id_1, 2733 'comment_post_ID' => self::$post_id, 2734 'user_id' => self::$subscriber_id, 2735 ) ); 2736 2737 $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%s', $child_comment ) ); 2818 $comment_id_1 = $this->factory->comment->create( 2819 array( 2820 'comment_approved' => 1, 2821 'comment_post_ID' => self::$post_id, 2822 'user_id' => self::$subscriber_id, 2823 ) 2824 ); 2825 2826 $child_comment = $this->factory->comment->create( 2827 array( 2828 'comment_approved' => 1, 2829 'comment_parent' => $comment_id_1, 2830 'comment_post_ID' => self::$post_id, 2831 'user_id' => self::$subscriber_id, 2832 ) 2833 ); 2834 2835 $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%s', $child_comment ) ); 2738 2836 $response = $this->server->dispatch( $request ); 2739 2837 $this->assertEquals( 200, $response->get_status() ); 2740 2838 2741 2839 // Verify children link is gone. 2742 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) );2840 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); 2743 2841 $response = $this->server->dispatch( $request ); 2744 2842 $this->assertEquals( 200, $response->get_status() ); … … 2747 2845 2748 2846 public function test_get_item_schema() { 2749 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments' );2750 $response = $this->server->dispatch( $request );2751 $data = $response->get_data();2847 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments' ); 2848 $response = $this->server->dispatch( $request ); 2849 $data = $response->get_data(); 2752 2850 $properties = $data['schema']['properties']; 2753 2851 $this->assertEquals( 17, count( $properties ) ); … … 2779 2877 public function test_get_item_schema_show_avatar() { 2780 2878 update_option( 'show_avatars', false ); 2781 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/users' );2782 $response = $this->server->dispatch( $request );2783 $data = $response->get_data();2879 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/users' ); 2880 $response = $this->server->dispatch( $request ); 2881 $data = $response->get_data(); 2784 2882 $properties = $data['schema']['properties']; 2785 2883 … … 2796 2894 ); 2797 2895 2798 register_rest_field( 'comment', 'my_custom_int', array( 2799 'schema' => $schema, 2800 'get_callback' => array( $this, 'additional_field_get_callback' ), 2801 'update_callback' => array( $this, 'additional_field_update_callback' ), 2802 ) ); 2896 register_rest_field( 2897 'comment', 'my_custom_int', array( 2898 'schema' => $schema, 2899 'get_callback' => array( $this, 'additional_field_get_callback' ), 2900 'update_callback' => array( $this, 'additional_field_update_callback' ), 2901 ) 2902 ); 2803 2903 2804 2904 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments' ); 2805 2905 2806 2906 $response = $this->server->dispatch( $request ); 2807 $data = $response->get_data();2907 $data = $response->get_data(); 2808 2908 2809 2909 $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] ); … … 2816 2916 2817 2917 $request = new WP_REST_Request( 'POST', '/wp/v2/comments/' . self::$approved_id ); 2818 $request->set_body_params(array( 2819 'my_custom_int' => 123, 2820 'content' => 'abc', 2821 )); 2918 $request->set_body_params( 2919 array( 2920 'my_custom_int' => 123, 2921 'content' => 'abc', 2922 ) 2923 ); 2822 2924 2823 2925 wp_set_current_user( 1 ); … … 2826 2928 2827 2929 $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); 2828 $request->set_body_params(array( 2829 'my_custom_int' => 123, 2830 'title' => 'hello', 2831 'content' => 'goodbye', 2832 'post' => self::$post_id, 2833 )); 2930 $request->set_body_params( 2931 array( 2932 'my_custom_int' => 123, 2933 'title' => 'hello', 2934 'content' => 'goodbye', 2935 'post' => self::$post_id, 2936 ) 2937 ); 2834 2938 2835 2939 $response = $this->server->dispatch( $request ); … … 2849 2953 ); 2850 2954 2851 register_rest_field( 'comment', 'my_custom_int', array( 2852 'schema' => $schema, 2853 'get_callback' => array( $this, 'additional_field_get_callback' ), 2854 'update_callback' => array( $this, 'additional_field_update_callback' ), 2855 ) ); 2955 register_rest_field( 2956 'comment', 'my_custom_int', array( 2957 'schema' => $schema, 2958 'get_callback' => array( $this, 'additional_field_get_callback' ), 2959 'update_callback' => array( $this, 'additional_field_update_callback' ), 2960 ) 2961 ); 2856 2962 2857 2963 wp_set_current_user( self::$admin_id ); … … 2859 2965 // Check for error on update. 2860 2966 $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); 2861 $request->set_body_params(array( 2862 'my_custom_int' => 'returnError', 2863 'content' => 'abc', 2864 )); 2967 $request->set_body_params( 2968 array( 2969 'my_custom_int' => 'returnError', 2970 'content' => 'abc', 2971 ) 2972 ); 2865 2973 2866 2974 $response = $this->server->dispatch( $request ); … … 2897 3005 $this->assertEquals( get_comment_link( $comment ), $data['link'] ); 2898 3006 $this->assertContains( 'author_avatar_urls', $data ); 2899 $this->assertEqualSets( array( 2900 'self', 2901 'collection', 2902 'up', 2903 ), array_keys( $links ) ); 3007 $this->assertEqualSets( 3008 array( 3009 'self', 3010 'collection', 3011 'up', 3012 ), array_keys( $links ) 3013 ); 2904 3014 2905 3015 if ( 'edit' === $context ) {
Note: See TracChangeset
for help on using the changeset viewer.