Changeset 55423 for trunk/tests/phpunit/tests/functions/wpListUtil.php
- Timestamp:
- 02/25/2023 10:57:14 AM (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/functions/wpListUtil.php
r54855 r55423 86 86 87 87 /** 88 * Data provider for test_wp_list_util_pluck _simple().88 * Data provider for test_wp_list_util_pluck(). 89 89 * 90 90 * @return array[] … … 106 106 'expected' => array( 'bar' ), 107 107 ), 108 ); 109 } 110 111 /** 112 * Tests that wp_list_pluck() throws _doing_it_wrong() with invalid input. 113 * 114 * @ticket 56650 115 * 116 * @dataProvider data_wp_list_pluck_should_throw_doing_it_wrong_with_invalid_input 117 * 118 * @covers WP_List_Util::pluck 119 * @covers ::wp_list_pluck 120 * 121 * @expectedIncorrectUsage WP_List_Util::pluck 122 * 123 * @param array $input An invalid input array. 124 */ 125 public function test_wp_list_pluck_should_throw_doing_it_wrong_with_invalid_input( $input ) { 126 $this->assertSame( array(), wp_list_pluck( $input, 'a_field' ) ); 127 } 128 129 /** 130 * Tests that wp_list_pluck() throws _doing_it_wrong() with an index key and invalid input. 131 * 132 * @ticket 56650 133 * 134 * @dataProvider data_wp_list_pluck_should_throw_doing_it_wrong_with_invalid_input 135 * 136 * @covers WP_List_Util::pluck 137 * @covers ::wp_list_pluck 138 * 139 * @expectedIncorrectUsage WP_List_Util::pluck 140 * 141 * @param array $input An invalid input array. 142 */ 143 public function test_wp_list_pluck_should_throw_doing_it_wrong_with_index_key_and_invalid_input( $input ) { 144 $this->assertSame( array(), wp_list_pluck( $input, 'a_field', 'an_index_key' ) ); 145 } 146 147 /** 148 * Data provider that provides invalid input arrays. 149 * 150 * @return array 151 */ 152 public function data_wp_list_pluck_should_throw_doing_it_wrong_with_invalid_input() { 153 return array( 154 'int[] 0' => array( array( 0 ) ), 155 'int[] 1' => array( array( 1 ) ), 156 'int[] -1' => array( array( -1 ) ), 157 'float[] 0.0' => array( array( 0.0 ) ), 158 'float[] 1.0' => array( array( 1.0 ) ), 159 'float[] -1.0' => array( array( -1.0 ) ), 160 'string[] and empty string' => array( array( '' ) ), 161 'string[] and "0"' => array( array( '0' ) ), 162 'string[] and "1"' => array( array( '1' ) ), 163 'string[] and "-1"' => array( array( '-1' ) ), 164 'array and null' => array( array( null ) ), 165 'array and false' => array( array( false ) ), 166 'array and true' => array( array( true ) ), 108 167 ); 109 168 }
Note: See TracChangeset
for help on using the changeset viewer.