- Timestamp:
- 11/18/2016 06:52:19 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-comments-controller.php
r39290 r39292 136 136 'exclude', 137 137 'include', 138 'karma',139 138 'offset', 140 139 'order', … … 1162 1161 } 1163 1162 1164 public function test_create_comment_karma_without_permission() {1165 wp_set_current_user( self::$subscriber_id );1166 1167 $params = array(1168 'post' => self::$post_id,1169 'author_name' => 'Homer Jay Simpson',1170 'author_email' => 'chunkylover53@aol.com',1171 'author_url' => 'http://compuglobalhypermeganet.com',1172 'content' => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.',1173 'author' => self::$subscriber_id,1174 'karma' => 100,1175 );1176 1177 $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );1178 $request->add_header( 'content-type', 'application/json' );1179 $request->set_body( wp_json_encode( $params ) );1180 $response = $this->server->dispatch( $request );1181 1182 $this->assertErrorResponse( 'rest_comment_invalid_karma', $response, 403 );1183 }1184 1185 1163 public function test_create_comment_invalid_post() { 1186 1164 wp_set_current_user( self::$subscriber_id ); … … 1193 1171 'content' => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.', 1194 1172 'author' => self::$subscriber_id, 1195 );1196 1197 $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );1198 $request->add_header( 'content-type', 'application/json' );1199 $request->set_body( wp_json_encode( $params ) );1200 $response = $this->server->dispatch( $request );1201 1202 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );1203 }1204 1205 public function test_create_comment_karma_invalid_value() {1206 wp_set_current_user( self::$subscriber_id );1207 1208 $params = array(1209 'post' => self::$post_id,1210 'author_name' => 'Homer Jay Simpson',1211 'author_email' => 'chunkylover53@aol.com',1212 'author_url' => 'http://compuglobalhypermeganet.com',1213 'content' => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.',1214 'author' => self::$subscriber_id,1215 'karma' => 'themostkarmaever',1216 1173 ); 1217 1174 … … 1650 1607 'content' => 'Testing.', 1651 1608 'date' => '2014-11-07T10:14:25', 1652 'karma' => 100,1653 1609 'post' => $post_id, 1654 1610 ); … … 1669 1625 $this->assertEquals( $params['author_ip'], $comment['author_ip'] ); 1670 1626 $this->assertEquals( $params['post'], $comment['post'] ); 1671 $this->assertEquals( $params['karma'], $comment['karma'] );1672 1627 1673 1628 $this->assertEquals( mysql_to_rfc3339( $updated->comment_date ), $comment['date'] ); … … 2224 2179 $data = $response->get_data(); 2225 2180 $properties = $data['schema']['properties']; 2226 $this->assertEquals( 1 8, count( $properties ) );2181 $this->assertEquals( 17, count( $properties ) ); 2227 2182 $this->assertArrayHasKey( 'id', $properties ); 2228 2183 $this->assertArrayHasKey( 'author', $properties ); … … 2236 2191 $this->assertArrayHasKey( 'date', $properties ); 2237 2192 $this->assertArrayHasKey( 'date_gmt', $properties ); 2238 $this->assertArrayHasKey( 'karma', $properties );2239 2193 $this->assertArrayHasKey( 'link', $properties ); 2240 2194 $this->assertArrayHasKey( 'meta', $properties ); … … 2383 2337 $this->assertEquals( $comment->comment_agent, $data['author_user_agent'] ); 2384 2338 $this->assertEquals( $comment->comment_content, $data['content']['raw'] ); 2385 $this->assertEquals( $comment->comment_karma, $data['karma'] );2386 2339 } 2387 2340 … … 2391 2344 $this->assertArrayNotHasKey( 'author_user_agent', $data ); 2392 2345 $this->assertArrayNotHasKey( 'raw', $data['content'] ); 2393 $this->assertArrayNotHasKey( 'karma', $data );2394 2346 } 2395 2347 }
Note: See TracChangeset
for help on using the changeset viewer.