Comments: Ensure that themes overriding default comment_form() fields still display the cookies consent checkbox.

The `comment_form_default_fields` filter can be used to remove the checkbox.

Props pross, SergeyBiryukov.
Fixes #44126.

git-svn-id: https://develop.svn.wordpress.org/trunk@43518 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2018-07-20 00:37:40 +00:00
parent 9d4b0ec88f
commit 8a0aac2ccb
2 changed files with 25 additions and 0 deletions

View File

@@ -80,4 +80,24 @@ class Tests_Comment_CommentForm extends WP_UnitTestCase {
unset( $defaults['submit_button'] );
return $defaults;
}
/**
* @ticket 44126
*/
public function test_fields_should_include_cookies_consent() {
$p = self::factory()->post->create();
add_filter( 'option_show_comments_cookies_opt_in', '__return_true' );
$args = array(
'fields' => array(
'author' => 'Hello World!',
),
);
$form = get_echo( 'comment_form', array( $args, $p ) );
remove_filter( 'option_show_comments_cookies_opt_in', '__return_true' );
$this->assertRegExp( '|<p class="comment\-form\-cookies\-consent">.*?</p>|', $form );
}
}