mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-07 09:49:04 +00:00
Tests: Remove duplicate wp_list_pluck() tests.
The tests were partially duplicated in two separate files, and are now located in their own file. Follow-up to [431/tests], [28900], [38928], [42527], [51663]. See #53363, #53987. git-svn-id: https://develop.svn.wordpress.org/trunk@51664 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -5,167 +5,6 @@
|
||||
*/
|
||||
class Tests_Functions_wpListUtil extends WP_UnitTestCase {
|
||||
|
||||
public function data_test_wp_list_pluck() {
|
||||
return array(
|
||||
'arrays' => array(
|
||||
array(
|
||||
array(
|
||||
'foo' => 'bar',
|
||||
'bar' => 'baz',
|
||||
'abc' => 'xyz',
|
||||
),
|
||||
array(
|
||||
'foo' => 'foo',
|
||||
'123' => '456',
|
||||
'lorem' => 'ipsum',
|
||||
),
|
||||
array( 'foo' => 'baz' ),
|
||||
),
|
||||
'foo',
|
||||
null,
|
||||
array( 'bar', 'foo', 'baz' ),
|
||||
),
|
||||
'arrays with index key' => array(
|
||||
array(
|
||||
array(
|
||||
'foo' => 'bar',
|
||||
'bar' => 'baz',
|
||||
'abc' => 'xyz',
|
||||
'key' => 'foo',
|
||||
),
|
||||
array(
|
||||
'foo' => 'foo',
|
||||
'123' => '456',
|
||||
'lorem' => 'ipsum',
|
||||
'key' => 'bar',
|
||||
),
|
||||
array(
|
||||
'foo' => 'baz',
|
||||
'key' => 'value',
|
||||
),
|
||||
),
|
||||
'foo',
|
||||
'key',
|
||||
array(
|
||||
'foo' => 'bar',
|
||||
'bar' => 'foo',
|
||||
'value' => 'baz',
|
||||
),
|
||||
),
|
||||
'arrays with index key missing' => array(
|
||||
array(
|
||||
array(
|
||||
'foo' => 'bar',
|
||||
'bar' => 'baz',
|
||||
'abc' => 'xyz',
|
||||
),
|
||||
array(
|
||||
'foo' => 'foo',
|
||||
'123' => '456',
|
||||
'lorem' => 'ipsum',
|
||||
'key' => 'bar',
|
||||
),
|
||||
array(
|
||||
'foo' => 'baz',
|
||||
'key' => 'value',
|
||||
),
|
||||
),
|
||||
'foo',
|
||||
'key',
|
||||
array(
|
||||
'bar',
|
||||
'bar' => 'foo',
|
||||
'value' => 'baz',
|
||||
),
|
||||
),
|
||||
'objects' => array(
|
||||
array(
|
||||
(object) array(
|
||||
'foo' => 'bar',
|
||||
'bar' => 'baz',
|
||||
'abc' => 'xyz',
|
||||
),
|
||||
(object) array(
|
||||
'foo' => 'foo',
|
||||
'123' => '456',
|
||||
'lorem' => 'ipsum',
|
||||
),
|
||||
(object) array( 'foo' => 'baz' ),
|
||||
),
|
||||
'foo',
|
||||
null,
|
||||
array( 'bar', 'foo', 'baz' ),
|
||||
),
|
||||
'objects with index key' => array(
|
||||
array(
|
||||
(object) array(
|
||||
'foo' => 'bar',
|
||||
'bar' => 'baz',
|
||||
'abc' => 'xyz',
|
||||
'key' => 'foo',
|
||||
),
|
||||
(object) array(
|
||||
'foo' => 'foo',
|
||||
'123' => '456',
|
||||
'lorem' => 'ipsum',
|
||||
'key' => 'bar',
|
||||
),
|
||||
(object) array(
|
||||
'foo' => 'baz',
|
||||
'key' => 'value',
|
||||
),
|
||||
),
|
||||
'foo',
|
||||
'key',
|
||||
array(
|
||||
'foo' => 'bar',
|
||||
'bar' => 'foo',
|
||||
'value' => 'baz',
|
||||
),
|
||||
),
|
||||
'objects with index key missing' => array(
|
||||
array(
|
||||
(object) array(
|
||||
'foo' => 'bar',
|
||||
'bar' => 'baz',
|
||||
'abc' => 'xyz',
|
||||
),
|
||||
(object) array(
|
||||
'foo' => 'foo',
|
||||
'123' => '456',
|
||||
'lorem' => 'ipsum',
|
||||
'key' => 'bar',
|
||||
),
|
||||
(object) array(
|
||||
'foo' => 'baz',
|
||||
'key' => 'value',
|
||||
),
|
||||
),
|
||||
'foo',
|
||||
'key',
|
||||
array(
|
||||
'bar',
|
||||
'bar' => 'foo',
|
||||
'value' => 'baz',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider data_test_wp_list_pluck
|
||||
*
|
||||
* @covers ::wp_list_pluck
|
||||
*
|
||||
* @param array $list List of objects or arrays.
|
||||
* @param int|string $field Field from the object to place instead of the entire object
|
||||
* @param int|string $index_key Field from the object to use as keys for the new array.
|
||||
* @param array $expected Expected result.
|
||||
*/
|
||||
public function test_wp_list_pluck( $list, $field, $index_key, $expected ) {
|
||||
$this->assertSameSetsWithIndex( $expected, wp_list_pluck( $list, $field, $index_key ) );
|
||||
}
|
||||
|
||||
public function data_test_wp_list_filter() {
|
||||
return array(
|
||||
'string instead of array' => array(
|
||||
|
||||
Reference in New Issue
Block a user