Changeset 28583
- Timestamp:
- 05/27/2014 03:28:05 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r28562 r28583 2338 2338 } 2339 2339 2340 if ( ! $terms ) 2340 if ( ! $terms ) { 2341 2341 $terms = array(); 2342 2342 } else { 2343 $terms = array_values( array_unique( $terms, SORT_REGULAR ) ); 2344 } 2343 2345 /** 2344 2346 * Filter the terms for a given object or objects. -
trunk/tests/phpunit/tests/term.php
r28566 r28583 571 571 $this->assertEquals( 0, $count ); 572 572 } 573 574 function test_wp_get_object_terms_no_dupes() { 575 $post_id1 = $this->factory->post->create(); 576 $post_id2 = $this->factory->post->create(); 577 $cat_id = $this->factory->category->create(); 578 $cat_id2 = $this->factory->category->create(); 579 wp_set_post_categories( $post_id1, array( $cat_id, $cat_id2 ) ); 580 wp_set_post_categories( $post_id2, $cat_id ); 581 582 $terms = wp_get_object_terms( array( $post_id1, $post_id2 ), 'category' ); 583 $this->assertCount( 2, $terms ); 584 $this->assertEquals( array( $cat_id, $cat_id2 ), wp_list_pluck( $terms, 'term_id' ) ); 585 586 $terms2 = wp_get_object_terms( array( $post_id1, $post_id2 ), 'category', array( 587 'fields' => 'all_with_object_id' 588 ) ); 589 590 $this->assertCount( 3, $terms2 ); 591 $this->assertEquals( array( $cat_id, $cat_id, $cat_id2 ), wp_list_pluck( $terms2, 'term_id' ) ); 592 } 573 593 }
Note: See TracChangeset
for help on using the changeset viewer.