Changeset 43313 for trunk/tests/phpunit/tests/term/query.php
- Timestamp:
- 05/25/2018 01:22:44 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term/query.php
r43049 r43313 316 316 foreach ( $query->terms as $term ) { 317 317 $this->assertSame( $t, $term->term_id ); 318 } 319 } 320 321 /** 322 * @ticket 44221 323 */ 324 public function test_all_with_object_id_should_return_term_objects() { 325 register_taxonomy( 'wptests_tax_1', 'post' ); 326 $posts = self::factory()->post->create_many( 2 ); 327 $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax_1' ) ); 328 329 foreach ( $posts as $p ) { 330 wp_set_object_terms( $p, array( $t ), 'wptests_tax_1' ); 331 } 332 333 $query = new WP_Term_Query(); 334 $args = array( 335 'taxonomy' => 'wptests_tax_1', 336 'object_ids' => $posts, 337 'fields' => 'all_with_object_id', 338 ); 339 340 $terms = $query->query( $args ); 341 $this->assertNotEmpty( $terms ); 342 foreach ( $terms as $term ) { 343 $this->assertInstanceOf( 'WP_Term', $term ); 344 $this->assertObjectHasAttribute( 'object_id', $term ); 345 } 346 347 // Run again to check the cached response. 348 $terms = $query->query( $args ); 349 $this->assertNotEmpty( $terms ); 350 foreach ( $terms as $term ) { 351 $this->assertInstanceOf( 'WP_Term', $term ); 352 $this->assertObjectHasAttribute( 'object_id', $term ); 318 353 } 319 354 }
Note: See TracChangeset
for help on using the changeset viewer.