Make WordPress Core


Ignore:
Timestamp:
09/05/2013 05:14:54 PM (13 years ago)
Author:
wonderboymusic
Message:

Avoid database error when include or exclude is not really a term_id. Adds more unit tests.

Props kovshenin.
Fixes #11823.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/term/getTerms.php

    r25241 r25257  
    122122
    123123        /**
    124          * @ti
    125          * cket 11823
     124         * @ticket 11823
    126125         */
    127126        function test_get_terms_include_exclude() {
     127                global $wpdb;
     128
    128129                $term_id1 = $this->factory->tag->create();
    129130                $term_id2 = $this->factory->tag->create();
    … …  
    139140                ) );
    140141                $this->assertEquals( array(), wp_list_pluck( $exc_terms, 'term_id' ) );
     142
     143                // These should not generate query errors.
     144                get_terms( 'post_tag', array( 'exclude' => array( 0 ), 'hide_empty' => false ) );
     145                $this->assertEmpty( $wpdb->last_error );
     146
     147                get_terms( 'post_tag', array( 'exclude' => array( 'unexpected-string' ), 'hide_empty' => false ) );
     148                $this->assertEmpty( $wpdb->last_error );
     149
     150                get_terms( 'post_tag', array( 'include' => array( 'unexpected-string' ), 'hide_empty' => false ) );
     151                $this->assertEmpty( $wpdb->last_error );
    141152        }
    142153
Note: See TracChangeset for help on using the changeset viewer.