Make WordPress Core


Ignore:
Timestamp:
11/16/2021 02:13:25 AM (5 years ago)
Author:
hellofromTonya
Message:

Comments: Don't output "cancel comment reply link" if comments aren't threaded.

Though hidden via style="display:none;", if the comments aren't threaded, this commit doesn't output the cancel comment reply link (skips over that logic). Change in comment_form().

Adds tests.

Follow-up to [12810], [38959].

Props henrywright, jigneshnakrani, rachelbaker, desrosj, audrasjb, hellofromTonya.
Fixes #37267.

File:
1 edited

Legend:

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

    r51565 r52175  
    22
    33/**
    4  * @group comment
     4 * @group  comment
     5 * @covers ::comment_form
    56 */
    67class Tests_Comment_CommentForm extends WP_UnitTestCase {
     8        public static $post_id;
     9
     10        public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     11                self::$post_id = $factory->post->create();
     12        }
     13
    714        public function test_default_markup_for_submit_button_and_wrapper() {
    815                $p = self::factory()->post->create();
     
    124131                $this->assertStringNotContainsString( 'aria-describedby="email-notes"', $form_without_aria );
    125132        }
     133
     134        /**
     135         * @ticket 32767
     136         */
     137        public function test_when_thread_comments_enabled() {
     138                update_option( 'thread_comments', true );
     139
     140                $form     = get_echo( 'comment_form', array( array(), self::$post_id ) );
     141                $expected = '<a rel="nofollow" id="cancel-comment-reply-link" href="#respond" style="display:none;">Cancel reply</a>';
     142                $this->assertStringContainsString( $expected, $form );
     143        }
     144
     145        /**
     146         * @ticket 32767
     147         */
     148        public function test_when_thread_comments_disabled() {
     149                delete_option( 'thread_comments' );
     150
     151                $form     = get_echo( 'comment_form', array( array(), self::$post_id ) );
     152                $expected = '<a rel="nofollow" id="cancel-comment-reply-link" href="#respond" style="display:none;">Cancel reply</a>';
     153                $this->assertStringNotContainsString( $expected, $form );
     154        }
    126155}
Note: See TracChangeset for help on using the changeset viewer.