Changeset 53804 for trunk/tests/phpunit/tests/hooks/removeFilter.php
- Timestamp:
- 07/31/2022 03:03:46 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/hooks/removeFilter.php
r52389 r53804 12 12 $callback = '__return_null'; 13 13 $hook = new WP_Hook(); 14 $ tag= __FUNCTION__;14 $hook_name = __FUNCTION__; 15 15 $priority = 1; 16 16 $accepted_args = 2; 17 17 18 $hook->add_filter( $ tag, $callback, $priority, $accepted_args );19 $hook->remove_filter( $ tag, $callback, $priority );18 $hook->add_filter( $hook_name, $callback, $priority, $accepted_args ); 19 $hook->remove_filter( $hook_name, $callback, $priority ); 20 20 21 21 $this->assertArrayNotHasKey( $priority, $hook->callbacks ); … … 26 26 $callback = array( $a, 'action' ); 27 27 $hook = new WP_Hook(); 28 $ tag= __FUNCTION__;28 $hook_name = __FUNCTION__; 29 29 $priority = 1; 30 30 $accepted_args = 2; 31 31 32 $hook->add_filter( $ tag, $callback, $priority, $accepted_args );33 $hook->remove_filter( $ tag, $callback, $priority );32 $hook->add_filter( $hook_name, $callback, $priority, $accepted_args ); 33 $hook->remove_filter( $hook_name, $callback, $priority ); 34 34 35 35 $this->assertArrayNotHasKey( $priority, $hook->callbacks ); … … 39 39 $callback = array( 'MockAction', 'action' ); 40 40 $hook = new WP_Hook(); 41 $ tag= __FUNCTION__;41 $hook_name = __FUNCTION__; 42 42 $priority = 1; 43 43 $accepted_args = 2; 44 44 45 $hook->add_filter( $ tag, $callback, $priority, $accepted_args );46 $hook->remove_filter( $ tag, $callback, $priority );45 $hook->add_filter( $hook_name, $callback, $priority, $accepted_args ); 46 $hook->remove_filter( $hook_name, $callback, $priority ); 47 47 48 48 $this->assertArrayNotHasKey( $priority, $hook->callbacks ); … … 53 53 $callback_two = '__return_false'; 54 54 $hook = new WP_Hook(); 55 $ tag= __FUNCTION__;55 $hook_name = __FUNCTION__; 56 56 $priority = 1; 57 57 $accepted_args = 2; 58 58 59 $hook->add_filter( $ tag, $callback_one, $priority, $accepted_args );60 $hook->add_filter( $ tag, $callback_two, $priority, $accepted_args );59 $hook->add_filter( $hook_name, $callback_one, $priority, $accepted_args ); 60 $hook->add_filter( $hook_name, $callback_two, $priority, $accepted_args ); 61 61 62 $hook->remove_filter( $ tag, $callback_one, $priority );62 $hook->remove_filter( $hook_name, $callback_one, $priority ); 63 63 64 64 $this->assertCount( 1, $hook->callbacks[ $priority ] ); … … 69 69 $callback_two = '__return_false'; 70 70 $hook = new WP_Hook(); 71 $ tag= __FUNCTION__;71 $hook_name = __FUNCTION__; 72 72 $priority = 1; 73 73 $accepted_args = 2; 74 74 75 $hook->add_filter( $ tag, $callback_one, $priority, $accepted_args );76 $hook->add_filter( $ tag, $callback_two, $priority + 1, $accepted_args );75 $hook->add_filter( $hook_name, $callback_one, $priority, $accepted_args ); 76 $hook->add_filter( $hook_name, $callback_two, $priority + 1, $accepted_args ); 77 77 78 $hook->remove_filter( $ tag, $callback_one, $priority );78 $hook->remove_filter( $hook_name, $callback_one, $priority ); 79 79 $this->assertArrayNotHasKey( $priority, $hook->callbacks ); 80 80 $this->assertCount( 1, $hook->callbacks[ $priority + 1 ] );
Note: See TracChangeset
for help on using the changeset viewer.