| 146 | /** |
| 147 | * @ticket 30875 |
| 148 | */ |
| 149 | function test_action_priority_is_valid() { |
| 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, 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( 10, has_action( '_test_string', array( &$a, 'action' ) ) ); |
| 176 | |
| 177 | // Test boolean |
| 178 | add_action( '_test_bool', array( &$a, 'action' ), true ); |
| 179 | do_action( '_test_bool' ); |
| 180 | $this->assertEquals( 10, has_action( '_test_bool', array( &$a, 'action' ) ) ); |
| 181 | |
| 182 | // Test boolean as string |
| 183 | add_action( '_test_bool_as_string', array( &$a, 'action' ), 'true' ); |
| 184 | do_action( '_test_bool_as_string' ); |
| 185 | $this->assertEquals( 10, has_action( '_test_bool_as_string', array( &$a, 'action' ) ) ); |
| 186 | |
| 187 | // Test array |
| 188 | add_action( '_test_array', array( &$a, 'action' ), array() ); |
| 189 | do_action( '_test_array' ); |
| 190 | $this->assertEquals( 10, has_action( '_test_array', array( &$a, 'action' ) ) ); |
| 191 | |
| 192 | // Test object |
| 193 | add_action( '_test_oject', array( &$a, 'action' ), new stdClass() ); |
| 194 | do_action( '_test_oject' ); |
| 195 | $this->assertEquals( 10, has_action( '_test_oject', array( &$a, 'action' ) ) ); |
| 196 | } |
| 197 | |