Changeset 58150
- Timestamp:
- 05/15/2024 01:07:35 AM (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/functions/absint.php
r57735 r58150 2 2 3 3 /** 4 * Tests for the absint function.4 * Tests for the absint() function. 5 5 * 6 6 * @group functions … … 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 /** … … 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 6010122 * Data provider. 24 23 * 25 * Returns an array of test data for the `data_absint` method. 26 * 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, 35 '1 string' => array( 36 'test_value' => '1', 37 'expected_value' => 1, 38 ), 39 '-1 int' => array( 40 'test_value' => -1, 41 'expected_value' => 1, 42 ), 43 '-1 string' => array( 44 'test_value' => '-1', 45 'expected_value' => 1, 46 ), 47 '9.1 float' => array( 48 'test_value' => 9.1, 37 49 'expected_value' => 9, 38 50 ), 39 '9.9 _int'=> array(40 ' maybe_int'=> 9.9,51 '9.9 float' => array( 52 'test_value' => 9.9, 41 53 'expected_value' => 9, 42 54 ), 43 ' 1_string'=> array(44 ' maybe_int' => 1,45 'expected_value' => '1',55 'string' => array( 56 'test_value' => 'string', 57 'expected_value' => 0, 46 58 ), 47 '-1_int' => array( 48 'maybe_int' => 1, 49 'expected_value' => 1, 50 ), 51 '-1_string' => array( 52 'maybe_int' => 1, 53 'expected_value' => 1, 54 ), 55 'string' => array( 56 'maybe_int' => 'string', 59 'string_1' => array( 60 'test_value' => 'string_1', 57 61 'expected_value' => 0, 58 62 ), 59 63 '999_string' => array( 60 ' maybe_int'=> '999_string',64 'test_value' => '999_string', 61 65 'expected_value' => 999, 62 66 ), 63 'string_1' => array(64 'maybe_int' => 'string_1',65 'expected_value' => 0,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 ),
Note: See TracChangeset
for help on using the changeset viewer.