WordPress.org

Make WordPress Core

Changeset 437 in tests


Ignore:
Timestamp:
09/18/11 13:50:41 (3 years ago)
Author:
dd32
Message:

Better test cases for wp_filter_object_list() with OR, Previous test's passed OR returning *all* elements rather than the ones matching the criteria. See #WP18092

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_includes_functions.php

    r433 r437  
    293293 
    294294    function test_filter_object_list_or_field() { 
    295         $list = wp_filter_object_list( $this->object_list, array( 'field1' => true, 'field2' => true ), 'OR', 'name' ); 
    296         $this->assertEquals( 3, count( $list ) ); 
    297         $this->assertEquals( array( 'foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz' ) , $list ); 
     295        $list = wp_filter_object_list( $this->object_list, array( 'field2' => true, 'field3' => true ), 'OR', 'name' ); 
     296        $this->assertEquals( 2, count( $list ) ); 
     297        $this->assertEquals( array( 'foo' => 'foo', 'bar' => 'bar' ) , $list ); 
    298298    } 
    299299 
     
    326326 
    327327    function test_filter_object_list_nested_array_or() { 
     328        $list = wp_filter_object_list( $this->object_list, array( 'field3' => true, 'field4' => array( 'blue' ) ), 'OR' ); 
     329        $this->assertEquals( 2, count( $list ) ); 
     330        $this->assertArrayHasKey( 'foo', $list ); 
     331        $this->assertArrayHasKey( 'baz', $list ); 
     332    } 
     333 
     334    function test_filter_object_list_nested_array_or_singular() { 
    328335        $list = wp_filter_object_list( $this->object_list, array( 'field4' => array( 'blue' ) ), 'OR' ); 
    329         $this->assertEquals( 3, count( $list ) ); 
    330         $this->assertArrayHasKey( 'foo', $list ); 
    331         $this->assertArrayHasKey( 'bar', $list ); 
    332         $this->assertArrayHasKey( 'baz', $list ); 
    333     } 
     336        $this->assertEquals( 1, count( $list ) ); 
     337        $this->assertArrayHasKey( 'baz', $list ); 
     338    } 
     339 
    334340 
    335341    function test_filter_object_list_nested_array_and_field() { 
     
    346352 
    347353    function test_filter_object_list_nested_array_or_field() { 
    348         $list = wp_filter_object_list( $this->object_list, array( 'field4' => array( 'blue' ) ), 'OR', 'name' ); 
    349         $this->assertEquals( 3, count( $list ) ); 
    350         $this->assertEquals( array( 'foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz' ), $list ); 
     354        $list = wp_filter_object_list( $this->object_list, array( 'field3' => true, 'field4' => array( 'blue' ) ), 'OR', 'name' ); 
     355        $this->assertEquals( 2, count( $list ) ); 
     356        $this->assertEquals( array( 'foo' => 'foo', 'baz' => 'baz' ), $list ); 
    351357    } 
    352358} 
Note: See TracChangeset for help on using the changeset viewer.