- Timestamp:
- 01/29/2020 12:43:23 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-comments-controller.php
r47036 r47122 169 169 170 170 public function test_context_param() { 171 // Collection 171 // Collection. 172 172 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments' ); 173 173 $response = rest_get_server()->dispatch( $request ); … … 175 175 $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); 176 176 $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 177 // Single 177 // Single. 178 178 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments/' . self::$approved_id ); 179 179 $response = rest_get_server()->dispatch( $request ); … … 980 980 981 981 $comment = get_comment( self::$approved_id ); 982 /** 983 * Ignore the subdomain, since 'get_avatar_url randomly sets the Gravatar 984 * server when building the url string. 985 */ 982 // Ignore the subdomain, since get_avatar_url() randomly sets 983 // the Gravatar server when building the URL string. 986 984 $this->assertEquals( substr( get_avatar_url( $comment->comment_author_email ), 9 ), substr( $data['author_avatar_urls'][96], 9 ) ); 987 985 } … … 1566 1564 $this->assertEquals( $user_id, $data['author'] ); 1567 1565 1568 // Check author data matches 1566 // Check author data matches. 1569 1567 $author = get_user_by( 'id', $user_id ); 1570 1568 $comment = get_comment( $data['id'] ); … … 2073 2071 2074 2072 public function anonymous_comments_callback_null() { 2075 // I'm a plugin developer who forgot to include a return value for some2076 // code path in my 'rest_allow_anonymous_comments' filter.2073 // I'm a plugin developer who forgot to include a return value 2074 // for some code path in my 'rest_allow_anonymous_comments' filter. 2077 2075 } 2078 2076 … … 2333 2331 $request->set_param( 'post', $comment->comment_post_ID ); 2334 2332 2335 // Run twice to make sure that the update still succeeds even if no DB2336 // rows are updated.2333 // Run twice to make sure that the update still succeeds 2334 // even if no DB rows are updated. 2337 2335 $response = rest_get_server()->dispatch( $request ); 2338 2336 $this->assertEquals( 200, $response->get_status() ); … … 2794 2792 2795 2793 public function verify_comment_roundtrip( $input = array(), $expected_output = array() ) { 2796 // Create the comment 2794 // Create the comment. 2797 2795 $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); 2798 2796 $request->set_param( 'author_email', 'cbg@androidsdungeon.com' ); … … 2805 2803 $actual_output = $response->get_data(); 2806 2804 2807 // Compare expected API output to actual API output 2805 // Compare expected API output to actual API output. 2808 2806 $this->assertInternalType( 'array', $actual_output['content'] ); 2809 2807 $this->assertArrayHasKey( 'raw', $actual_output['content'] ); … … 2813 2811 $this->assertEquals( $expected_output['author_user_agent'], $actual_output['author_user_agent'] ); 2814 2812 2815 // Compare expected API output to WP internal values 2813 // Compare expected API output to WP internal values. 2816 2814 $comment = get_comment( $actual_output['id'] ); 2817 2815 $this->assertEquals( $expected_output['content']['raw'], $comment->comment_content ); … … 2819 2817 $this->assertEquals( $expected_output['author_user_agent'], $comment->comment_agent ); 2820 2818 2821 // Update the comment 2819 // Update the comment. 2822 2820 $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', $actual_output['id'] ) ); 2823 2821 foreach ( $input as $name => $value ) { 2824 2822 $request->set_param( $name, $value ); 2825 2823 } 2826 // FIXME at least one value must change, or update fails2824 // FIXME At least one value must change, or update fails. 2827 2825 // See https://core.trac.wordpress.org/ticket/38700 2828 2826 $request->set_param( 'author_ip', '127.0.0.2' ); … … 2831 2829 $actual_output = $response->get_data(); 2832 2830 2833 // Compare expected API output to actual API output 2831 // Compare expected API output to actual API output. 2834 2832 $this->assertEquals( $expected_output['content']['raw'], $actual_output['content']['raw'] ); 2835 2833 $this->assertEquals( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) ); … … 2837 2835 $this->assertEquals( $expected_output['author_user_agent'], $actual_output['author_user_agent'] ); 2838 2836 2839 // Compare expected API output to WP internal values 2837 // Compare expected API output to WP internal values. 2840 2838 $comment = get_comment( $actual_output['id'] ); 2841 2839 $this->assertEquals( $expected_output['content']['raw'], $comment->comment_content );
Note: See TracChangeset
for help on using the changeset viewer.