Make WordPress Core


Ignore:
Timestamp:
05/19/2015 01:03:39 AM (9 years ago)
Author:
SergeyBiryukov
Message:

In comment_form(), ensure that filtered arguments contain all required default values.

props boonebgorges.
fixes #32312 for trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/comment/commentForm.php

    r31699 r32511  
    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}
Note: See TracChangeset for help on using the changeset viewer.