Make WordPress Core


Ignore:
Timestamp:
08/07/2014 02:29:15 AM (10 years ago)
Author:
wonderboymusic
Message:

After [28883], ensure that priorities have callbacks before returning true in has_filter().

Adds unit tests.

Props boonebgorges.
Fixes #29070.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/filters.php

    r25377 r29422  
    268268        $this->assertEquals( $result, $tag . '_append_append', 'priority 11 and 12 filters should run after priority 10 empties itself' );
    269269    }
     270
     271    /**
     272     * @ticket 29070
     273     */
     274    function test_has_filter_after_remove_all_filters() {
     275        $a = new MockAction();
     276        $tag = rand_str();
     277        $val = rand_str();
     278
     279        // No priority
     280        add_filter( $tag, array( $a, 'filter' ), 11 );
     281        add_filter( $tag, array( $a, 'filter' ), 12 );
     282        $this->assertTrue( has_filter( $tag ) );
     283
     284        remove_all_filters( $tag );
     285        $this->assertFalse( has_filter( $tag ) );
     286
     287        // Remove priorities one at a time
     288        add_filter( $tag, array( $a, 'filter' ), 11 );
     289        add_filter( $tag, array( $a, 'filter' ), 12 );
     290        $this->assertTrue( has_filter( $tag ) );
     291
     292        remove_all_filters( $tag, 11 );
     293        remove_all_filters( $tag, 12 );
     294        $this->assertFalse( has_filter( $tag ) );
     295    }
    270296}
Note: See TracChangeset for help on using the changeset viewer.