| | 756 | /** |
| | 757 | * @ticket 49236 |
| | 758 | */ |
| | 759 | public function test_comment_submission_sends_empty_string_comment_type() { |
| | 760 | $user = get_userdata( self::$author_id ); |
| | 761 | wp_set_current_user( $user->ID ); |
| | 762 | |
| | 763 | $data = array( |
| | 764 | 'comment_post_ID' => self::$post->ID, |
| | 765 | 'comment' => 'Comment', |
| | 766 | 'comment_type' => '', |
| | 767 | ); |
| | 768 | |
| | 769 | add_filter( 'preprocess_comment', array( $this, 'filter_preprocess_comment' ) ); |
| | 770 | |
| | 771 | $comment = wp_handle_comment_submission( $data ); |
| | 772 | |
| | 773 | remove_filter( 'preprocess_comment', array( $this, 'filter_preprocess_comment' ) ); |
| | 774 | |
| | 775 | $this->assertNotWPError( $comment ); |
| | 776 | $this->assertEquals( |
| | 777 | array( |
| | 778 | 'comment_post_ID' => self::$post->ID, |
| | 779 | 'comment_author' => $user->display_name, |
| | 780 | 'comment_author_email' => $user->user_email, |
| | 781 | 'comment_author_url' => $user->user_url, |
| | 782 | 'comment_content' => $data['comment'], |
| | 783 | 'comment_type' => 'comment', |
| | 784 | 'comment_parent' => '0', |
| | 785 | 'user_ID' => $user->ID, |
| | 786 | 'user_id' => $user->ID, |
| | 787 | ), |
| | 788 | $this->preprocess_comment_data |
| | 789 | ); |
| | 790 | } |
| | 791 | |
| | 792 | /** |
| | 793 | * @ticket 49236 |
| | 794 | */ |
| | 795 | public function test_comment_insertion_uses_empty_string_comment_type() { |
| | 796 | $user = get_userdata( self::$author_id ); |
| | 797 | wp_set_current_user( $user->ID ); |
| | 798 | |
| | 799 | $data = array( |
| | 800 | 'comment_post_ID' => self::$post->ID, |
| | 801 | 'comment_author' => $user->display_name, |
| | 802 | 'comment_author_email' => $user->user_email, |
| | 803 | 'comment_author_url' => $user->user_url, |
| | 804 | 'comment_content' => 'Comment', |
| | 805 | 'comment_type' => '', |
| | 806 | 'user_id' => $user->ID, |
| | 807 | ); |
| | 808 | |
| | 809 | add_action( 'wp_insert_comment', array( $this, 'action_postprocess_comment' ), 10, 2 ); |
| | 810 | |
| | 811 | $comment = wp_insert_comment( $data ); |
| | 812 | |
| | 813 | remove_action( 'wp_insert_comment', array( $this, 'action_postprocess_comment' ), 10, 2 ); |
| | 814 | |
| | 815 | $this->assertEquals( |
| | 816 | array( |
| | 817 | 'comment_post_ID' => self::$post->ID, |
| | 818 | 'comment_author' => $data['comment_author'], |
| | 819 | 'comment_author_email' => $data['comment_author_email'], |
| | 820 | 'comment_author_url' => $data['comment_author_url'], |
| | 821 | 'comment_content' => $data['comment_content'], |
| | 822 | 'comment_type' => 'comment', |
| | 823 | 'comment_parent' => '0', |
| | 824 | 'user_id' => $data['user_id'], |
| | 825 | ), |
| | 826 | $this->postprocess_comment_data |
| | 827 | ); |
| | 828 | } |
| | 829 | |
| | 835 | public function action_postprocess_comment( $id, $comment ) { |
| | 836 | $this->postprocess_comment_data = array( |
| | 837 | 'comment_post_ID' => (int) $comment->comment_post_ID, |
| | 838 | 'comment_author' => $comment->comment_author, |
| | 839 | 'comment_author_email' => $comment->comment_author_email, |
| | 840 | 'comment_author_url' => $comment->comment_author_url, |
| | 841 | 'comment_content' => $comment->comment_content, |
| | 842 | 'comment_type' => $comment->comment_type, |
| | 843 | 'comment_parent' => $comment->comment_parent, |
| | 844 | 'user_id' => (int) $comment->user_id, |
| | 845 | ); |
| | 846 | } |
| | 847 | |