Changeset 51666 for trunk/tests/phpunit/tests/functions/wpListUtil.php
- Timestamp:
- 08/26/2021 04:20:57 PM (4 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/functions/wpListUtil.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/functions/wpListUtil.php
r51664 r51666 5 5 */ 6 6 class Tests_Functions_wpListUtil extends WP_UnitTestCase { 7 8 public function data_test_wp_list_filter() {9 return array(10 'string instead of array' => array(11 'foo',12 array(),13 'AND',14 array(),15 ),16 'object instead of array' => array(17 (object) array( 'foo' ),18 array(),19 'AND',20 array(),21 ),22 'empty args' => array(23 array( 'foo', 'bar' ),24 array(),25 'AND',26 array( 'foo', 'bar' ),27 ),28 'invalid operator' => array(29 array(30 (object) array( 'foo' => 'bar' ),31 (object) array( 'foo' => 'baz' ),32 ),33 array( 'foo' => 'bar' ),34 'XOR',35 array(),36 ),37 'single argument to match' => array(38 array(39 (object) array(40 'foo' => 'bar',41 'bar' => 'baz',42 'abc' => 'xyz',43 'key' => 'foo',44 ),45 (object) array(46 'foo' => 'foo',47 '123' => '456',48 'lorem' => 'ipsum',49 'key' => 'bar',50 ),51 (object) array(52 'foo' => 'baz',53 'key' => 'value',54 ),55 (object) array(56 'foo' => 'bar',57 'key' => 'value',58 ),59 ),60 array( 'foo' => 'bar' ),61 'AND',62 array(63 0 => (object) array(64 'foo' => 'bar',65 'bar' => 'baz',66 'abc' => 'xyz',67 'key' => 'foo',68 ),69 3 => (object) array(70 'foo' => 'bar',71 'key' => 'value',72 ),73 ),74 ),75 'all must match' => array(76 array(77 (object) array(78 'foo' => 'bar',79 'bar' => 'baz',80 'abc' => 'xyz',81 'key' => 'foo',82 ),83 (object) array(84 'foo' => 'foo',85 '123' => '456',86 'lorem' => 'ipsum',87 'key' => 'bar',88 ),89 (object) array(90 'foo' => 'baz',91 'key' => 'value',92 'bar' => 'baz',93 ),94 (object) array(95 'foo' => 'bar',96 'key' => 'value',97 ),98 ),99 array(100 'foo' => 'bar',101 'bar' => 'baz',102 ),103 'AND',104 array(105 0 => (object) array(106 'foo' => 'bar',107 'bar' => 'baz',108 'abc' => 'xyz',109 'key' => 'foo',110 ),111 ),112 ),113 'any must match' => array(114 array(115 (object) array(116 'foo' => 'bar',117 'bar' => 'baz',118 'abc' => 'xyz',119 'key' => 'foo',120 ),121 (object) array(122 'foo' => 'foo',123 '123' => '456',124 'lorem' => 'ipsum',125 'key' => 'bar',126 ),127 (object) array(128 'foo' => 'baz',129 'key' => 'value',130 'bar' => 'baz',131 ),132 (object) array(133 'foo' => 'bar',134 'key' => 'value',135 ),136 ),137 array(138 'key' => 'value',139 'bar' => 'baz',140 ),141 'OR',142 array(143 0 => (object) array(144 'foo' => 'bar',145 'bar' => 'baz',146 'abc' => 'xyz',147 'key' => 'foo',148 ),149 2 => (object) array(150 'foo' => 'baz',151 'key' => 'value',152 'bar' => 'baz',153 ),154 3 => (object) array(155 'foo' => 'bar',156 'key' => 'value',157 ),158 ),159 ),160 'none must match' => array(161 array(162 (object) array(163 'foo' => 'bar',164 'bar' => 'baz',165 'abc' => 'xyz',166 'key' => 'foo',167 ),168 (object) array(169 'foo' => 'foo',170 '123' => '456',171 'lorem' => 'ipsum',172 'key' => 'bar',173 ),174 (object) array(175 'foo' => 'baz',176 'key' => 'value',177 ),178 (object) array(179 'foo' => 'bar',180 'key' => 'value',181 ),182 ),183 array(184 'key' => 'value',185 'bar' => 'baz',186 ),187 'NOT',188 array(189 1 => (object) array(190 'foo' => 'foo',191 '123' => '456',192 'lorem' => 'ipsum',193 'key' => 'bar',194 ),195 ),196 ),197 );198 }199 200 /**201 * @dataProvider data_test_wp_list_filter202 *203 * @covers ::wp_list_filter204 *205 * @param array $list An array of objects to filter.206 * @param array $args An array of key => value arguments to match207 * against each object.208 * @param string $operator The logical operation to perform.209 * @param array $expected Expected result.210 */211 public function test_wp_list_filter( $list, $args, $operator, $expected ) {212 $this->assertEqualSetsWithIndex( $expected, wp_list_filter( $list, $args, $operator ) );213 }214 7 215 8 public function data_test_wp_list_sort() {
Note: See TracChangeset
for help on using the changeset viewer.