Changeset 433 in tests
- Timestamp:
- 08/25/2011 07:51:22 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wp-testcase/test_includes_functions.php
r431 r433 257 257 258 258 function setUp() { 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 );259 $this->array_list['foo'] = array( 'name' => 'foo', 'field1' => true, 'field2' => true, 'field3' => true, 'field4' => array( 'red' ) ); 260 $this->array_list['bar'] = array( 'name' => 'bar', 'field1' => true, 'field2' => true, 'field3' => false, 'field4' => array( 'green' ) ); 261 $this->array_list['baz'] = array( 'name' => 'baz', 'field1' => true, 'field2' => false, 'field3' => false, 'field4' => array( 'blue' ) ); 262 262 foreach ( $this->array_list as $key => $value ) { 263 263 $this->object_list[ $key ] = (object) $value; … … 310 310 $list = wp_list_pluck( $this->array_list, 'name' ); 311 311 $this->assertEquals( array( 'foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz' ) , $list ); 312 } 313 314 function test_filter_object_list_nested_array_and() { 315 $list = wp_filter_object_list( $this->object_list, array( 'field4' => array( 'blue' ) ), 'AND' ); 316 $this->assertEquals( 1, count( $list ) ); 317 $this->assertArrayHasKey( 'baz', $list ); 318 } 319 320 function test_filter_object_list_nested_array_not() { 321 $list = wp_filter_object_list( $this->object_list, array( 'field4' => array( 'red' ) ), 'NOT' ); 322 $this->assertEquals( 2, count( $list ) ); 323 $this->assertArrayHasKey( 'bar', $list ); 324 $this->assertArrayHasKey( 'baz', $list ); 325 } 326 327 function test_filter_object_list_nested_array_or() { 328 $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 } 334 335 function test_filter_object_list_nested_array_and_field() { 336 $list = wp_filter_object_list( $this->object_list, array( 'field4' => array( 'blue' ) ), 'AND', 'name' ); 337 $this->assertEquals( 1, count( $list ) ); 338 $this->assertEquals( array( 'baz' => 'baz' ) , $list ); 339 } 340 341 function test_filter_object_list_nested_array_not_field() { 342 $list = wp_filter_object_list( $this->object_list, array( 'field4' => array( 'green' ) ), 'NOT', 'name' ); 343 $this->assertEquals( 2, count( $list ) ); 344 $this->assertEquals( array( 'foo' => 'foo', 'baz' => 'baz' ), $list ); 345 } 346 347 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 ); 312 351 } 313 352 }
Note: See TracChangeset
for help on using the changeset viewer.