Changeset 42343 for trunk/tests/phpunit/tests/hooks/addFilter.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/hooks/addFilter.php
r42200 r42343 12 12 13 13 public function test_add_filter_with_function() { 14 $callback = '__return_null';15 $hook = new WP_Hook();16 $tag = __FUNCTION__;17 $priority = rand( 1, 100 );14 $callback = '__return_null'; 15 $hook = new WP_Hook(); 16 $tag = __FUNCTION__; 17 $priority = rand( 1, 100 ); 18 18 $accepted_args = rand( 1, 100 ); 19 19 … … 26 26 27 27 public function test_add_filter_with_object() { 28 $a = new MockAction();29 $callback = array( $a, 'action' );30 $hook = new WP_Hook();31 $tag = __FUNCTION__;32 $priority = rand( 1, 100 );28 $a = new MockAction(); 29 $callback = array( $a, 'action' ); 30 $hook = new WP_Hook(); 31 $tag = __FUNCTION__; 32 $priority = rand( 1, 100 ); 33 33 $accepted_args = rand( 1, 100 ); 34 34 … … 41 41 42 42 public function test_add_filter_with_static_method() { 43 $callback = array( 'MockAction', 'action' );44 $hook = new WP_Hook();45 $tag = __FUNCTION__;46 $priority = rand( 1, 100 );43 $callback = array( 'MockAction', 'action' ); 44 $hook = new WP_Hook(); 45 $tag = __FUNCTION__; 46 $priority = rand( 1, 100 ); 47 47 $accepted_args = rand( 1, 100 ); 48 48 … … 55 55 56 56 public function test_add_two_filters_with_same_priority() { 57 $callback_one = '__return_null';58 $callback_two = '__return_false';59 $hook = new WP_Hook();60 $tag = __FUNCTION__;61 $priority = rand( 1, 100 );57 $callback_one = '__return_null'; 58 $callback_two = '__return_false'; 59 $hook = new WP_Hook(); 60 $tag = __FUNCTION__; 61 $priority = rand( 1, 100 ); 62 62 $accepted_args = rand( 1, 100 ); 63 63 … … 70 70 71 71 public function test_add_two_filters_with_different_priority() { 72 $callback_one = '__return_null'; 73 $callback_two = '__return_false'; 72 $callback_one = '__return_null'; 73 $callback_two = '__return_false'; 74 $hook = new WP_Hook(); 75 $tag = __FUNCTION__; 76 $priority = rand( 1, 100 ); 77 $accepted_args = rand( 1, 100 ); 78 79 $hook->add_filter( $tag, $callback_one, $priority, $accepted_args ); 80 $this->assertCount( 1, $hook->callbacks[ $priority ] ); 81 82 $hook->add_filter( $tag, $callback_two, $priority + 1, $accepted_args ); 83 $this->assertCount( 1, $hook->callbacks[ $priority ] ); 84 $this->assertCount( 1, $hook->callbacks[ $priority + 1 ] ); 85 } 86 87 public function test_readd_filter() { 88 $callback = '__return_null'; 89 $hook = new WP_Hook(); 90 $tag = __FUNCTION__; 91 $priority = rand( 1, 100 ); 92 $accepted_args = rand( 1, 100 ); 93 94 $hook->add_filter( $tag, $callback, $priority, $accepted_args ); 95 $this->assertCount( 1, $hook->callbacks[ $priority ] ); 96 97 $hook->add_filter( $tag, $callback, $priority, $accepted_args ); 98 $this->assertCount( 1, $hook->callbacks[ $priority ] ); 99 } 100 101 public function test_readd_filter_with_different_priority() { 102 $callback = '__return_null'; 103 $hook = new WP_Hook(); 104 $tag = __FUNCTION__; 105 $priority = rand( 1, 100 ); 106 $accepted_args = rand( 1, 100 ); 107 108 $hook->add_filter( $tag, $callback, $priority, $accepted_args ); 109 $this->assertCount( 1, $hook->callbacks[ $priority ] ); 110 111 $hook->add_filter( $tag, $callback, $priority + 1, $accepted_args ); 112 $this->assertCount( 1, $hook->callbacks[ $priority ] ); 113 $this->assertCount( 1, $hook->callbacks[ $priority + 1 ] ); 114 } 115 116 public function test_sort_after_add_filter() { 117 $a = new MockAction(); 118 $b = new MockAction(); 119 $c = new MockAction(); 74 120 $hook = new WP_Hook(); 75 $tag = __FUNCTION__; 76 $priority = rand( 1, 100 ); 77 $accepted_args = rand( 1, 100 ); 78 79 $hook->add_filter( $tag, $callback_one, $priority, $accepted_args ); 80 $this->assertCount( 1, $hook->callbacks[ $priority ] ); 81 82 $hook->add_filter( $tag, $callback_two, $priority + 1, $accepted_args ); 83 $this->assertCount( 1, $hook->callbacks[ $priority ] ); 84 $this->assertCount( 1, $hook->callbacks[ $priority + 1 ] ); 85 } 86 87 public function test_readd_filter() { 88 $callback = '__return_null'; 89 $hook = new WP_Hook(); 90 $tag = __FUNCTION__; 91 $priority = rand( 1, 100 ); 92 $accepted_args = rand( 1, 100 ); 93 94 $hook->add_filter( $tag, $callback, $priority, $accepted_args ); 95 $this->assertCount( 1, $hook->callbacks[ $priority ] ); 96 97 $hook->add_filter( $tag, $callback, $priority, $accepted_args ); 98 $this->assertCount( 1, $hook->callbacks[ $priority ] ); 99 } 100 101 public function test_readd_filter_with_different_priority() { 102 $callback = '__return_null'; 103 $hook = new WP_Hook(); 104 $tag = __FUNCTION__; 105 $priority = rand( 1, 100 ); 106 $accepted_args = rand( 1, 100 ); 107 108 $hook->add_filter( $tag, $callback, $priority, $accepted_args ); 109 $this->assertCount( 1, $hook->callbacks[ $priority ] ); 110 111 $hook->add_filter( $tag, $callback, $priority + 1, $accepted_args ); 112 $this->assertCount( 1, $hook->callbacks[ $priority ] ); 113 $this->assertCount( 1, $hook->callbacks[ $priority + 1 ] ); 114 } 115 116 public function test_sort_after_add_filter() { 117 $a = new MockAction(); 118 $b = new MockAction(); 119 $c = new MockAction(); 120 $hook = new WP_Hook(); 121 $tag = __FUNCTION__; 121 $tag = __FUNCTION__; 122 122 123 123 $hook->add_filter( $tag, array( $a, 'action' ), 10, 1 ); … … 202 202 203 203 public function test_remove_and_add_action() { 204 $this->hook = new Wp_Hook();204 $this->hook = new Wp_Hook(); 205 205 $this->action_output = ''; 206 206 … … 217 217 218 218 public function test_remove_and_add_last_action() { 219 $this->hook = new Wp_Hook();219 $this->hook = new Wp_Hook(); 220 220 $this->action_output = ''; 221 221 … … 232 232 233 233 public function test_remove_and_recurse_and_add_action() { 234 $this->hook = new Wp_Hook();234 $this->hook = new Wp_Hook(); 235 235 $this->action_output = ''; 236 236
Note: See TracChangeset
for help on using the changeset viewer.