Make WordPress Core

Changeset 26187


Ignore:
Timestamp:
11/15/2013 02:32:16 AM (12 years ago)
Author:
wonderboymusic
Message:

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.

Location:
trunk/tests/phpunit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/utils.php

    r26006 r26187  
    383383    }
    384384}
     385
     386function _clean_term_filters() {
     387    remove_filter( 'get_terms',     array( 'Featured_Content', 'hide_featured_term'     ), 10, 2 );
     388    remove_filter( 'get_the_terms', array( 'Featured_Content', 'hide_the_featured_term' ), 10, 3 );
     389}
  • trunk/tests/phpunit/tests/term.php

    r26028 r26187  
    99    function setUp() {
    1010        parent::setUp();
     11       
     12        _clean_term_filters();
    1113        // insert one term into every post taxonomy
    1214        // otherwise term_ids and term_taxonomy_ids might be identical, which could mask bugs
     
    442444        wp_set_object_terms( $post_id, $term, $this->taxonomy );
    443445
    444         $term = array_shift( wp_get_object_terms( $post_id, $this->taxonomy, array( 'fields' => 'all_with_object_id' ) ) );
     446        $terms = wp_get_object_terms( $post_id, $this->taxonomy, array( 'fields' => 'all_with_object_id' ) );
     447        $term = array_shift( $terms );
    445448        $int_fields = array( 'parent', 'term_id', 'count', 'term_group', 'term_taxonomy_id', 'object_id' );
    446449        foreach ( $int_fields as $field )
    447450            $this->assertInternalType( 'int', $term->$field, $field );
    448451
    449         $term = array_shift( wp_get_object_terms( $post_id, $this->taxonomy, array( 'fields' => 'ids' ) ) );
     452        $terms = wp_get_object_terms( $post_id, $this->taxonomy, array( 'fields' => 'ids' ) );
     453        $term = array_shift( $terms );
    450454        $this->assertInternalType( 'int', $term, 'term' );
    451455    }
  • trunk/tests/phpunit/tests/term/getTerms.php

    r25933 r26187  
    77    function setUp() {
    88        parent::setUp();
    9 
     9       
     10        _clean_term_filters();
    1011        wp_cache_delete( 'last_changed', 'terms' );
    1112    }
     
    2930        $terms = get_terms( 'post_tag' );
    3031        $this->assertEquals( 15, count( $terms ) );
    31         $this->assertNotEmpty( $time1 = wp_cache_get( 'last_changed', 'terms' ) );
     32        $time1 = wp_cache_get( 'last_changed', 'terms' );
     33        $this->assertNotEmpty( $time1 );
    3234        $this->assertEquals( $num_queries + 1, $wpdb->num_queries );
    3335
Note: See TracChangeset for help on using the changeset viewer.