WordPress.org

Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.4/tests/phpunit/tests/comment-submission.php

    r35745 r36039  
    55 */
    66class Tests_Comment_Submission extends WP_UnitTestCase {
     7
     8    protected $preprocess_comment_data = array();
    79
    810    function setUp() {
     
    591593    }
    592594
     595    /**
     596     * @ticket 34997
     597     */
     598    public function test_comment_submission_sends_all_expected_parameters_to_preprocess_comment_filter() {
     599
     600        $user = self::factory()->user->create_and_get( array(
     601            'role' => 'author',
     602        ) );
     603        wp_set_current_user( $user->ID );
     604
     605        $post = self::factory()->post->create_and_get();
     606        $data = array(
     607            'comment_post_ID' => $post->ID,
     608            'comment'         => 'Comment',
     609        );
     610
     611        add_filter( 'preprocess_comment', array( $this, 'filter_preprocess_comment' ) );
     612
     613        $comment = wp_handle_comment_submission( $data );
     614
     615        remove_filter( 'preprocess_comment', array( $this, 'filter_preprocess_comment' ) );
     616
     617        $this->assertNotWPError( $comment );
     618        $this->assertEquals( array(
     619            'comment_post_ID'      => $post->ID,
     620            'comment_author'       => $user->display_name,
     621            'comment_author_email' => $user->user_email,
     622            'comment_author_url'   => $user->user_url,
     623            'comment_content'      => $data['comment'],
     624            'comment_type'         => '',
     625            'comment_parent'       => '0',
     626            'user_ID'              => $user->ID,
     627            'user_id'              => $user->ID,
     628        ), $this->preprocess_comment_data );
     629
     630    }
     631
     632    public function filter_preprocess_comment( $commentdata ) {
     633        $this->preprocess_comment_data = $commentdata;
     634        return $commentdata;
     635    }
     636
    593637}
Note: See TracChangeset for help on using the changeset viewer.