|
1 | 1 | <?php |
2 | 2 |
|
3 | 3 | /** |
4 | | - * Tests for the absint function. |
| 4 | + * Tests for the absint() function. |
5 | 5 | * |
6 | 6 | * @group functions |
7 | 7 | * |
8 | 8 | * @covers ::absint |
9 | 9 | */ |
10 | | -class Tests_Functions_absint extends WP_UnitTestCase { |
| 10 | +class Tests_Functions_Absint extends WP_UnitTestCase { |
11 | 11 |
|
12 | 12 | /** |
13 | 13 | * @ticket 60101 |
14 | 14 | * |
15 | 15 | * @dataProvider data_absint |
16 | 16 | */ |
17 | | - public function test_absint( $maybe_int, $expected_value ) { |
18 | | - |
19 | | - $this->assertEquals( $expected_value, absint( $maybe_int ) ); |
| 17 | + public function test_absint( $test_value, $expected_value ) { |
| 18 | + $this->assertSame( $expected_value, absint( $test_value ) ); |
20 | 19 | } |
21 | 20 |
|
22 | 21 | /** |
23 | | - * @ticket 60101 |
24 | | - * |
25 | | - * Returns an array of test data for the `data_absint` method. |
| 22 | + * Data provider. |
26 | 23 | * |
27 | | - * @return array[] An array of test data. |
| 24 | + * @return array[] Test parameters { |
| 25 | + * @type string $test_value Test value. |
| 26 | + * @type string $expected Expected return value. |
| 27 | + * } |
28 | 28 | */ |
29 | 29 | public function data_absint() { |
30 | 30 | return array( |
31 | | - '1_int' => array( |
32 | | - 'maybe_int' => 1, |
| 31 | + '1 int' => array( |
| 32 | + 'test_value' => 1, |
33 | 33 | 'expected_value' => 1, |
34 | 34 | ), |
35 | | - '9.1_int' => array( |
36 | | - 'maybe_int' => 9.1, |
37 | | - 'expected_value' => 9, |
38 | | - ), |
39 | | - '9.9_int' => array( |
40 | | - 'maybe_int' => 9.9, |
41 | | - 'expected_value' => 9, |
42 | | - ), |
43 | | - '1_string' => array( |
44 | | - 'maybe_int' => 1, |
45 | | - 'expected_value' => '1', |
| 35 | + '1 string' => array( |
| 36 | + 'test_value' => '1', |
| 37 | + 'expected_value' => 1, |
46 | 38 | ), |
47 | | - '-1_int' => array( |
48 | | - 'maybe_int' => 1, |
| 39 | + '-1 int' => array( |
| 40 | + 'test_value' => -1, |
49 | 41 | 'expected_value' => 1, |
50 | 42 | ), |
51 | | - '-1_string' => array( |
52 | | - 'maybe_int' => 1, |
| 43 | + '-1 string' => array( |
| 44 | + 'test_value' => '-1', |
53 | 45 | 'expected_value' => 1, |
54 | 46 | ), |
| 47 | + '9.1 float' => array( |
| 48 | + 'test_value' => 9.1, |
| 49 | + 'expected_value' => 9, |
| 50 | + ), |
| 51 | + '9.9 float' => array( |
| 52 | + 'test_value' => 9.9, |
| 53 | + 'expected_value' => 9, |
| 54 | + ), |
55 | 55 | 'string' => array( |
56 | | - 'maybe_int' => 'string', |
| 56 | + 'test_value' => 'string', |
57 | 57 | 'expected_value' => 0, |
58 | 58 | ), |
59 | | - '999_string' => array( |
60 | | - 'maybe_int' => '999_string', |
61 | | - 'expected_value' => 999, |
62 | | - ), |
63 | 59 | 'string_1' => array( |
64 | | - 'maybe_int' => 'string_1', |
| 60 | + 'test_value' => 'string_1', |
65 | 61 | 'expected_value' => 0, |
66 | 62 | ), |
| 63 | + '999_string' => array( |
| 64 | + 'test_value' => '999_string', |
| 65 | + 'expected_value' => 999, |
| 66 | + ), |
67 | 67 | '99 string with spaces' => array( |
68 | | - 'maybe_int' => '99 string with spaces', |
| 68 | + 'test_value' => '99 string with spaces', |
69 | 69 | 'expected_value' => 99, |
70 | 70 | ), |
71 | | - 'array(99)' => array( |
72 | | - 'maybe_int' => array( 99 ), |
| 71 | + '99 array' => array( |
| 72 | + 'test_value' => array( 99 ), |
73 | 73 | 'expected_value' => 1, |
74 | 74 | ), |
75 | | - 'array("99")' => array( |
76 | | - 'maybe_int' => array( '99' ), |
| 75 | + '99 string array' => array( |
| 76 | + 'test_value' => array( '99' ), |
77 | 77 | 'expected_value' => 1, |
78 | 78 | ), |
79 | 79 | ); |
|
0 commit comments