diff --git a/tests/phpunit/includes/utils.php b/tests/phpunit/includes/utils.php index dc2fde4d1d..f39d7eecff 100644 --- a/tests/phpunit/includes/utils.php +++ b/tests/phpunit/includes/utils.php @@ -381,4 +381,9 @@ function _cleanup_query_vars() { if ( ! empty( $t->query_var ) ) $GLOBALS['wp']->add_query_var( $t->query_var ); } +} + +function _clean_term_filters() { + remove_filter( 'get_terms', array( 'Featured_Content', 'hide_featured_term' ), 10, 2 ); + remove_filter( 'get_the_terms', array( 'Featured_Content', 'hide_the_featured_term' ), 10, 3 ); } \ No newline at end of file diff --git a/tests/phpunit/tests/term.php b/tests/phpunit/tests/term.php index a2eb148b30..2a990d62be 100644 --- a/tests/phpunit/tests/term.php +++ b/tests/phpunit/tests/term.php @@ -8,6 +8,8 @@ class Tests_Term extends WP_UnitTestCase { function setUp() { parent::setUp(); + + _clean_term_filters(); // insert one term into every post taxonomy // otherwise term_ids and term_taxonomy_ids might be identical, which could mask bugs $term = rand_str(); @@ -441,12 +443,14 @@ class Tests_Term extends WP_UnitTestCase { $term = wp_insert_term( 'one', $this->taxonomy ); wp_set_object_terms( $post_id, $term, $this->taxonomy ); - $term = array_shift( wp_get_object_terms( $post_id, $this->taxonomy, array( 'fields' => 'all_with_object_id' ) ) ); + $terms = wp_get_object_terms( $post_id, $this->taxonomy, array( 'fields' => 'all_with_object_id' ) ); + $term = array_shift( $terms ); $int_fields = array( 'parent', 'term_id', 'count', 'term_group', 'term_taxonomy_id', 'object_id' ); foreach ( $int_fields as $field ) $this->assertInternalType( 'int', $term->$field, $field ); - $term = array_shift( wp_get_object_terms( $post_id, $this->taxonomy, array( 'fields' => 'ids' ) ) ); + $terms = wp_get_object_terms( $post_id, $this->taxonomy, array( 'fields' => 'ids' ) ); + $term = array_shift( $terms ); $this->assertInternalType( 'int', $term, 'term' ); } diff --git a/tests/phpunit/tests/term/getTerms.php b/tests/phpunit/tests/term/getTerms.php index 7709e8d17e..0db732bf0a 100644 --- a/tests/phpunit/tests/term/getTerms.php +++ b/tests/phpunit/tests/term/getTerms.php @@ -6,7 +6,8 @@ class Tests_Term_getTerms extends WP_UnitTestCase { function setUp() { parent::setUp(); - + + _clean_term_filters(); wp_cache_delete( 'last_changed', 'terms' ); } @@ -28,7 +29,8 @@ class Tests_Term_getTerms extends WP_UnitTestCase { // last_changed and num_queries should bump $terms = get_terms( 'post_tag' ); $this->assertEquals( 15, count( $terms ) ); - $this->assertNotEmpty( $time1 = wp_cache_get( 'last_changed', 'terms' ) ); + $time1 = wp_cache_get( 'last_changed', 'terms' ); + $this->assertNotEmpty( $time1 ); $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); $num_queries = $wpdb->num_queries;