- 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-categories-controller.php
r47122 r48937 118 118 $response = rest_get_server()->dispatch( $request ); 119 119 $data = $response->get_data(); 120 $this->assert Equals( 'view', $data['endpoints'][0]['args']['context']['default'] );120 $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); 121 121 $this->assertEqualSets( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 122 122 // Single. … … 125 125 $response = rest_get_server()->dispatch( $request ); 126 126 $data = $response->get_data(); 127 $this->assert Equals( 'view', $data['endpoints'][0]['args']['context']['default'] );127 $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); 128 128 $this->assertEqualSets( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 129 129 } … … 135 135 $keys = array_keys( $data['endpoints'][0]['args'] ); 136 136 sort( $keys ); 137 $this->assert Equals(137 $this->assertSame( 138 138 array( 139 139 'context', … … 184 184 $response = rest_get_server()->dispatch( $request ); 185 185 $data = $response->get_data(); 186 $this->assert Equals( 2, count( $data ) );187 $this->assert Equals( 'Season 5', $data[0]['name'] );188 $this->assert Equals( 'The Be Sharps', $data[1]['name'] );186 $this->assertSame( 2, count( $data ) ); 187 $this->assertSame( 'Season 5', $data[0]['name'] ); 188 $this->assertSame( 'The Be Sharps', $data[1]['name'] ); 189 189 190 190 // Confirm the empty category "Uncategorized" category appears. … … 192 192 $response = rest_get_server()->dispatch( $request ); 193 193 $data = $response->get_data(); 194 $this->assert Equals( $total_categories, count( $data ) );194 $this->assertSame( $total_categories, count( $data ) ); 195 195 } 196 196 … … 216 216 $response = rest_get_server()->dispatch( $request ); 217 217 218 $this->assert Equals( 200, $response->get_status() );218 $this->assertSame( 200, $response->get_status() ); 219 219 $data = $response->get_data(); 220 220 … … 224 224 ); 225 225 $categories = get_terms( 'category', $args ); 226 $this->assert Equals( count( $categories ), count( $data ) );226 $this->assertSame( count( $categories ), count( $data ) ); 227 227 } 228 228 … … 248 248 $response = rest_get_server()->dispatch( $request ); 249 249 250 $this->assert Equals( 200, $response->get_status() );250 $this->assertSame( 200, $response->get_status() ); 251 251 $data = $response->get_data(); 252 252 … … 256 256 ); 257 257 $categories = get_terms( 'category', $args ); 258 $this->assert Equals( count( $categories ), count( $data ) );258 $this->assertSame( count( $categories ), count( $data ) ); 259 259 } 260 260 … … 266 266 $response = rest_get_server()->dispatch( $request ); 267 267 268 $this->assert Equals( 200, $response->get_status() );269 $data = $response->get_data(); 270 271 $this->assert Equals( array(), $data );268 $this->assertSame( 200, $response->get_status() ); 269 $data = $response->get_data(); 270 271 $this->assertSame( array(), $data ); 272 272 } 273 273 … … 292 292 $response = rest_get_server()->dispatch( $request ); 293 293 $data = $response->get_data(); 294 $this->assert Equals( 2, count( $data ) );295 $this->assert Equals( $id1, $data[0]['id'] );294 $this->assertSame( 2, count( $data ) ); 295 $this->assertSame( $id1, $data[0]['id'] ); 296 296 297 297 // 'orderby' => 'include'. … … 299 299 $response = rest_get_server()->dispatch( $request ); 300 300 $data = $response->get_data(); 301 $this->assert Equals( 2, count( $data ) );302 $this->assert Equals( $id2, $data[0]['id'] );301 $this->assertSame( 2, count( $data ) ); 302 $this->assertSame( $id2, $data[0]['id'] ); 303 303 } 304 304 … … 338 338 $request->set_param( 'per_page', 1 ); 339 339 $response = rest_get_server()->dispatch( $request ); 340 $this->assert Equals( 200, $response->get_status() );341 $data = $response->get_data(); 342 $this->assert Equals( 1, count( $data ) );343 $this->assert Equals( 'Uncategorized', $data[0]['name'] );340 $this->assertSame( 200, $response->get_status() ); 341 $data = $response->get_data(); 342 $this->assertSame( 1, count( $data ) ); 343 $this->assertSame( 'Uncategorized', $data[0]['name'] ); 344 344 345 345 $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); … … 348 348 $request->set_param( 'per_page', 2 ); 349 349 $response = rest_get_server()->dispatch( $request ); 350 $this->assert Equals( 200, $response->get_status() );351 $data = $response->get_data(); 352 $this->assert Equals( 2, count( $data ) );353 $this->assert Equals( 'Apple', $data[0]['name'] );350 $this->assertSame( 200, $response->get_status() ); 351 $data = $response->get_data(); 352 $this->assertSame( 2, count( $data ) ); 353 $this->assertSame( 'Apple', $data[0]['name'] ); 354 354 } 355 355 … … 362 362 $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); 363 363 $response = rest_get_server()->dispatch( $request ); 364 $this->assert Equals( 200, $response->get_status() );365 $data = $response->get_data(); 366 $this->assert Equals( 'Apple', $data[0]['name'] );367 $this->assert Equals( 'Banana', $data[1]['name'] );368 $this->assert Equals( 'Cantaloupe', $data[2]['name'] );364 $this->assertSame( 200, $response->get_status() ); 365 $data = $response->get_data(); 366 $this->assertSame( 'Apple', $data[0]['name'] ); 367 $this->assertSame( 'Banana', $data[1]['name'] ); 368 $this->assertSame( 'Cantaloupe', $data[2]['name'] ); 369 369 370 370 // 'orderby' => 'id', with default 'order' => 'asc'. … … 372 372 $request->set_param( 'orderby', 'id' ); 373 373 $response = rest_get_server()->dispatch( $request ); 374 $this->assert Equals( 200, $response->get_status() );375 $data = $response->get_data(); 376 $this->assert Equals( 'Category 0', $data[1]['name'] );377 $this->assert Equals( 'Category 1', $data[2]['name'] );378 $this->assert Equals( 'Category 2', $data[3]['name'] );374 $this->assertSame( 200, $response->get_status() ); 375 $data = $response->get_data(); 376 $this->assertSame( 'Category 0', $data[1]['name'] ); 377 $this->assertSame( 'Category 1', $data[2]['name'] ); 378 $this->assertSame( 'Category 2', $data[3]['name'] ); 379 379 380 380 // 'orderby' => 'id', 'order' => 'desc'. … … 384 384 $response = rest_get_server()->dispatch( $request ); 385 385 $data = $response->get_data(); 386 $this->assert Equals( 200, $response->get_status() );387 $this->assert Equals( 'Banana', $data[0]['name'] );388 $this->assert Equals( 'Apple', $data[1]['name'] );389 $this->assert Equals( 'Cantaloupe', $data[2]['name'] );386 $this->assertSame( 200, $response->get_status() ); 387 $this->assertSame( 'Banana', $data[0]['name'] ); 388 $this->assertSame( 'Apple', $data[1]['name'] ); 389 $this->assertSame( 'Cantaloupe', $data[2]['name'] ); 390 390 } 391 391 … … 400 400 $response = rest_get_server()->dispatch( $request ); 401 401 $data = $response->get_data(); 402 $this->assert Equals( 200, $response->get_status() );403 $this->assert Equals( 'taco', $data[0]['slug'] );404 $this->assert Equals( 'burrito', $data[1]['slug'] );405 $this->assert Equals( 'chalupa', $data[2]['slug'] );402 $this->assertSame( 200, $response->get_status() ); 403 $this->assertSame( 'taco', $data[0]['slug'] ); 404 $this->assertSame( 'burrito', $data[1]['slug'] ); 405 $this->assertSame( 'chalupa', $data[2]['slug'] ); 406 406 } 407 407 … … 437 437 $request->set_param( 'post', $post_id ); 438 438 $response = rest_get_server()->dispatch( $request ); 439 $this->assert Equals( 200, $response->get_status() );440 441 $data = $response->get_data(); 442 $this->assert Equals( 3, count( $data ) );439 $this->assertSame( 200, $response->get_status() ); 440 441 $data = $response->get_data(); 442 $this->assertSame( 3, count( $data ) ); 443 443 444 444 // Check ordered by name by default. 445 445 $names = wp_list_pluck( $data, 'name' ); 446 $this->assert Equals( array( 'DC', 'Image', 'Marvel' ), $names );446 $this->assertSame( array( 'DC', 'Image', 'Marvel' ), $names ); 447 447 } 448 448 … … 455 455 $request->set_param( 'orderby', 'description' ); 456 456 $response = rest_get_server()->dispatch( $request ); 457 $this->assert Equals( 200, $response->get_status() );458 459 $data = $response->get_data(); 460 $this->assert Equals( 3, count( $data ) );457 $this->assertSame( 200, $response->get_status() ); 458 459 $data = $response->get_data(); 460 $this->assertSame( 3, count( $data ) ); 461 461 $names = wp_list_pluck( $data, 'name' ); 462 $this->assert Equals( array( 'Image', 'Marvel', 'DC' ), $names, 'Terms should be ordered by description' );462 $this->assertSame( array( 'Image', 'Marvel', 'DC' ), $names, 'Terms should be ordered by description' ); 463 463 464 464 // Flip the order. 465 465 $request->set_param( 'order', 'desc' ); 466 466 $response = rest_get_server()->dispatch( $request ); 467 $this->assert Equals( 200, $response->get_status() );468 469 $data = $response->get_data(); 470 $this->assert Equals( 3, count( $data ) );467 $this->assertSame( 200, $response->get_status() ); 468 469 $data = $response->get_data(); 470 $this->assertSame( 3, count( $data ) ); 471 471 $names = wp_list_pluck( $data, 'name' ); 472 $this->assert Equals( array( 'DC', 'Marvel', 'Image' ), $names, 'Terms should be reverse-ordered by description' );472 $this->assertSame( array( 'DC', 'Marvel', 'Image' ), $names, 'Terms should be reverse-ordered by description' ); 473 473 } 474 474 … … 480 480 $request->set_param( 'orderby', 'id' ); 481 481 $response = rest_get_server()->dispatch( $request ); 482 $this->assert Equals( 200, $response->get_status() );483 484 $data = $response->get_data(); 485 $this->assert Equals( 3, count( $data ) );482 $this->assertSame( 200, $response->get_status() ); 483 484 $data = $response->get_data(); 485 $this->assertSame( 3, count( $data ) ); 486 486 $names = wp_list_pluck( $data, 'name' ); 487 $this->assert Equals( array( 'DC', 'Marvel', 'Image' ), $names );487 $this->assertSame( array( 'DC', 'Marvel', 'Image' ), $names ); 488 488 } 489 489 … … 516 516 $request->set_param( 'post', $post_id ); 517 517 $response = rest_get_server()->dispatch( $request ); 518 $this->assert Equals( 200, $response->get_status() );519 520 $data = $response->get_data(); 521 $this->assert Equals( 2, count( $data ) );522 $this->assert Equals( 'Cape', $data[0]['name'] );518 $this->assertSame( 200, $response->get_status() ); 519 520 $data = $response->get_data(); 521 $this->assertSame( 2, count( $data ) ); 522 $this->assertSame( 'Cape', $data[0]['name'] ); 523 523 } 524 524 … … 534 534 $request->set_param( 'search', 'App' ); 535 535 $response = rest_get_server()->dispatch( $request ); 536 $this->assert Equals( 200, $response->get_status() );537 $data = $response->get_data(); 538 $this->assert Equals( 1, count( $data ) );539 $this->assert Equals( 'Apple', $data[0]['name'] );536 $this->assertSame( 200, $response->get_status() ); 537 $data = $response->get_data(); 538 $this->assertSame( 1, count( $data ) ); 539 $this->assertSame( 'Apple', $data[0]['name'] ); 540 540 541 541 $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); 542 542 $request->set_param( 'search', 'Garbage' ); 543 543 $response = rest_get_server()->dispatch( $request ); 544 $this->assert Equals( 200, $response->get_status() );545 $data = $response->get_data(); 546 $this->assert Equals( 0, count( $data ) );544 $this->assertSame( 200, $response->get_status() ); 545 $data = $response->get_data(); 546 $this->assertSame( 0, count( $data ) ); 547 547 } 548 548 … … 554 554 $request->set_param( 'slug', 'apple' ); 555 555 $response = rest_get_server()->dispatch( $request ); 556 $this->assert Equals( 200, $response->get_status() );557 $data = $response->get_data(); 558 $this->assert Equals( 1, count( $data ) );559 $this->assert Equals( 'Apple', $data[0]['name'] );556 $this->assertSame( 200, $response->get_status() ); 557 $data = $response->get_data(); 558 $this->assertSame( 1, count( $data ) ); 559 $this->assertSame( 'Apple', $data[0]['name'] ); 560 560 } 561 561 … … 573 573 $response = rest_get_server()->dispatch( $request ); 574 574 $data = $response->get_data(); 575 $this->assert Equals( 1, count( $data ) );576 $this->assert Equals( 'Child', $data[0]['name'] );575 $this->assertSame( 1, count( $data ) ); 576 $this->assertSame( 'Child', $data[0]['name'] ); 577 577 } 578 578 … … 618 618 $response = rest_get_server()->dispatch( $request ); 619 619 $headers = $response->get_headers(); 620 $this->assert Equals( $total_categories, $headers['X-WP-Total'] );621 $this->assert Equals( $total_pages, $headers['X-WP-TotalPages'] );620 $this->assertSame( $total_categories, $headers['X-WP-Total'] ); 621 $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); 622 622 $this->assertCount( 10, $response->get_data() ); 623 623 $next_link = add_query_arg( … … 638 638 $response = rest_get_server()->dispatch( $request ); 639 639 $headers = $response->get_headers(); 640 $this->assert Equals( $total_categories, $headers['X-WP-Total'] );641 $this->assert Equals( $total_pages, $headers['X-WP-TotalPages'] );640 $this->assertSame( $total_categories, $headers['X-WP-Total'] ); 641 $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); 642 642 $this->assertCount( 10, $response->get_data() ); 643 643 $prev_link = add_query_arg( … … 661 661 $response = rest_get_server()->dispatch( $request ); 662 662 $headers = $response->get_headers(); 663 $this->assert Equals( $total_categories, $headers['X-WP-Total'] );664 $this->assert Equals( $total_pages, $headers['X-WP-TotalPages'] );663 $this->assertSame( $total_categories, $headers['X-WP-Total'] ); 664 $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); 665 665 $this->assertCount( 1, $response->get_data() ); 666 666 $prev_link = add_query_arg( … … 678 678 $response = rest_get_server()->dispatch( $request ); 679 679 $headers = $response->get_headers(); 680 $this->assert Equals( $total_categories, $headers['X-WP-Total'] );681 $this->assert Equals( $total_pages, $headers['X-WP-TotalPages'] );680 $this->assertSame( $total_categories, $headers['X-WP-Total'] ); 681 $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); 682 682 $this->assertCount( 0, $response->get_data() ); 683 683 $prev_link = add_query_arg( … … 698 698 $response = rest_get_server()->dispatch( $request ); 699 699 $headers = $response->get_headers(); 700 $this->assert Equals( self::$total_categories, $headers['X-WP-Total'] );701 $this->assert Equals( 1, $headers['X-WP-TotalPages'] );700 $this->assertSame( self::$total_categories, $headers['X-WP-Total'] ); 701 $this->assertSame( 1, $headers['X-WP-TotalPages'] ); 702 702 $this->assertCount( self::$total_categories, $response->get_data() ); 703 703 … … 707 707 $response = rest_get_server()->dispatch( $request ); 708 708 $headers = $response->get_headers(); 709 $this->assert Equals( self::$total_categories, $headers['X-WP-Total'] );710 $this->assert Equals( 1, $headers['X-WP-TotalPages'] );709 $this->assertSame( self::$total_categories, $headers['X-WP-Total'] ); 710 $this->assertSame( 1, $headers['X-WP-TotalPages'] ); 711 711 $this->assertCount( 0, $response->get_data() ); 712 712 } … … 808 808 $request->set_param( 'slug', 'so-awesome' ); 809 809 $response = rest_get_server()->dispatch( $request ); 810 $this->assert Equals( 201, $response->get_status() );810 $this->assertSame( 201, $response->get_status() ); 811 811 $headers = $response->get_headers(); 812 812 $data = $response->get_data(); 813 813 $this->assertContains( '/wp/v2/categories/' . $data['id'], $headers['Location'] ); 814 $this->assert Equals( 'My Awesome Term', $data['name'] );815 $this->assert Equals( 'This term is so awesome.', $data['description'] );816 $this->assert Equals( 'so-awesome', $data['slug'] );814 $this->assertSame( 'My Awesome Term', $data['name'] ); 815 $this->assertSame( 'This term is so awesome.', $data['description'] ); 816 $this->assertSame( 'so-awesome', $data['slug'] ); 817 817 } 818 818 … … 829 829 830 830 $response = rest_get_server()->dispatch( $request ); 831 $this->assert Equals( 400, $response->get_status() );832 $data = $response->get_data(); 833 $this->assert Equals( 'term_exists', $data['code'] );834 $this->assert Equals( $existing_id, (int) $data['data']['term_id'] );831 $this->assertSame( 400, $response->get_status() ); 832 $data = $response->get_data(); 833 $this->assertSame( 'term_exists', $data['code'] ); 834 $this->assertSame( $existing_id, (int) $data['data']['term_id'] ); 835 835 836 836 wp_delete_term( $existing_id, 'category' ); … … 881 881 $request->set_param( 'parent', $parent['term_id'] ); 882 882 $response = rest_get_server()->dispatch( $request ); 883 $this->assert Equals( 201, $response->get_status() );884 $data = $response->get_data(); 885 $this->assert Equals( $parent['term_id'], $data['parent'] );883 $this->assertSame( 201, $response->get_status() ); 884 $data = $response->get_data(); 885 $this->assertSame( $parent['term_id'], $data['parent'] ); 886 886 } 887 887 … … 907 907 $request->set_param( 'parent', $parent ); 908 908 $response = rest_get_server()->dispatch( $request ); 909 $this->assert Equals( 201, $response->get_status() );910 $data = $response->get_data(); 911 $this->assert Equals( $parent, $data['parent'] );909 $this->assertSame( 201, $response->get_status() ); 910 $data = $response->get_data(); 911 $this->assertSame( $parent, $data['parent'] ); 912 912 } 913 913 … … 936 936 ); 937 937 $response = rest_get_server()->dispatch( $request ); 938 $this->assert Equals( 200, $response->get_status() );939 $data = $response->get_data(); 940 $this->assert Equals( 'New Name', $data['name'] );941 $this->assert Equals( 'New Description', $data['description'] );942 $this->assert Equals( 'new-slug', $data['slug'] );943 $this->assert Equals( 'just meta', $data['meta']['test_single'] );944 $this->assert Equals( 'category-specific meta', $data['meta']['test_cat_single'] );938 $this->assertSame( 200, $response->get_status() ); 939 $data = $response->get_data(); 940 $this->assertSame( 'New Name', $data['name'] ); 941 $this->assertSame( 'New Description', $data['description'] ); 942 $this->assertSame( 'new-slug', $data['slug'] ); 943 $this->assertSame( 'just meta', $data['meta']['test_single'] ); 944 $this->assertSame( 'category-specific meta', $data['meta']['test_cat_single'] ); 945 945 $this->assertFalse( isset( $data['meta']['test_tag_meta'] ) ); 946 946 } … … 984 984 $request->set_param( 'parent', $parent->term_id ); 985 985 $response = rest_get_server()->dispatch( $request ); 986 $this->assert Equals( 200, $response->get_status() );987 988 $data = $response->get_data(); 989 $this->assert Equals( $parent->term_id, $data['parent'] );986 $this->assertSame( 200, $response->get_status() ); 987 988 $data = $response->get_data(); 989 $this->assertSame( $parent->term_id, $data['parent'] ); 990 990 } 991 991 … … 1006 1006 ); 1007 1007 1008 $this->assert Equals( $old_parent_term->term_id, $term->parent );1008 $this->assertSame( $old_parent_term->term_id, $term->parent ); 1009 1009 1010 1010 $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id ); 1011 1011 $request->set_param( 'parent', $new_parent_id ); 1012 1012 $response = rest_get_server()->dispatch( $request ); 1013 $this->assert Equals( 200, $response->get_status() );1014 1015 $data = $response->get_data(); 1016 $this->assert Equals( $new_parent_id, $data['parent'] );1013 $this->assertSame( 200, $response->get_status() ); 1014 1015 $data = $response->get_data(); 1016 $this->assertSame( $new_parent_id, $data['parent'] ); 1017 1017 } 1018 1018 … … 1036 1036 $request->set_param( 'force', true ); 1037 1037 $response = rest_get_server()->dispatch( $request ); 1038 $this->assert Equals( 200, $response->get_status() );1038 $this->assertSame( 200, $response->get_status() ); 1039 1039 $data = $response->get_data(); 1040 1040 $this->assertTrue( $data['deleted'] ); 1041 $this->assert Equals( 'Deleted Category', $data['previous']['name'] );1041 $this->assertSame( 'Deleted Category', $data['previous']['name'] ); 1042 1042 } 1043 1043 … … 1097 1097 $term = get_term( 1, 'category' ); 1098 1098 $response = $endpoint->prepare_item_for_response( $term, $request ); 1099 $this->assert Equals(1099 $this->assertSame( 1100 1100 array( 1101 1101 'id', … … 1120 1120 $this->check_taxonomy_term( $term, $data, $response->get_links() ); 1121 1121 1122 $this->assert Equals( 1, $data['parent'] );1122 $this->assertSame( 1, $data['parent'] ); 1123 1123 1124 1124 $links = $response->get_links(); 1125 $this->assert Equals( rest_url( 'wp/v2/categories/1' ), $links['up'][0]['href'] );1125 $this->assertSame( rest_url( 'wp/v2/categories/1' ), $links['up'][0]['href'] ); 1126 1126 } 1127 1127 … … 1131 1131 $data = $response->get_data(); 1132 1132 $properties = $data['schema']['properties']; 1133 $this->assert Equals( 9, count( $properties ) );1133 $this->assertSame( 9, count( $properties ) ); 1134 1134 $this->assertArrayHasKey( 'id', $properties ); 1135 1135 $this->assertArrayHasKey( 'count', $properties ); … … 1141 1141 $this->assertArrayHasKey( 'slug', $properties ); 1142 1142 $this->assertArrayHasKey( 'taxonomy', $properties ); 1143 $this->assert Equals( array_keys( get_taxonomies() ), $properties['taxonomy']['enum'] );1143 $this->assertSame( array_keys( get_taxonomies() ), $properties['taxonomy']['enum'] ); 1144 1144 } 1145 1145 … … 1167 1167 $data = $response->get_data(); 1168 1168 $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] ); 1169 $this->assert Equals( $schema, $data['schema']['properties']['my_custom_int'] );1169 $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); 1170 1170 1171 1171 $category_id = $this->factory->category->create(); … … 1190 1190 1191 1191 protected function check_get_taxonomy_terms_response( $response ) { 1192 $this->assert Equals( 200, $response->get_status() );1192 $this->assertSame( 200, $response->get_status() ); 1193 1193 $data = $response->get_data(); 1194 1194 $args = array( … … 1196 1196 ); 1197 1197 $categories = get_terms( 'category', $args ); 1198 $this->assert Equals( count( $categories ), count( $data ) );1199 $this->assert Equals( $categories[0]->term_id, $data[0]['id'] );1200 $this->assert Equals( $categories[0]->name, $data[0]['name'] );1201 $this->assert Equals( $categories[0]->slug, $data[0]['slug'] );1202 $this->assert Equals( $categories[0]->taxonomy, $data[0]['taxonomy'] );1203 $this->assert Equals( $categories[0]->description, $data[0]['description'] );1204 $this->assert Equals( $categories[0]->count, $data[0]['count'] );1198 $this->assertSame( count( $categories ), count( $data ) ); 1199 $this->assertSame( $categories[0]->term_id, $data[0]['id'] ); 1200 $this->assertSame( $categories[0]->name, $data[0]['name'] ); 1201 $this->assertSame( $categories[0]->slug, $data[0]['slug'] ); 1202 $this->assertSame( $categories[0]->taxonomy, $data[0]['taxonomy'] ); 1203 $this->assertSame( $categories[0]->description, $data[0]['description'] ); 1204 $this->assertSame( $categories[0]->count, $data[0]['count'] ); 1205 1205 } 1206 1206 1207 1207 protected function check_taxonomy_term( $term, $data, $links ) { 1208 $this->assert Equals( $term->term_id, $data['id'] );1209 $this->assert Equals( $term->name, $data['name'] );1210 $this->assert Equals( $term->slug, $data['slug'] );1211 $this->assert Equals( $term->description, $data['description'] );1212 $this->assert Equals( get_term_link( $term ), $data['link'] );1213 $this->assert Equals( $term->count, $data['count'] );1208 $this->assertSame( $term->term_id, $data['id'] ); 1209 $this->assertSame( $term->name, $data['name'] ); 1210 $this->assertSame( $term->slug, $data['slug'] ); 1211 $this->assertSame( $term->description, $data['description'] ); 1212 $this->assertSame( get_term_link( $term ), $data['link'] ); 1213 $this->assertSame( $term->count, $data['count'] ); 1214 1214 $taxonomy = get_taxonomy( $term->taxonomy ); 1215 1215 if ( $taxonomy->hierarchical ) { 1216 $this->assert Equals( $term->parent, $data['parent'] );1216 $this->assertSame( $term->parent, $data['parent'] ); 1217 1217 } else { 1218 1218 $this->assertFalse( isset( $term->parent ) ); … … 1232 1232 $this->assertEqualSets( $relations, array_keys( $links ) ); 1233 1233 $this->assertContains( 'wp/v2/taxonomies/' . $term->taxonomy, $links['about'][0]['href'] ); 1234 $this->assert Equals( add_query_arg( 'categories', $term->term_id, rest_url( 'wp/v2/posts' ) ), $links['https://api.w.org/post_type'][0]['href'] );1234 $this->assertSame( add_query_arg( 'categories', $term->term_id, rest_url( 'wp/v2/posts' ) ), $links['https://api.w.org/post_type'][0]['href'] ); 1235 1235 } 1236 1236 1237 1237 protected function check_get_taxonomy_term_response( $response ) { 1238 1238 1239 $this->assert Equals( 200, $response->get_status() );1239 $this->assertSame( 200, $response->get_status() ); 1240 1240 1241 1241 $data = $response->get_data();
Note: See TracChangeset
for help on using the changeset viewer.