Make WordPress Core

Changeset 31277


Ignore:
Timestamp:
01/25/2015 03:38:10 AM (10 years ago)
Author:
boonebgorges
Message:

In Tests_Ajax_ReplytoComment::test_blocked_comment(), don't stop blocking comments until test is complete.

The test uses the _block_comments() method to prevent comment inserts from
happening. Since [31263], failed comment inserts lead to the comment content's
being stripped of invalid characters and inserted again. By immediately
unhooking itself after first being run, _block_comments() was causing the
INSERT block to work only for the first attempt, while the second attempt was
going through, causing the test to fail. As a fix, we move the
remove_filter() call to the class's tearDown() method - sufficient for
cleanup, but late enough that *all* comment inserts will be blocked for the
test method in question.

See #21212.
Since [31263], comment INSERT queries that were pseudo-bl

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/ajax/ReplytoComment.php

    r25433 r31277  
    4343    }
    4444
     45    public function tearDown() {
     46        parent::tearDown();
     47        remove_filter( 'query', array( $this, '_block_comments' ) );
     48    }
     49
    4550    /**
    4651     * Reply as a privilged user (administrator)
     
    221226        global $wpdb;
    222227        if ( false !== strpos( $sql, $wpdb->comments ) && 0 === stripos( trim ( $sql ), 'INSERT INTO') ) {
    223             remove_filter( 'query', array( $this, '_block_comments' ) );
    224228            return '';
    225229        }
Note: See TracChangeset for help on using the changeset viewer.