You appear to be a bot. Output may be restricted
Description
Usage
Tests_Filters::test_remove_all_filter();
Parameters
Returns
void
Source
File name: wordpress-develop-tests/phpunit/tests/filters.php
Lines:
1 to 24 of 24
public function test_remove_all_filter() { $a = new MockAction(); $tag = __FUNCTION__; $val = __FUNCTION__ . '_val'; add_filter( 'all', array( $a, 'filterall' ) ); $this->assertTrue( has_filter( 'all' ) ); $this->assertSame( 10, has_filter( 'all', array( $a, 'filterall' ) ) ); $this->assertSame( $val, apply_filters( $tag, $val ) ); // Make sure our hook was called correctly. $this->assertSame( 1, $a->get_call_count() ); $this->assertSame( array( $tag ), $a->get_tags() ); // Now remove the filter, do it again, and make sure it's not called this time. remove_filter( 'all', array( $a, 'filterall' ) ); $this->assertFalse( has_filter( 'all', array( $a, 'filterall' ) ) ); $this->assertFalse( has_filter( 'all' ) ); $this->assertSame( $val, apply_filters( $tag, $val ) ); // Call cound should remain at 1. $this->assertSame( 1, $a->get_call_count() ); $this->assertSame( array( $tag ), $a->get_tags() ); }