3.7 regression from [25119]: Have in_category() return false when the first argument is empty.

Adds unit tests.

props ericlewis.
fixes #25706 for trunk.


git-svn-id: https://develop.svn.wordpress.org/trunk@25923 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin
2013-10-26 02:53:30 +00:00
parent 99a4f77ea7
commit 559dc21202
2 changed files with 19 additions and 0 deletions
+16
View File
@@ -152,4 +152,20 @@ class Tests_Taxonomy extends WP_UnitTestCase {
_unregister_post_type( $post_type );
}
/**
* @ticket 25706
*/
function test_in_category() {
$post = $this->factory->post->create_and_get();
// in_category() returns false when first parameter is empty()
$this->assertFalse( in_category( '', $post ) );
$this->assertFalse( in_category( false, $post ) );
$this->assertFalse( in_category( null, $post ) );
// Test expected behavior of in_category()
$term = wp_insert_term( 'Test', 'category' );
wp_set_object_terms( $post->ID, $term['term_id'], 'category' );
$this->assertTrue( in_category( $term['term_id'], $post ) );
}
}