Changeset 47122 for trunk/tests/phpunit/tests/meta.php
- Timestamp:
- 01/29/2020 12:43:23 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/meta.php
r46586 r47122 28 28 29 29 function test_delete_metadata_by_mid() { 30 // Let's try and delete a non-existing ID, non existing meta 30 // Let's try and delete a non-existing ID, non existing meta. 31 31 $this->assertFalse( delete_metadata_by_mid( 'user', 0 ) ); 32 32 $this->assertFalse( delete_metadata_by_mid( 'non_existing_meta', $this->delete_meta_id ) ); 33 33 34 // Now let's delete the real meta data 34 // Now let's delete the real meta data. 35 35 $this->assertTrue( delete_metadata_by_mid( 'user', $this->delete_meta_id ) ); 36 36 37 // And make sure it's been deleted 37 // And make sure it's been deleted. 38 38 $this->assertFalse( get_metadata_by_mid( 'user', $this->delete_meta_id ) ); 39 39 40 // Make sure the caches are cleared 40 // Make sure the caches are cleared. 41 41 $this->assertFalse( (bool) get_user_meta( $this->author->ID, 'delete_meta_key' ) ); 42 42 } 43 43 44 44 function test_update_metadata_by_mid() { 45 // Setup 45 // Setup. 46 46 $meta = get_metadata_by_mid( 'user', $this->meta_id ); 47 47 48 // Update the meta value 48 // Update the meta value. 49 49 $this->assertTrue( update_metadata_by_mid( 'user', $this->meta_id, 'meta_new_value' ) ); 50 50 $meta = get_metadata_by_mid( 'user', $this->meta_id ); 51 51 $this->assertEquals( 'meta_new_value', $meta->meta_value ); 52 52 53 // Update the meta value 53 // Update the meta value. 54 54 $this->assertTrue( update_metadata_by_mid( 'user', $this->meta_id, 'meta_new_value', 'meta_new_key' ) ); 55 55 $meta = get_metadata_by_mid( 'user', $this->meta_id ); 56 56 $this->assertEquals( 'meta_new_key', $meta->meta_key ); 57 57 58 // Update the key and value 58 // Update the key and value. 59 59 $this->assertTrue( update_metadata_by_mid( 'user', $this->meta_id, 'meta_value', 'meta_key' ) ); 60 60 $meta = get_metadata_by_mid( 'user', $this->meta_id ); … … 62 62 $this->assertEquals( 'meta_value', $meta->meta_value ); 63 63 64 // Update the value that has to be serialized 64 // Update the value that has to be serialized. 65 65 $this->assertTrue( update_metadata_by_mid( 'user', $this->meta_id, array( 'first', 'second' ) ) ); 66 66 $meta = get_metadata_by_mid( 'user', $this->meta_id ); 67 67 $this->assertEquals( array( 'first', 'second' ), $meta->meta_value ); 68 68 69 // Let's try some invalid meta data 69 // Let's try some invalid meta data. 70 70 $this->assertFalse( update_metadata_by_mid( 'user', 0, 'meta_value' ) ); 71 71 $this->assertFalse( update_metadata_by_mid( 'user', $this->meta_id, 'meta_value', array( 'invalid', 'key' ) ) ); … … 118 118 // Let's see if it returns the correct value when adding a filter. 119 119 add_filter( 'get_user_metadata', '__return_zero' ); 120 $this->assertFalse( metadata_exists( 'user', $this->author->ID, 'meta_key' ) ); // existing meta key120 $this->assertFalse( metadata_exists( 'user', $this->author->ID, 'meta_key' ) ); // Existing meta key. 121 121 $this->assertFalse( metadata_exists( 'user', 1234567890, 'meta_key' ) ); 122 122 remove_filter( 'get_user_metadata', '__return_zero' ); … … 140 140 $this->assertEquals( 1, count( $u ) ); 141 141 142 // User found is not locally defined author (it's the admin) 142 // User found is not locally defined author (it's the admin). 143 143 $this->assertNotEquals( $this->author->user_login, $u[0]->user_login ); 144 144 145 // Test EXISTS and NOT EXISTS together, no users should be found 145 // Test EXISTS and NOT EXISTS together, no users should be found. 146 146 $this->assertEquals( 147 147 0, … … 220 220 $this->assertFalse( metadata_exists( 'user', $this->author->ID, $key ) ); 221 221 222 // Test overslashing 222 // Test overslashing. 223 223 $this->assertInternalType( 'int', add_metadata( 'user', $this->author->ID, $key, $value2 ) ); 224 224 $this->assertEquals( $expected2, get_metadata( 'user', $this->author->ID, $key, true ) ); … … 256 256 $this->assertEquals( 2, substr_count( $posts->request, 'CAST(' ) ); 257 257 258 // Make sure the newer meta_query syntax behaves in a consistent way 258 // Make sure the newer meta_query syntax behaves in a consistent way. 259 259 $posts = new WP_Query( 260 260 array(
Note: See TracChangeset
for help on using the changeset viewer.