/** * @ticket 38295 * @group cache */ public function test_count_query_cache_should_be_invalidated_with_incrementor_bump() { register_taxonomy('wptests_tax_1', 'post'); $terms = self::factory()->term->create_many(2, array('taxonomy' => 'wptests_tax_1')); $query = new WP_Term_Query(array('taxonomy' => 'wptests_tax_1', 'fields' => 'count', 'hide_empty' => false)); $count = $query->get_terms(); $this->assertEquals(2, $count); wp_delete_term($terms[0], 'wptests_tax_1'); $query = new WP_Term_Query(array('taxonomy' => 'wptests_tax_1', 'fields' => 'count', 'hide_empty' => false)); $count = $query->get_terms(); $this->assertEquals(1, $count); }
/** * @ticket 37198 * @group cache */ public function test_object_ids_cache_should_be_invalidated_by_term_relationship_change() { register_taxonomy('wptests_tax_1', 'post'); $p = self::factory()->post->create(); $terms = self::factory()->term->create_many(2, array('taxonomy' => 'wptests_tax_1')); wp_set_object_terms($p, array($terms[0]), 'wptests_tax_1'); $query = new WP_Term_Query(array('taxonomy' => 'wptests_tax_1', 'object_ids' => $p, 'fields' => 'ids')); $found = $query->get_terms(); $this->assertEqualSets(array($terms[0]), $found); wp_set_object_terms($p, array($terms[1]), 'wptests_tax_1'); $query = new WP_Term_Query(array('taxonomy' => 'wptests_tax_1', 'object_ids' => $p, 'fields' => 'ids')); $found = $query->get_terms(); $this->assertEqualSets(array($terms[1]), $found); }
/** * @ticket 23261 * @ticket 37904 */ public function test_orderby_include_with_comma_separated_list() { register_taxonomy('wptests_tax_1', 'post'); $t1 = self::factory()->term->create_and_get(array('taxonomy' => 'wptests_tax_1')); $t2 = self::factory()->term->create_and_get(array('taxonomy' => 'wptests_tax_1')); $query = new WP_Term_Query(array('include' => "{$t1->term_id},{$t2->term_id}", 'orderby' => 'include', 'hide_empty' => false)); $terms = $query->get_terms(); $this->assertEquals(array($t1, $t2), $terms); }