Changeset 51664
- Timestamp:
- 08/26/2021 04:02:13 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/functions/wpListUtil.php
r49006 r51664 5 5 */ 6 6 class Tests_Functions_wpListUtil extends WP_UnitTestCase { 7 8 public function data_test_wp_list_pluck() {9 return array(10 'arrays' => array(11 array(12 array(13 'foo' => 'bar',14 'bar' => 'baz',15 'abc' => 'xyz',16 ),17 array(18 'foo' => 'foo',19 '123' => '456',20 'lorem' => 'ipsum',21 ),22 array( 'foo' => 'baz' ),23 ),24 'foo',25 null,26 array( 'bar', 'foo', 'baz' ),27 ),28 'arrays with index key' => array(29 array(30 array(31 'foo' => 'bar',32 'bar' => 'baz',33 'abc' => 'xyz',34 'key' => 'foo',35 ),36 array(37 'foo' => 'foo',38 '123' => '456',39 'lorem' => 'ipsum',40 'key' => 'bar',41 ),42 array(43 'foo' => 'baz',44 'key' => 'value',45 ),46 ),47 'foo',48 'key',49 array(50 'foo' => 'bar',51 'bar' => 'foo',52 'value' => 'baz',53 ),54 ),55 'arrays with index key missing' => array(56 array(57 array(58 'foo' => 'bar',59 'bar' => 'baz',60 'abc' => 'xyz',61 ),62 array(63 'foo' => 'foo',64 '123' => '456',65 'lorem' => 'ipsum',66 'key' => 'bar',67 ),68 array(69 'foo' => 'baz',70 'key' => 'value',71 ),72 ),73 'foo',74 'key',75 array(76 'bar',77 'bar' => 'foo',78 'value' => 'baz',79 ),80 ),81 'objects' => array(82 array(83 (object) array(84 'foo' => 'bar',85 'bar' => 'baz',86 'abc' => 'xyz',87 ),88 (object) array(89 'foo' => 'foo',90 '123' => '456',91 'lorem' => 'ipsum',92 ),93 (object) array( 'foo' => 'baz' ),94 ),95 'foo',96 null,97 array( 'bar', 'foo', 'baz' ),98 ),99 'objects with index key' => array(100 array(101 (object) array(102 'foo' => 'bar',103 'bar' => 'baz',104 'abc' => 'xyz',105 'key' => 'foo',106 ),107 (object) array(108 'foo' => 'foo',109 '123' => '456',110 'lorem' => 'ipsum',111 'key' => 'bar',112 ),113 (object) array(114 'foo' => 'baz',115 'key' => 'value',116 ),117 ),118 'foo',119 'key',120 array(121 'foo' => 'bar',122 'bar' => 'foo',123 'value' => 'baz',124 ),125 ),126 'objects with index key missing' => array(127 array(128 (object) array(129 'foo' => 'bar',130 'bar' => 'baz',131 'abc' => 'xyz',132 ),133 (object) array(134 'foo' => 'foo',135 '123' => '456',136 'lorem' => 'ipsum',137 'key' => 'bar',138 ),139 (object) array(140 'foo' => 'baz',141 'key' => 'value',142 ),143 ),144 'foo',145 'key',146 array(147 'bar',148 'bar' => 'foo',149 'value' => 'baz',150 ),151 ),152 );153 }154 155 /**156 * @dataProvider data_test_wp_list_pluck157 *158 * @covers ::wp_list_pluck159 *160 * @param array $list List of objects or arrays.161 * @param int|string $field Field from the object to place instead of the entire object162 * @param int|string $index_key Field from the object to use as keys for the new array.163 * @param array $expected Expected result.164 */165 public function test_wp_list_pluck( $list, $field, $index_key, $expected ) {166 $this->assertSameSetsWithIndex( $expected, wp_list_pluck( $list, $field, $index_key ) );167 }168 7 169 8 public function data_test_wp_list_filter() {
Note: See TracChangeset
for help on using the changeset viewer.