| 639 | |
| 640 | |
| 641 | public function test_wp_update_comment_author_id_and_agent() { |
| 642 | |
| 643 | $default_data = array( |
| 644 | 'comment_post_ID' => self::$post_id, |
| 645 | 'comment_author' => rand_str(), |
| 646 | 'comment_author_IP' => '192.168.0.1', |
| 647 | 'comment_agent' => 'WRONG_AGENT', |
| 648 | 'comment_author_url' => '', |
| 649 | 'comment_author_email' => '', |
| 650 | 'comment_type' => '', |
| 651 | 'comment_content' => rand_str(), |
| 652 | ); |
| 653 | |
| 654 | $comment_id = wp_new_comment( $default_data ); |
| 655 | |
| 656 | // Confirm that the IP and Agent are correct on initial save. |
| 657 | $save = get_comment( $comment_id ); |
| 658 | $this->assertEquals( $default_data['comment_author_IP'], $save->comment_author_IP ); |
| 659 | $this->assertEquals( $default_data['comment_agent'], $save->comment_agent ); |
| 660 | |
| 661 | // Update the comment. |
| 662 | wp_update_comment( array( |
| 663 | 'comment_ID' => $comment_id, |
| 664 | 'comment_author_IP' => '111.111.1.1', |
| 665 | 'comment_agent' => 'SHIELD_AGENT', |
| 666 | ) |
| 667 | ); |
| 668 | |
| 669 | // Retrieve and check the new values. |
| 670 | $updated = get_comment( $comment_id ); |
| 671 | $this->assertEquals( '111.111.1.1', $updated->comment_author_IP ); |
| 672 | $this->assertEquals( 'SHIELD_AGENT', $updated->comment_agent ); |
| 673 | } |