| | 189 | |
| | 190 | function test_is_countable_availability() { |
| | 191 | $this->assertTrue( function_exists( 'is_countable' ) ); |
| | 192 | } |
| | 193 | |
| | 194 | /** |
| | 195 | * @dataProvider countable_variable_test_data |
| | 196 | */ |
| | 197 | function test_is_countable_functionality($variable, $is_countable) { |
| | 198 | $this->assertEquals( is_countable( $variable ), $is_countable ); |
| | 199 | } |
| | 200 | |
| | 201 | /** |
| | 202 | * Data provider for test_is_countable_functionality test. First array value |
| | 203 | * is the variable, and the second value is the expected return value of the |
| | 204 | * PHP 7.3's is_countable function. |
| | 205 | * @return array test data. |
| | 206 | */ |
| | 207 | public function countable_variable_test_data() { |
| | 208 | return array( |
| | 209 | array( true, false ), |
| | 210 | array( new stdClass(), false ), |
| | 211 | array( new ArrayIteratorFake(), true ), |
| | 212 | array( new CountableFake(), true ), |
| | 213 | array( 16, false ), |
| | 214 | array( null, false ), |
| | 215 | array( array( 1, 2, 3 ), true ), |
| | 216 | array( (array) 1, true ), |
| | 217 | array( (object) array( 'foo', 'bar', 'baz' ), false ), |
| | 218 | ); |
| | 219 | } |