forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabsint.php
More file actions
81 lines (77 loc) · 1.75 KB
/
absint.php
File metadata and controls
81 lines (77 loc) · 1.75 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
78
79
80
81
<?php
/**
* Tests for the absint function.
*
* @group functions
*
* @covers ::absint
*/
class Tests_Functions_absint extends WP_UnitTestCase {
/**
* @ticket 60101
*
* @dataProvider data_absint
*/
public function test_absint( $maybe_int, $expected_value ) {
$this->assertEquals( $expected_value, absint( $maybe_int ) );
}
/**
* @ticket 60101
*
* Returns an array of test data for the `data_absint` method.
*
* @return array[] An array of test data.
*/
public function data_absint() {
return array(
'1_int' => array(
'maybe_int' => 1,
'expected_value' => 1,
),
'9.1_int' => array(
'maybe_int' => 9.1,
'expected_value' => 9,
),
'9.9_int' => array(
'maybe_int' => 9.9,
'expected_value' => 9,
),
'1_string' => array(
'maybe_int' => 1,
'expected_value' => '1',
),
'-1_int' => array(
'maybe_int' => 1,
'expected_value' => 1,
),
'-1_string' => array(
'maybe_int' => 1,
'expected_value' => 1,
),
'string' => array(
'maybe_int' => 'string',
'expected_value' => 0,
),
'999_string' => array(
'maybe_int' => '999_string',
'expected_value' => 999,
),
'string_1' => array(
'maybe_int' => 'string_1',
'expected_value' => 0,
),
'99 string with spaces' => array(
'maybe_int' => '99 string with spaces',
'expected_value' => 99,
),
'array(99)' => array(
'maybe_int' => array( 99 ),
'expected_value' => 1,
),
'array("99")' => array(
'maybe_int' => array( '99' ),
'expected_value' => 1,
),
);
}
}