Remove the Featured Content term filters when running Unit Tests. Set the return value of `wp_get_object_terms()` to a var before passing to `array_shift()` in `test_get_object_terms_types()`, which expects a var to be passed by reference.

See #25282.



git-svn-id: https://develop.svn.wordpress.org/trunk@26187 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2013-11-15 02:32:16 +00:00
parent 8c01596a75
commit 5de39fc2f1
3 changed files with 15 additions and 4 deletions

View File

@ -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 );
}

View File

@ -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' );
}

View File

@ -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;