| | 321 | public function test_all_with_object_id_should_return_term_objects() { |
| | 322 | register_taxonomy( 'wptests_tax_1', 'post' ); |
| | 323 | $posts = self::factory()->post->create_many( 2 ); |
| | 324 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax_1' ) ); |
| | 325 | |
| | 326 | foreach ( $posts as $p ) { |
| | 327 | wp_set_object_terms( $p, array( $t ), 'wptests_tax_1' ); |
| | 328 | } |
| | 329 | |
| | 330 | $query = new WP_Term_Query(); |
| | 331 | $args = array( |
| | 332 | 'taxonomy' => 'wptests_tax_1', |
| | 333 | 'object_ids' => $posts, |
| | 334 | 'fields' => 'all_with_object_id', |
| | 335 | ); |
| | 336 | |
| | 337 | $terms = $query->query( $args ); |
| | 338 | $this->assertNotEmpty( $terms ); |
| | 339 | foreach ( $terms as $term ) { |
| | 340 | $this->assertInstanceOf( 'WP_Term', $term ); |
| | 341 | } |
| | 342 | |
| | 343 | // Run again to check the cached response. |
| | 344 | $terms = $query->query( $args ); |
| | 345 | $this->assertNotEmpty( $terms ); |
| | 346 | foreach ( $terms as $term ) { |
| | 347 | $this->assertInstanceOf( 'WP_Term', $term ); |
| | 348 | } |
| | 349 | } |
| | 350 | |