After [29339] and [29341], add more unit tests and less ambiguous type-checking before bailing in meta-related functions that expect a numeric value for $object_id.

Props SergeyBiryukov.
Fixes #28315.


git-svn-id: https://develop.svn.wordpress.org/trunk@29421 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2014-08-06 22:07:42 +00:00
parent 5f2fa44dee
commit e9ba499f23
2 changed files with 99 additions and 41 deletions
+20
View File
@@ -236,4 +236,24 @@ class Tests_Meta extends WP_UnitTestCase {
$this->assertEquals( wp_list_pluck( $posts, 'post_title' ), wp_list_pluck( $posts2, 'post_title' ) );
}
/**
* @ticket 28315
*/
function test_non_numeric_object_id() {
$this->assertFalse( add_metadata( 'user', array( 1 ), 'meta_key', 'meta_value' ) );
$this->assertFalse( update_metadata( 'user', array( 1 ), 'meta_key', 'meta_new_value' ) );
$this->assertFalse( delete_metadata( 'user', array( 1 ), 'meta_key' ) );
$this->assertFalse( get_metadata( 'user', array( 1 ) ) );
$this->assertFalse( metadata_exists( 'user', array( 1 ), 'meta_key' ) );
}
/**
* @ticket 28315
*/
function test_non_numeric_meta_id() {
$this->assertFalse( get_metadata_by_mid( 'user', array( 1 ) ) );
$this->assertFalse( update_metadata_by_mid( 'user', array( 1 ), 'meta_new_value' ) );
$this->assertFalse( delete_metadata_by_mid( 'user', array( 1 ) ) );
}
}