WordPress.org

Make WordPress Core

Changeset 431 in tests


Ignore:
Timestamp:
08/25/2011 06:19:46 PM (7 years ago)
Author:
ryan
Message:

wp_list_pluck tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_includes_functions.php

    r410 r431  
    254254class TestListFilter extends WPTestCase {
    255255    var $object_list = array();
     256    var $array_list = array();
    256257
    257258    function setUp() {
    258         $this->object_list['foo'] = (object) array( 'name' => 'foo', 'field1' => true, 'field2' => true, 'field3' => true );
    259         $this->object_list['bar'] = (object) array( 'name' => 'bar', 'field1' => true, 'field2' => true, 'field3' => false );
    260         $this->object_list['baz'] = (object) array( 'name' => 'baz', 'field1' => true, 'field2' => false, 'field3' => false );     
     259        $this->array_list['foo'] = array( 'name' => 'foo', 'field1' => true, 'field2' => true, 'field3' => true );
     260        $this->array_list['bar'] = array( 'name' => 'bar', 'field1' => true, 'field2' => true, 'field3' => false );
     261        $this->array_list['baz'] = array( 'name' => 'baz', 'field1' => true, 'field2' => false, 'field3' => false );
     262        foreach ( $this->array_list as $key => $value ) {
     263            $this->object_list[ $key ] = (object) $value;
     264        }
    261265    }
    262266
     
    298302        $this->assertEquals( 1, count( $list ) );
    299303        $this->assertEquals( array( 'baz' => 'baz' ) , $list );
     304    }
     305
     306    function test_wp_list_pluck() {
     307        $list = wp_list_pluck( $this->object_list, 'name' );
     308        $this->assertEquals( array( 'foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz' ) , $list );
     309
     310        $list = wp_list_pluck( $this->array_list, 'name' );
     311        $this->assertEquals( array( 'foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz' ) , $list );
    300312    }
    301313}
Note: See TracChangeset for help on using the changeset viewer.