Ensure `wp_list_pluck()` throws a warning when not being passed an array.

We should not paper over the code and hide warnings from developers by casting values to an array.

See #35087.

git-svn-id: https://develop.svn.wordpress.org/trunk@35949 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Pascal Birchler 2015-12-15 18:28:55 +00:00
parent c2943ef70a
commit 666d0736f4
1 changed files with 13 additions and 0 deletions

View File

@ -110,6 +110,19 @@ class Tests_Functions_ListFilter extends WP_UnitTestCase {
$this->assertEquals( array( 'f' => 'foo', 'b' => 'bar', 'z' => 'baz' ), $list );
}
/**
* When not being passed an array, the function should throw a warning.
*
* @ticket 35087
* @expectedException PHPUnit_Framework_Error_Warning
*/
function test_wp_list_pluck_non_array() {
$object = new stdClass();
$object->foo = 'abc';
$object->bar = 'def';
wp_list_pluck( $object, 'test' );
}
function test_filter_object_list_nested_array_and() {
$list = wp_filter_object_list( $this->object_list, array( 'field4' => array( 'blue' ) ), 'AND' );
$this->assertEquals( 1, count( $list ) );