| | 146 | /** |
| | 147 | * @ticket 30875 |
| | 148 | */ |
| | 149 | function test_add_filter_priority_value() { |
| | 150 | $a = new MockAction(); |
| | 151 | |
| | 152 | // Test integers |
| | 153 | add_action( '_test_int', array( &$a, 'action' ), 10 ); |
| | 154 | do_action( '_test_int' ); |
| | 155 | $this->assertEquals( 10, has_action( '_test_int', array( &$a, 'action' ) ) ); |
| | 156 | |
| | 157 | // Test integer as string |
| | 158 | add_action( '_test_int_as_string', array( &$a, 'action' ), '9' ); |
| | 159 | do_action( '_test_int_as_string' ); |
| | 160 | $this->assertEquals( 9, has_action( '_test_int_as_string', array( &$a, 'action' ) ) ); |
| | 161 | |
| | 162 | // Test float |
| | 163 | add_action( '_test_float', array( &$a, 'action' ), 8.1 ); |
| | 164 | do_action( '_test_float' ); |
| | 165 | $this->assertEquals( 8, has_action( '_test_float', array( &$a, 'action' ) ) ); |
| | 166 | |
| | 167 | // Test float as string |
| | 168 | add_action( '_test_float_as_string', array( &$a, 'action' ), '7.2' ); |
| | 169 | do_action( '_test_float_as_string' ); |
| | 170 | $this->assertEquals( '7.2', has_action( '_test_float_as_string', array( &$a, 'action' ) ) ); |
| | 171 | |
| | 172 | // Test string |
| | 173 | add_action( '_test_string', array( &$a, 'action' ), 'micky' ); |
| | 174 | do_action( '_test_string' ); |
| | 175 | $this->assertEquals( 'micky', has_action( '_test_string', array( &$a, 'action' ) ) ); |
| | 176 | |
| | 177 | // Test boolean true |
| | 178 | add_action( '_test_bool_true', array( &$a, 'action' ), true ); |
| | 179 | do_action( '_test_bool_true' ); |
| | 180 | $this->assertEquals( 1, has_action( '_test_bool_true', array( &$a, 'action' ) ) ); |
| | 181 | |
| | 182 | // Test boolean false |
| | 183 | add_action( '_test_bool_false', array( &$a, 'action' ), false ); |
| | 184 | do_action( '_test_bool_false' ); |
| | 185 | $this->assertEquals( 0, has_action( '_test_bool_false', array( &$a, 'action' ) ) ); |
| | 186 | |
| | 187 | // Test boolean as string |
| | 188 | add_action( '_test_bool_as_string', array( &$a, 'action' ), 'true' ); |
| | 189 | do_action( '_test_bool_as_string' ); |
| | 190 | $this->assertEquals( 'true', has_action( '_test_bool_as_string', array( &$a, 'action' ) ) ); |
| | 191 | |
| | 192 | // Test array |
| | 193 | add_action( '_test_array', array( &$a, 'action' ), array() ); |
| | 194 | do_action( '_test_array' ); |
| | 195 | $this->assertEquals( false, has_action( '_test_array', array( &$a, 'action' ) ) ); |
| | 196 | |
| | 197 | // Test object |
| | 198 | add_action( '_test_object', array( &$a, 'action' ), new stdClass() ); |
| | 199 | do_action( '_test_object' ); |
| | 200 | $this->assertEquals( false, has_action( '_test_object', array( &$a, 'action' ) ) ); |
| | 201 | } |
| | 202 | |