- Timestamp:
- 09/02/2020 12:35:36 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-term-meta-fields.php
r48402 r48937 215 215 $response = rest_get_server()->dispatch( $request ); 216 216 217 $this->assert Equals( 200, $response->get_status() );217 $this->assertSame( 200, $response->get_status() ); 218 218 219 219 $data = $response->get_data(); … … 222 222 $meta = (array) $data['meta']; 223 223 $this->assertArrayHasKey( 'test_single', $meta ); 224 $this->assert Equals( 'testvalue', $meta['test_single'] );224 $this->assertSame( 'testvalue', $meta['test_single'] ); 225 225 } 226 226 … … 233 233 234 234 $response = rest_get_server()->dispatch( $request ); 235 $this->assert Equals( 200, $response->get_status() );235 $this->assertSame( 200, $response->get_status() ); 236 236 237 237 $data = $response->get_data(); … … 245 245 246 246 $response = rest_get_server()->dispatch( $request ); 247 $this->assert Equals( 200, $response->get_status() );247 $this->assertSame( 200, $response->get_status() ); 248 248 $data = $response->get_data(); 249 249 $meta = (array) $data['meta']; … … 260 260 261 261 $response = rest_get_server()->dispatch( $request ); 262 $this->assert Equals( 200, $response->get_status() );262 $this->assertSame( 200, $response->get_status() ); 263 263 264 264 $data = $response->get_data(); … … 275 275 276 276 $response = rest_get_server()->dispatch( $request ); 277 $this->assert Equals( 200, $response->get_status() );277 $this->assertSame( 200, $response->get_status() ); 278 278 279 279 $data = $response->get_data(); … … 290 290 291 291 $response = rest_get_server()->dispatch( $request ); 292 $this->assert Equals( 200, $response->get_status() );292 $this->assertSame( 200, $response->get_status() ); 293 293 294 294 $data = $response->get_data(); … … 337 337 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/categories/%d', self::$category_id ) ); 338 338 $response = rest_get_server()->dispatch( $request ); 339 $this->assert Equals( 200, $response->get_status() );339 $this->assertSame( 200, $response->get_status() ); 340 340 341 341 $data = $response->get_data(); … … 352 352 $this->assertArrayHasKey( 'test_bool', $meta ); 353 353 $this->assertInternalType( 'boolean', $meta['test_bool'] ); 354 $this->assert Same( true,$meta['test_bool'] );354 $this->assertTrue( $meta['test_bool'] ); 355 355 } 356 356 … … 361 361 $response = rest_get_server()->dispatch( $request ); 362 362 363 $this->assert Equals( 200, $response->get_status() );363 $this->assertSame( 200, $response->get_status() ); 364 364 365 365 $data = $response->get_data(); … … 368 368 $meta = (array) $data['meta']; 369 369 $this->assertArrayHasKey( 'new_name', $meta ); 370 $this->assert Equals( 'janet', $meta['new_name'] );370 $this->assertSame( 'janet', $meta['new_name'] ); 371 371 } 372 372 … … 390 390 391 391 $response = rest_get_server()->dispatch( $request ); 392 $this->assert Equals( 200, $response->get_status() );392 $this->assertSame( 200, $response->get_status() ); 393 393 394 394 $meta = get_term_meta( self::$category_id, 'test_single', false ); 395 395 $this->assertNotEmpty( $meta ); 396 396 $this->assertCount( 1, $meta ); 397 $this->assert Equals( 'test_value', $meta[0] );397 $this->assertSame( 'test_value', $meta[0] ); 398 398 399 399 $data = $response->get_data(); 400 400 $meta = (array) $data['meta']; 401 401 $this->assertArrayHasKey( 'test_single', $meta ); 402 $this->assert Equals( 'test_value', $meta['test_single'] );402 $this->assertSame( 'test_value', $meta['test_single'] ); 403 403 } 404 404 … … 409 409 // Start with an existing metakey and value. 410 410 $values = update_term_meta( self::$category_id, 'test_single', 'test_value' ); 411 $this->assert Equals( 'test_value', get_term_meta( self::$category_id, 'test_single', true ) );411 $this->assertSame( 'test_value', get_term_meta( self::$category_id, 'test_single', true ) ); 412 412 413 413 $this->grant_write_permission(); … … 422 422 423 423 $response = rest_get_server()->dispatch( $request ); 424 $this->assert Equals( 200, $response->get_status() );424 $this->assertSame( 200, $response->get_status() ); 425 425 426 426 $meta = get_term_meta( self::$category_id, 'test_single', true ); 427 427 $this->assertNotEmpty( $meta ); 428 $this->assert Equals( 'test_value', $meta );428 $this->assertSame( 'test_value', $meta ); 429 429 430 430 $data = $response->get_data(); 431 431 $meta = (array) $data['meta']; 432 432 $this->assertArrayHasKey( 'test_single', $meta ); 433 $this->assert Equals( 'test_value', $meta['test_single'] );433 $this->assertSame( 'test_value', $meta['test_single'] ); 434 434 } 435 435 … … 540 540 541 541 $response = rest_get_server()->dispatch( $request ); 542 $this->assert Equals( 200, $response->get_status() );542 $this->assertSame( 200, $response->get_status() ); 543 543 544 544 $meta = get_term_meta( self::$category_id, 'test_multi', false ); 545 545 $this->assertNotEmpty( $meta ); 546 546 $this->assertCount( 1, $meta ); 547 $this->assert Equals( 'val1', $meta[0] );547 $this->assertSame( 'val1', $meta[0] ); 548 548 549 549 // Add another value. … … 556 556 557 557 $response = rest_get_server()->dispatch( $request ); 558 $this->assert Equals( 200, $response->get_status() );558 $this->assertSame( 200, $response->get_status() ); 559 559 560 560 $meta = get_term_meta( self::$category_id, 'test_multi', false ); … … 584 584 585 585 $response = rest_get_server()->dispatch( $request ); 586 $this->assert Equals( 200, $response->get_status() );586 $this->assertSame( 200, $response->get_status() ); 587 587 588 588 $meta = get_term_meta( self::$category_id, 'test_multi', false ); … … 691 691 $response = rest_get_server()->dispatch( $request ); 692 692 $data = $response->get_data(); 693 $this->assert Equals( 1, $data['meta']['my_meta_key'] );693 $this->assertSame( 1, $data['meta']['my_meta_key'] ); 694 694 } 695 695 … … 717 717 $response = rest_get_server()->dispatch( $request ); 718 718 $data = $response->get_data(); 719 $this->assert Equals( array( 1, 2, 3 ), $data['meta']['my_meta_key'] );719 $this->assertSame( array( 1, 2, 3 ), $data['meta']['my_meta_key'] ); 720 720 } 721 721 … … 789 789 790 790 $response = rest_get_server()->dispatch( $request ); 791 $this->assert Equals( 200, $response->get_status() );791 $this->assertSame( 200, $response->get_status() ); 792 792 793 793 $meta = get_term_meta( self::$category_id, 'test_custom_schema', false ); … … 818 818 819 819 $response = rest_get_server()->dispatch( $request ); 820 $this->assert Equals( 200, $response->get_status() );820 $this->assertSame( 200, $response->get_status() ); 821 821 822 822 $meta = get_term_meta( self::$category_id, 'test_custom_schema_multi', false ); … … 834 834 835 835 $response = rest_get_server()->dispatch( $request ); 836 $this->assert Equals( 200, $response->get_status() );836 $this->assertSame( 200, $response->get_status() ); 837 837 838 838 $meta = get_term_meta( self::$category_id, 'test_custom_schema_multi', false ); … … 862 862 863 863 $response = rest_get_server()->dispatch( $request ); 864 $this->assert Equals( 200, $response->get_status() );864 $this->assertSame( 200, $response->get_status() ); 865 865 866 866 $meta = get_term_meta( self::$category_id, 'test_custom_name', false ); 867 867 $this->assertNotEmpty( $meta ); 868 868 $this->assertCount( 1, $meta ); 869 $this->assert Equals( 'janet', $meta[0] );869 $this->assertSame( 'janet', $meta[0] ); 870 870 871 871 $data = $response->get_data(); 872 872 $meta = (array) $data['meta']; 873 873 $this->assertArrayHasKey( 'new_name', $meta ); 874 $this->assert Equals( 'janet', $meta['new_name'] );874 $this->assertSame( 'janet', $meta['new_name'] ); 875 875 } 876 876 … … 891 891 892 892 $response = rest_get_server()->dispatch( $request ); 893 $this->assert Equals( 200, $response->get_status() );893 $this->assertSame( 200, $response->get_status() ); 894 894 895 895 $meta = get_term_meta( self::$category_id, 'test_custom_name_multi', false ); 896 896 $this->assertNotEmpty( $meta ); 897 897 $this->assertCount( 1, $meta ); 898 $this->assert Equals( 'janet', $meta[0] );898 $this->assertSame( 'janet', $meta[0] ); 899 899 900 900 // Add another value. … … 907 907 908 908 $response = rest_get_server()->dispatch( $request ); 909 $this->assert Equals( 200, $response->get_status() );909 $this->assertSame( 200, $response->get_status() ); 910 910 911 911 $meta = get_term_meta( self::$category_id, 'test_custom_name_multi', false ); … … 939 939 // The meta value should not have changed. 940 940 $current_value = get_term_meta( self::$category_id, 'test_single', true ); 941 $this->assert Equals( 'So I tied an onion to my belt, which was the style at the time.', $current_value );941 $this->assertSame( 'So I tied an onion to my belt, which was the style at the time.', $current_value ); 942 942 943 943 // Ensure the term name update was not processed. 944 944 $term_updated = get_term( self::$category_id ); 945 $this->assert Equals( $term_original->name, $term_updated->name );945 $this->assertSame( $term_original->name, $term_updated->name ); 946 946 } 947 947 … … 968 968 // The meta value should not have changed. 969 969 $current_value = get_term_meta( self::$category_id, 'test_single', true ); 970 $this->assert Equals( 'Now, to take the ferry cost a nickel, and in those days, nickels had pictures of bumblebees on them.', $current_value );970 $this->assertSame( 'Now, to take the ferry cost a nickel, and in those days, nickels had pictures of bumblebees on them.', $current_value ); 971 971 972 972 // Ensure the term name update was not processed. 973 973 $term_updated = get_term( self::$category_id ); 974 $this->assert Equals( $term_original->name, $term_updated->name );974 $this->assertSame( $term_original->name, $term_updated->name ); 975 975 } 976 976 … … 978 978 add_term_meta( self::$category_id, 'test_multi', 'val1' ); 979 979 $values = get_term_meta( self::$category_id, 'test_multi', false ); 980 $this->assert Equals( array( 'val1' ), $values );980 $this->assertSame( array( 'val1' ), $values ); 981 981 982 982 $this->grant_write_permission(); … … 1009 1009 add_term_meta( self::$category_id, 'test_single', 'val1' ); 1010 1010 $current = get_term_meta( self::$category_id, 'test_single', true ); 1011 $this->assert Equals( 'val1', $current );1011 $this->assertSame( 'val1', $current ); 1012 1012 1013 1013 $this->grant_write_permission(); … … 1022 1022 1023 1023 $response = rest_get_server()->dispatch( $request ); 1024 $this->assert Equals( 200, $response->get_status() );1024 $this->assertSame( 200, $response->get_status() ); 1025 1025 1026 1026 $meta = get_term_meta( self::$category_id, 'test_single', false ); … … 1034 1034 add_term_meta( self::$category_id, 'test_bad_auth', 'val1' ); 1035 1035 $current = get_term_meta( self::$category_id, 'test_bad_auth', true ); 1036 $this->assert Equals( 'val1', $current );1036 $this->assertSame( 'val1', $current ); 1037 1037 1038 1038 $this->grant_write_permission(); … … 1050 1050 1051 1051 $meta = get_term_meta( self::$category_id, 'test_bad_auth', true ); 1052 $this->assert Equals( 'val1', $meta );1052 $this->assertSame( 'val1', $meta ); 1053 1053 } 1054 1054 … … 1059 1059 add_term_meta( self::$category_id, 'test_single', 'val1' ); 1060 1060 $current = get_term_meta( self::$category_id, 'test_single', true ); 1061 $this->assert Equals( 'val1', $current );1061 $this->assertSame( 'val1', $current ); 1062 1062 1063 1063 $this->grant_write_permission(); … … 1088 1088 add_term_meta( self::$category_id, 'test_custom_name', 'janet' ); 1089 1089 $current = get_term_meta( self::$category_id, 'test_custom_name', true ); 1090 $this->assert Equals( 'janet', $current );1090 $this->assertSame( 'janet', $current ); 1091 1091 1092 1092 $this->grant_write_permission(); … … 1101 1101 1102 1102 $response = rest_get_server()->dispatch( $request ); 1103 $this->assert Equals( 200, $response->get_status() );1103 $this->assertSame( 200, $response->get_status() ); 1104 1104 1105 1105 $meta = get_term_meta( self::$category_id, 'test_custom_name', false ); … … 1118 1118 1119 1119 $this->assertArrayHasKey( 'test_single', $meta_schema ); 1120 $this->assert Equals( 'string', $meta_schema['test_single']['type'] );1120 $this->assertSame( 'string', $meta_schema['test_single']['type'] ); 1121 1121 1122 1122 $this->assertArrayHasKey( 'test_multi', $meta_schema ); 1123 $this->assert Equals( 'array', $meta_schema['test_multi']['type'] );1123 $this->assertSame( 'array', $meta_schema['test_multi']['type'] ); 1124 1124 $this->assertArrayHasKey( 'items', $meta_schema['test_multi'] ); 1125 $this->assert Equals( 'string', $meta_schema['test_multi']['items']['type'] );1125 $this->assertSame( 'string', $meta_schema['test_multi']['items']['type'] ); 1126 1126 1127 1127 $this->assertArrayHasKey( 'test_custom_schema', $meta_schema ); 1128 $this->assert Equals( 'number', $meta_schema['test_custom_schema']['type'] );1128 $this->assertSame( 'number', $meta_schema['test_custom_schema']['type'] ); 1129 1129 1130 1130 $this->assertArrayNotHasKey( 'test_no_rest', $meta_schema ); … … 1153 1153 $response = rest_get_server()->dispatch( $request ); 1154 1154 1155 $this->assert Equals( 200, $response->get_status() );1155 $this->assertSame( 200, $response->get_status() ); 1156 1156 1157 1157 $data = $response->get_data(); … … 1167 1167 1168 1168 $this->assertArrayHasKey( $meta_key, $data['meta'] ); 1169 $this->assert Equals( $expected_value, $data['meta'][ $meta_key ] );1169 $this->assertSame( $expected_value, $data['meta'][ $meta_key ] ); 1170 1170 } else { 1171 1171 $this->assertArrayNotHasKey( $meta_key, $data['meta'] ); … … 1213 1213 $response = rest_get_server()->dispatch( $request ); 1214 1214 if ( ! $can_write ) { 1215 $this->assert Equals( 403, $response->get_status() );1215 $this->assertSame( 403, $response->get_status() ); 1216 1216 $this->assertEmpty( get_term_meta( $term_id, $meta_key, $single ) ); 1217 1217 return; 1218 1218 } 1219 1219 1220 $this->assert Equals( 200, $response->get_status() );1220 $this->assertSame( 200, $response->get_status() ); 1221 1221 1222 1222 $data = $response->get_data(); … … 1230 1230 } 1231 1231 1232 $this->assert Equals( $expected_value, get_term_meta( $term_id, $meta_key, $single ) );1232 $this->assertSame( $expected_value, get_term_meta( $term_id, $meta_key, $single ) ); 1233 1233 $this->assertArrayHasKey( $meta_key, $data['meta'] ); 1234 $this->assert Equals( $expected_value, $data['meta'][ $meta_key ] );1234 $this->assertSame( $expected_value, $data['meta'][ $meta_key ] ); 1235 1235 } else { 1236 1236 $this->assertEmpty( get_term_meta( $term_id, $meta_key, $single ) ); … … 1276 1276 $response = rest_get_server()->dispatch( $request ); 1277 1277 1278 $this->assert Equals( 200, $response->get_status() );1278 $this->assertSame( 200, $response->get_status() ); 1279 1279 1280 1280 $data = $response->get_data();
Note: See TracChangeset
for help on using the changeset viewer.