Files
wordpress-develop/tests/phpunit/tests/functions/wpIsNumericArray.php
Sergey Biryukov 31e9247872 Tests: Remove the formatting group from wp_is_numeric_array() tests.
Similar to `wp_array_slice_assoc()` or other array-related functions, this appears to be a general-purpose function unrelated to the Formatting component.

Add missing `public` visibility keyword.

Follow-up to [52037].

See #53971.

git-svn-id: https://develop.svn.wordpress.org/trunk@52048 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-08 17:07:49 +00:00

71 lines
1.5 KiB
PHP

<?php
/**
* @group functions.php
* @covers ::wp_is_numeric_array
*/
class Tests_Functions_wpIsNumericArray extends WP_UnitTestCase {
/**
* @dataProvider data_wp_is_numeric_array
*
* @ticket 53971
*
* @param mixed $input Input to test.
* @param array $expected Expected result.
*/
public function test_wp_is_numeric_array( $input, $expected ) {
$this->assertSame( $expected, wp_is_numeric_array( $input ) );
}
/**
* Data provider.
*
* @return array[]
*/
public function data_wp_is_numeric_array() {
return array(
'no index' => array(
'test_array' => array( 'www', 'eee' ),
'expected' => true,
),
'text index' => array(
'test_array' => array( 'www' => 'eee' ),
'expected' => false,
),
'numeric index' => array(
'test_array' => array( 99 => 'eee' ),
'expected' => true,
),
'- numeric index' => array(
'test_array' => array( -11 => 'eee' ),
'expected' => true,
),
'numeric string index' => array(
'test_array' => array( '11' => 'eee' ),
'expected' => true,
),
'nested number index' => array(
'test_array' => array(
'next' => array(
11 => 'vvv',
),
),
'expected' => false,
),
'nested string index' => array(
'test_array' => array(
'11' => array(
'eee' => 'vvv',
),
),
'expected' => true,
),
'not an array' => array(
'test_array' => null,
'expected' => false,
),
);
}
}