Make WordPress Core

Ticket #32312: 32312.diff

File 32312.diff, 2.0 KB (added by boonebgorges, 10 years ago)
  • src/wp-includes/comment-template.php

    diff --git src/wp-includes/comment-template.php src/wp-includes/comment-template.php
    index 77f16d9..2f1c59e 100644
    function comment_form( $args = array(), $post_id = null ) { 
    22522252         */
    22532253        $args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) );
    22542254
     2255        // Ensure that the filtered args contain all required default values.
     2256        $args = array_merge( $defaults, $args );
     2257
    22552258                if ( comments_open( $post_id ) ) : ?>
    22562259                        <?php
    22572260                        /**
  • tests/phpunit/tests/comment/commentForm.php

    diff --git tests/phpunit/tests/comment/commentForm.php tests/phpunit/tests/comment/commentForm.php
    index 689ccf6..5573ebd 100644
    class Tests_Comment_CommentForm extends WP_UnitTestCase { 
    5252                $hidden = get_comment_id_fields( $p );
    5353                $this->assertRegExp( '|<p class="my\-custom\-submit\-field">\s*' . $button . '\s*' . $hidden . '\s*|', $form );
    5454        }
     55
     56        /**
     57         * @ticket 32312
     58         */
     59        public function test_submit_button_and_submit_field_should_fall_back_on_defaults_when_filtered_defaults_do_not_contain_the_keys() {
     60                $p = $this->factory->post->create();
     61
     62                $args = array(
     63                        'name_submit' => 'foo-name',
     64                        'id_submit' => 'foo-id',
     65                        'class_submit' => 'foo-class',
     66                        'label_submit' => 'foo-label',
     67                );
     68
     69                add_filter( 'comment_form_defaults', array( $this, 'filter_comment_form_defaults' ) );
     70                $form = get_echo( 'comment_form', array( $args, $p ) );
     71                remove_filter( 'comment_form_defaults', array( $this, 'filter_comment_form_defaults' ) );
     72
     73                $button = '<input name="foo-name" type="submit" id="foo-id" class="foo-class" value="foo-label" />';
     74                $hidden = get_comment_id_fields( $p );
     75                $this->assertRegExp( '|<p class="form\-submit">\s*' . $button . '\s*' . $hidden . '\s*|', $form );
     76        }
     77
     78        public function filter_comment_form_defaults( $defaults ) {
     79                unset( $defaults['submit_field'] );
     80                unset( $defaults['submit_button'] );
     81                return $defaults;
     82        }
    5583}