Ticket #43583: 43583.2.diff
| File 43583.2.diff, 2.2 KB (added by , 8 years ago) |
|---|
-
src/wp-includes/compat.php
520 520 * @return bool True if `$var` is countable, false otherwise. 521 521 */ 522 522 function is_countable( $var ) { 523 return ( is_array( $var ) || $var instanceof Countable ); 523 return ( is_array( $var ) 524 || $var instanceof Countable 525 || $var instanceof SimpleXMLElement 526 || $var instanceof ResourceBundle 527 ); 524 528 } 525 529 } 526 530 -
tests/phpunit/tests/compat.php
188 188 } 189 189 190 190 /** 191 * Test that is_countable() is always available (either from PHP or WP). 192 * 191 193 * @ticket 43583 192 194 */ 193 195 function test_is_countable_availability() { … … 200 202 * @ticket 43583 201 203 * 202 204 * @dataProvider countable_variable_test_data 205 * 206 * @param mixed $variable Variable to check. 207 * @param bool $is_countable The expected return value of PHP 7.3 is_countable() function. 203 208 */ 204 209 function test_is_countable_functionality( $variable, $is_countable ) { 205 $this->assert Equals( is_countable( $variable ), $is_countable );210 $this->assertSame( is_countable( $variable ), $is_countable ); 206 211 } 207 212 208 213 /** … … 232 237 } 233 238 234 239 /** 240 * Test is_countable() polyfill for ResourceBundle. 241 * 242 * @ticket 43583 243 */ 244 function test_is_countable_ResourceBundle() { 245 if ( ! class_exists( 'ResourceBundle' ) ) { 246 $this->markTestSkipped( 'The intl extension is not loaded. ResourceBundle not tested for is_countable().' ); 247 } 248 249 $this->assertTrue( is_countable( new ResourceBundle( 'en', null ) ) ); 250 } 251 252 /** 253 * Test is_countable() polyfill for SimpleXMLElement. 254 * 255 * @ticket 43583 256 */ 257 function test_is_countable_SimpleXMLElement() { 258 if ( ! class_exists( 'SimpleXMLElement' ) ) { 259 $this->markTestSkipped( 'The xml extension is not loaded. SimpleXMLElement not tested for is_countable().' ); 260 } 261 262 $this->assertTrue( is_countable( new SimpleXMLElement( '<xml><tag>1</tag><tag>2</tag></xml>' ) ) ); 263 } 264 /** 235 265 * @ticket 43619 236 266 */ 237 267 function test_is_iterable_availability() {