Changeset 56609 for trunk/tests/phpunit/tests/hooks/removeFilter.php
- Timestamp:
- 09/18/2023 12:39:18 PM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/hooks/removeFilter.php
r53804 r56609 18 18 $hook->add_filter( $hook_name, $callback, $priority, $accepted_args ); 19 19 $hook->remove_filter( $hook_name, $callback, $priority ); 20 $this->check_priority_non_existent( $hook, $priority ); 20 21 21 22 $this->assertArrayNotHasKey( $priority, $hook->callbacks ); … … 32 33 $hook->add_filter( $hook_name, $callback, $priority, $accepted_args ); 33 34 $hook->remove_filter( $hook_name, $callback, $priority ); 35 $this->check_priority_non_existent( $hook, $priority ); 34 36 35 37 $this->assertArrayNotHasKey( $priority, $hook->callbacks ); … … 45 47 $hook->add_filter( $hook_name, $callback, $priority, $accepted_args ); 46 48 $hook->remove_filter( $hook_name, $callback, $priority ); 49 $this->check_priority_non_existent( $hook, $priority ); 47 50 48 51 $this->assertArrayNotHasKey( $priority, $hook->callbacks ); … … 63 66 64 67 $this->assertCount( 1, $hook->callbacks[ $priority ] ); 68 $this->check_priority_exists( $hook, $priority, 'Has priority of 2' ); 65 69 } 66 70 … … 77 81 78 82 $hook->remove_filter( $hook_name, $callback_one, $priority ); 83 $this->check_priority_non_existent( $hook, $priority ); 79 84 $this->assertArrayNotHasKey( $priority, $hook->callbacks ); 80 85 $this->assertCount( 1, $hook->callbacks[ $priority + 1 ] ); 86 $this->check_priority_exists( $hook, $priority + 1, 'Should priority of 3' ); 87 } 88 89 protected function check_priority_non_existent( $hook, $priority ) { 90 $priorities = $this->get_priorities( $hook ); 91 92 $this->assertNotContains( $priority, $priorities ); 93 } 94 95 protected function check_priority_exists( $hook, $priority ) { 96 $priorities = $this->get_priorities( $hook ); 97 98 $this->assertContains( $priority, $priorities ); 99 } 100 101 protected function get_priorities( $hook ) { 102 $reflection = new ReflectionClass( $hook ); 103 $reflection_property = $reflection->getProperty( 'priorities' ); 104 $reflection_property->setAccessible( true ); 105 106 return $reflection_property->getValue( $hook ); 81 107 } 82 108 }
Note: See TracChangeset
for help on using the changeset viewer.