Changeset 62797 for trunk/tests/phpunit/tests/functions/wpParseIdList.php
- Timestamp:
- 07/19/2026 04:53:46 PM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/functions/wpParseIdList.php
r57737 r62797 16 16 * @dataProvider data_wp_parse_id_list 17 17 * @dataProvider data_unexpected_input 18 * 19 * @param mixed[]|string $input_list 20 * @param array<non-negative-int> $expected 18 21 */ 19 public function test_wp_parse_id_list( $input_list, $expected ) { 20 $this->assertSameSets( $expected, wp_parse_id_list( $input_list ) ); 22 public function test_wp_parse_id_list( $input_list, array $expected ): void { 23 $parsed_list = wp_parse_id_list( $input_list ); 24 $this->assertThat( 25 $parsed_list, 26 $this->callback( 27 static fn ( array $arr ) => array_all( 28 $arr, 29 static fn ( $v ) => is_int( $v ) && $v >= 0 30 ) 31 ), 32 'Array should contain only non-negative ints.' 33 ); 34 $this->assertSame( $expected, $parsed_list ); 21 35 } 22 36 … … 24 38 * Data provider. 25 39 * 26 * @return array []40 * @return array<string, array{ input_list: mixed[]|string, expected: array<non-negative-int> }> 27 41 */ 28 public function data_wp_parse_id_list() {42 public function data_wp_parse_id_list(): array { 29 43 return array( 30 44 'regular' => array( … … 38 52 'duplicate id in a string' => array( 39 53 'input_list' => '1,2,2,3,4', 40 'expected' => array( 1, 2, 3, 4 ), 54 'expected' => array( 55 0 => 1, 56 1 => 2, 57 3 => 3, 58 4 => 4, 59 ), 41 60 ), 42 61 'duplicate id in an array' => array( … … 62 81 * Data provider. 63 82 * 64 * @return array []83 * @return array<string, array{ input_list: mixed[]|string, expected: array<non-negative-int> }> 65 84 */ 66 public function data_unexpected_input() {85 public function data_unexpected_input(): array { 67 86 return array( 68 87 'string with commas' => array( … … 98 117 'expected' => array( 1, 2, 0 ), 99 118 ), 119 'array with array' => array( 120 'input_list' => array( 1, array(), 2 ), 121 'expected' => array( 122 0 => 1, 123 2 => 2, 124 ), 125 ), 126 'passed assoc array' => array( 127 'input_list' => array( 128 'one' => 1, 129 'two' => '2', 130 'three' => '3 is company', 131 ), 132 'expected' => array( 133 'one' => 1, 134 'two' => 2, 135 'three' => 3, 136 ), 137 ), 100 138 ); 101 139 }
Note:
See TracChangeset
for help on using the changeset viewer.