Changeset 48937 for trunk/tests/phpunit/tests/meta.php
- Timestamp:
- 09/02/2020 12:35:36 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/meta.php
r47122 r48937 20 20 function test_sanitize_meta() { 21 21 $meta = sanitize_meta( 'some_meta', 'unsanitized', 'post' ); 22 $this->assert Equals( 'unsanitized', $meta );22 $this->assertSame( 'unsanitized', $meta ); 23 23 24 24 register_meta( 'post', 'some_meta', array( $this, '_meta_sanitize_cb' ) ); 25 25 $meta = sanitize_meta( 'some_meta', 'unsanitized', 'post' ); 26 $this->assert Equals( 'sanitized', $meta );26 $this->assertSame( 'sanitized', $meta ); 27 27 } 28 28 … … 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 $this->assert Equals( 'meta_new_value', $meta->meta_value );51 $this->assertSame( 'meta_new_value', $meta->meta_value ); 52 52 53 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 $this->assert Equals( 'meta_new_key', $meta->meta_key );56 $this->assertSame( 'meta_new_key', $meta->meta_key ); 57 57 58 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 ); 61 $this->assert Equals( 'meta_key', $meta->meta_key );62 $this->assert Equals( 'meta_value', $meta->meta_value );61 $this->assertSame( 'meta_key', $meta->meta_key ); 62 $this->assertSame( 'meta_value', $meta->meta_value ); 63 63 64 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 $this->assert Equals( array( 'first', 'second' ), $meta->meta_value );67 $this->assertSame( array( 'first', 'second' ), $meta->meta_value ); 68 68 69 69 // Let's try some invalid meta data. … … 138 138 ); 139 139 140 $this->assert Equals( 1, count( $u ) );140 $this->assertSame( 1, count( $u ) ); 141 141 142 142 // User found is not locally defined author (it's the admin). … … 144 144 145 145 // Test EXISTS and NOT EXISTS together, no users should be found. 146 $this->assert Equals(146 $this->assertSame( 147 147 0, 148 148 count( … … 164 164 ); 165 165 166 $this->assert Equals(166 $this->assertSame( 167 167 2, 168 168 count( … … 182 182 delete_metadata( 'user', $this->author->ID, 'meta_key' ); 183 183 184 $this->assert Equals(184 $this->assertSame( 185 185 2, 186 186 count( … … 209 209 $this->assertSame( '', get_metadata( 'user', $this->author->ID, $key, true ) ); 210 210 $this->assertInternalType( 'int', add_metadata( 'user', $this->author->ID, $key, $value ) ); 211 $this->assert Equals( $expected, get_metadata( 'user', $this->author->ID, $key, true ) );211 $this->assertSame( $expected, get_metadata( 'user', $this->author->ID, $key, true ) ); 212 212 $this->assertTrue( delete_metadata( 'user', $this->author->ID, $key ) ); 213 213 $this->assertSame( '', get_metadata( 'user', $this->author->ID, $key, true ) ); 214 214 $this->assertInternalType( 'int', update_metadata( 'user', $this->author->ID, $key, $value ) ); 215 $this->assert Equals( $expected, get_metadata( 'user', $this->author->ID, $key, true ) );215 $this->assertSame( $expected, get_metadata( 'user', $this->author->ID, $key, true ) ); 216 216 $this->assertTrue( update_metadata( 'user', $this->author->ID, $key, 'blah' ) ); 217 $this->assert Equals( 'blah', get_metadata( 'user', $this->author->ID, $key, true ) );217 $this->assertSame( 'blah', get_metadata( 'user', $this->author->ID, $key, true ) ); 218 218 $this->assertTrue( delete_metadata( 'user', $this->author->ID, $key ) ); 219 219 $this->assertSame( '', get_metadata( 'user', $this->author->ID, $key, true ) ); … … 222 222 // Test overslashing. 223 223 $this->assertInternalType( 'int', add_metadata( 'user', $this->author->ID, $key, $value2 ) ); 224 $this->assert Equals( $expected2, get_metadata( 'user', $this->author->ID, $key, true ) );224 $this->assertSame( $expected2, get_metadata( 'user', $this->author->ID, $key, true ) ); 225 225 $this->assertTrue( delete_metadata( 'user', $this->author->ID, $key ) ); 226 226 $this->assertSame( '', get_metadata( 'user', $this->author->ID, $key, true ) ); 227 227 $this->assertInternalType( 'int', update_metadata( 'user', $this->author->ID, $key, $value2 ) ); 228 $this->assert Equals( $expected2, get_metadata( 'user', $this->author->ID, $key, true ) );228 $this->assertSame( $expected2, get_metadata( 'user', $this->author->ID, $key, true ) ); 229 229 } 230 230 … … 253 253 ); 254 254 255 $this->assert Equals( array( $post_id2, $post_id1 ), $posts->posts );256 $this->assert Equals( 2, substr_count( $posts->request, 'CAST(' ) );255 $this->assertSame( array( $post_id2, $post_id1 ), $posts->posts ); 256 $this->assertSame( 2, substr_count( $posts->request, 'CAST(' ) ); 257 257 258 258 // Make sure the newer meta_query syntax behaves in a consistent way. … … 274 274 ); 275 275 276 $this->assert Equals( array( $post_id2, $post_id1 ), $posts->posts );277 $this->assert Equals( 2, substr_count( $posts->request, 'CAST(' ) );276 $this->assertSame( array( $post_id2, $post_id1 ), $posts->posts ); 277 $this->assertSame( 2, substr_count( $posts->request, 'CAST(' ) ); 278 278 279 279 // The legacy `meta_key` value should take precedence. … … 298 298 ); 299 299 300 $this->assert Equals( array( $post_id2, $post_id1 ), $posts->posts );301 $this->assert Equals( 2, substr_count( $posts->request, 'CAST(' ) );300 $this->assertSame( array( $post_id2, $post_id1 ), $posts->posts ); 301 $this->assertSame( 2, substr_count( $posts->request, 'CAST(' ) ); 302 302 } 303 303 … … 311 311 foreach ( range( 1, 10 ) as $i ) { 312 312 $meta = get_post_meta( $post_id, 'color' ); 313 $this->assert Equals( $meta, $colors );313 $this->assertSame( $meta, $colors ); 314 314 315 315 if ( 0 === $i % 2 ) { … … 400 400 $found = get_metadata( 'user', $this->author->ID ); 401 401 402 $this->assert Equals( array( $value ), $found['foo'] );402 $this->assertSame( array( $value ), $found['foo'] ); 403 403 } 404 404
Note: See TracChangeset
for help on using the changeset viewer.