WordPress.org

Make WordPress Core

Ticket #21169: 21169-unittests.diff

File 21169-unittests.diff, 1.1 KB (added by MikeHansenMe, 5 years ago)

see #30284

  • tests/phpunit/tests/filters.php

    diff --git a/tests/phpunit/tests/filters.php b/tests/phpunit/tests/filters.php
    index c0eb125..b4ee12f 100644
    a b class Tests_Filters extends WP_UnitTestCase { 
    251251        }
    252252
    253253        /**
     254         * @ticket 21169
     255         */
     256        function test_filter_removal_during_filter() {
     257                $tag = rand_str();
     258                $a = new MockAction();
     259                $b = new MockAction();
     260
     261                add_action( $tag, array($a, 'filter_append'), 11, 1 );
     262                add_action( $tag, array($b, 'filter_append'), 12, 1 );
     263                add_action( $tag, array($this, '_self_removal'), 10, 1 );
     264
     265                $result = apply_filters($tag, $tag);
     266                $this->assertEquals( 1, $a->get_call_count(), 'priority 11 filters should run after priority 10 empties itself' );
     267                $this->assertEquals( 1, $b->get_call_count(), 'priority 12 filters should run after priority 10 empties itself and priority 11 runs' );
     268                $this->assertEquals( $result, $tag . '_append_append', 'priority 11 and 12 filters should run after priority 10 empties itself' );
     269        }
     270
     271        /**
    254272         * @ticket 29070
    255273         */
    256274        function test_has_filter_after_remove_all_filters() {