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

Props kovshenin.
Fixes #11823.



git-svn-id: https://develop.svn.wordpress.org/trunk@25257 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2013-09-05 17:14:54 +00:00
parent 4286692d7d
commit e8c7634e79
2 changed files with 19 additions and 5 deletions

View File

@@ -121,10 +121,11 @@ class Tests_Term_getTerms extends WP_UnitTestCase {
}
/**
* @ti
* cket 11823
* @ticket 11823
*/
function test_get_terms_include_exclude() {
global $wpdb;
$term_id1 = $this->factory->tag->create();
$term_id2 = $this->factory->tag->create();
$inc_terms = get_terms( 'post_tag', array(
@@ -138,6 +139,16 @@ class Tests_Term_getTerms extends WP_UnitTestCase {
'hide_empty' => false
) );
$this->assertEquals( array(), wp_list_pluck( $exc_terms, 'term_id' ) );
// These should not generate query errors.
get_terms( 'post_tag', array( 'exclude' => array( 0 ), 'hide_empty' => false ) );
$this->assertEmpty( $wpdb->last_error );
get_terms( 'post_tag', array( 'exclude' => array( 'unexpected-string' ), 'hide_empty' => false ) );
$this->assertEmpty( $wpdb->last_error );
get_terms( 'post_tag', array( 'include' => array( 'unexpected-string' ), 'hide_empty' => false ) );
$this->assertEmpty( $wpdb->last_error );
}
/**