Changeset 43314 for branches/4.9/tests/phpunit/tests/term/query.php
- Timestamp:
- 05/25/2018 01:25:55 AM (6 years ago)
- Location:
- branches/4.9
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.9
-
branches/4.9/tests/phpunit/tests/term/query.php
r41880 r43314 288 288 foreach ( $query->terms as $term ) { 289 289 $this->assertSame( $t, $term->term_id ); 290 } 291 } 292 293 /** 294 * @ticket 44221 295 */ 296 public function test_all_with_object_id_should_return_term_objects() { 297 register_taxonomy( 'wptests_tax_1', 'post' ); 298 $posts = self::factory()->post->create_many( 2 ); 299 $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax_1' ) ); 300 301 foreach ( $posts as $p ) { 302 wp_set_object_terms( $p, array( $t ), 'wptests_tax_1' ); 303 } 304 305 $query = new WP_Term_Query(); 306 $args = array( 307 'taxonomy' => 'wptests_tax_1', 308 'object_ids' => $posts, 309 'fields' => 'all_with_object_id', 310 ); 311 312 $terms = $query->query( $args ); 313 $this->assertNotEmpty( $terms ); 314 foreach ( $terms as $term ) { 315 $this->assertInstanceOf( 'WP_Term', $term ); 316 $this->assertObjectHasAttribute( 'object_id', $term ); 317 } 318 319 // Run again to check the cached response. 320 $terms = $query->query( $args ); 321 $this->assertNotEmpty( $terms ); 322 foreach ( $terms as $term ) { 323 $this->assertInstanceOf( 'WP_Term', $term ); 324 $this->assertObjectHasAttribute( 'object_id', $term ); 290 325 } 291 326 }
Note: See TracChangeset
for help on using the changeset viewer.