Ticket #43583: 43583.diff
| File 43583.diff, 2.1 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
200 200 * @ticket 43583 201 201 * 202 202 * @dataProvider countable_variable_test_data 203 * 204 * @type mixed $variable Variable to check. 205 * @type bool $is_countable The expected return value of PHP 7.3 is_countable() function. 203 206 */ 204 207 function test_is_countable_functionality( $variable, $is_countable ) { 205 $this->assert Equals( is_countable( $variable ), $is_countable );208 $this->assertSame( is_countable( $variable ), $is_countable ); 206 209 } 207 210 208 211 /** 212 * Test is_countable() polyfill for ResourceBundle. 213 * 214 * @ticket 43583 215 */ 216 function test_is_countable_ResourceBundle() { 217 if ( ! class_exists( 'ResourceBundle' ) ) { 218 $this->markTestSkipped( 'The intl extension is not loaded. ResourceBundle not tested for is_countable().' ); 219 } 220 221 $this->assertTrue( is_countable( new ResourceBundle( 'en', null ) ) ); 222 } 223 224 /** 225 * Test is_countable() polyfill for SimpleXMLElement. 226 * 227 * @ticket 43583 228 */ 229 function test_is_countable_SimpleXMLElement() { 230 if ( ! class_exists( 'SimpleXMLElement' ) ) { 231 $this->markTestSkipped( 'The xml extension is not loaded. SimpleXMLElement not tested for is_countable().' ); 232 } 233 234 $this->assertTrue( is_countable( new SimpleXMLElement( '<xml><tag>1</tag><tag>2</tag></xml>' ) ) ); 235 } 236 237 /** 209 238 * Data provider for test_is_countable_functionality(). 210 239 * 211 240 * @ticket 43583