Changeset 56141 for trunk/tests/phpunit/tests/functions/wpListUtil.php
- Timestamp:
- 07/05/2023 05:39:55 PM (17 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/functions/wpListUtil.php
r55423 r56141 211 211 * @dataProvider data_wp_list_util_sort_arrays_of_arrays 212 212 * @dataProvider data_wp_list_util_sort_object_arrays 213 * @dataProvider data_wp_list_util_sort_non_existent_orderby_fields 213 214 * 214 215 * @covers WP_List_Util::sort … … 1003 1004 1004 1005 /** 1005 * Tests non-existent '$orderby' fields. 1006 * 1007 * In PHP < 7.0.0, the sorting behavior is different, which Core does not 1008 * currently handle. Until this is fixed, or the minimum PHP version is 1009 * raised to PHP 7.0.0+, these tests will be skipped on PHP < 7.0.0. 1010 * 1011 * @ticket 55300 1012 * 1013 * @dataProvider data_wp_list_util_sort_php_7_or_greater 1014 * 1015 * @covers WP_List_Util::sort 1016 * @covers ::wp_list_sort 1017 * 1018 * @param array $expected The expected array. 1019 * @param array $target_array The array to create a list from. 1020 * @param array $orderby Optional. Either the field name to order by or an array 1021 * of multiple orderby fields as `$orderby => $order`. 1022 * Default empty array. 1023 * @param string $order Optional. Either 'ASC' or 'DESC'. Only used if `$orderby` 1024 * is a string. Default 'ASC'. 1025 * @param bool $preserve_keys Optional. Whether to preserve keys. Default false. 1026 */ 1027 public function test_wp_list_util_sort_php_7_or_greater( $expected, $target_array, $orderby = array(), $order = 'ASC', $preserve_keys = false ) { 1028 if ( version_compare( PHP_VERSION, '7.0.0', '<' ) ) { 1029 $this->markTestSkipped( 'This test can only run on PHP 7.0 or greater due to an unstable sort order.' ); 1030 } 1031 1032 $util = new WP_List_Util( $target_array ); 1033 $actual = $util->sort( $orderby, $order, $preserve_keys ); 1034 1035 $this->assertEqualSetsWithIndex( 1036 $expected, 1037 $actual, 1038 'The sorted value did not match the expected value.' 1039 ); 1040 $this->assertEqualSetsWithIndex( 1041 $expected, 1042 $util->get_output(), 1043 '::get_output() did not return the expected value.' 1044 ); 1045 } 1046 1047 /** 1048 * Data provider for test_wp_list_util_sort_php_7_or_greater(). 1006 * Data provider for test_wp_list_util_sort(). 1049 1007 * 1050 1008 * @return array[] 1051 1009 */ 1052 public function data_wp_list_util_sort_ php_7_or_greater() {1010 public function data_wp_list_util_sort_non_existent_orderby_fields() { 1053 1011 return array( 1054 1012 'int[], int keys, $orderby a non-existent field, $order = ASC and $preserve_keys = false' => array(
Note: See TracChangeset
for help on using the changeset viewer.