forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathisIterable.php
More file actions
77 lines (73 loc) · 1.82 KB
/
isIterable.php
File metadata and controls
77 lines (73 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/**
* @group compat
*
* @covers ::is_iterable
*/
class Tests_Compat_isIterable extends WP_UnitTestCase {
/**
* Test that is_iterable() is always available (either from PHP or WP).
*
* @ticket 43619
*/
public function test_is_iterable_availability() {
$this->assertTrue( function_exists( 'is_iterable' ) );
}
/**
* Test is_iterable() polyfill.
*
* @ticket 43619
*
* @dataProvider data_is_iterable_functionality
*
* @param mixed $variable Variable to check.
* @param bool $is_iterable The expected return value of PHP 7.1 is_iterable() function.
*/
public function test_is_iterable_functionality( $variable, $is_iterable ) {
$this->assertSame( $is_iterable, is_iterable( $variable ) );
}
/**
* Data provider for test_is_iterable_functionality().
*
* @ticket 43619
*
* @return array {
* @type array {
* @type mixed $variable Variable to check.
* @type bool $is_iterable The expected return value of PHP 7.1 is_iterable() function.
* }
* }
*/
public function data_is_iterable_functionality() {
return array(
'empty array' => array(
'variable' => array(),
'is_iterable' => true,
),
'non-empty array' => array(
'variable' => array( 1, 2, 3 ),
'is_iterable' => true,
),
'Iterator object' => array(
'variable' => new ArrayIterator( array( 1, 2, 3 ) ),
'is_iterable' => true,
),
'null' => array(
'variable' => null,
'is_iterable' => false,
),
'integer 1' => array(
'variable' => 1,
'is_iterable' => false,
),
'float 3.14' => array(
'variable' => 3.14,
'is_iterable' => false,
),
'plain stdClass object' => array(
'variable' => new stdClass(),
'is_iterable' => false,
),
);
}
}