| | 1249 | public function test_create_comment_user_agent_header() { |
| | 1250 | wp_set_current_user( self::$admin_id ); |
| | 1251 | |
| | 1252 | $params = array( |
| | 1253 | 'post' => self::$post_id, |
| | 1254 | 'author_name' => 'Homer Jay Simpson', |
| | 1255 | 'author_email' => 'chunkylover53@aol.com', |
| | 1256 | 'author_url' => 'http://compuglobalhypermeganet.com', |
| | 1257 | 'content' => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.', |
| | 1258 | ); |
| | 1259 | |
| | 1260 | $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); |
| | 1261 | $request->add_header( 'content-type', 'application/json' ); |
| | 1262 | $request->add_header( 'user_agent', 'Mozilla/4.0 (compatible; MSIE 5.5; AOL 4.0; Windows 95)' ); |
| | 1263 | $request->set_body( wp_json_encode( $params ) ); |
| | 1264 | |
| | 1265 | $response = $this->server->dispatch( $request ); |
| | 1266 | $this->assertEquals( 201, $response->get_status() ); |
| | 1267 | |
| | 1268 | $data = $response->get_data(); |
| | 1269 | |
| | 1270 | $new_comment = get_comment( $data['id'] ); |
| | 1271 | $this->assertEquals( 'Mozilla/4.0 (compatible; MSIE 5.5; AOL 4.0; Windows 95)', $new_comment->comment_agent ); |
| | 1272 | } |
| | 1273 | |