Skip to content

Commit 6a3df0e

Browse files
committed
Tests: Cover equivalent post-meta return values.
Check that `update_post_meta()` returns `false` when stored numeric strings are updated with equivalent integer or boolean values. Developed in: #8780 Props vishalkakadiya, mukesh27. See #59361. git-svn-id: https://develop.svn.wordpress.org/trunk@65145 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 9049f6c commit 6a3df0e

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎tests/phpunit/tests/post/meta.php‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,22 @@ public function test_update_post_meta() {
134134
$this->assertSame( array( 'new' ), get_post_meta( self::$post_id, 'unique_update', false ) );
135135
$this->assertSame( 'new', get_post_meta( self::$post_id, 'nonunique_update', true ) );
136136
$this->assertSame( array( 'new', 'another new' ), get_post_meta( self::$post_id, 'nonunique_update', false ) );
137+
138+
// Checks "1" == 1 == true
139+
$this->assertIsInt( add_post_meta( self::$post_id, 'unique_type_true', '1' ) );
140+
// Checking asserting false to confirm that the post meta is not updating unnecessary as "1" and 1 is same in meta_value.
141+
$this->assertFalse( update_post_meta( self::$post_id, 'unique_type_true', 1 ) );
142+
$this->assertFalse( update_post_meta( self::$post_id, 'unique_type_true', true ) );
143+
144+
// Check "21" == 21
145+
$this->assertIsInt( add_post_meta( self::$post_id, 'unique_type_integer', '21' ) );
146+
// Checking asserting false to confirm that the post meta is not updating unnecessary as "21" and 21 is same in meta_value.
147+
$this->assertFalse( update_post_meta( self::$post_id, 'unique_type_integer', 21 ) );
148+
149+
// Check "0" == 0
150+
$this->assertIsInt( add_post_meta( self::$post_id, 'unique_type_false', '0' ) );
151+
// Checking asserting false to confirm that the post meta is not updating unnecessary as "0" and 0 is same in meta_value.
152+
$this->assertFalse( update_post_meta( self::$post_id, 'unique_type_false', 0 ) );
137153
}
138154

139155
public function test_delete_post_meta() {

0 commit comments

Comments
 (0)