- Timestamp:
- 09/02/2020 12:35:36 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-users-controller.php
r48402 r48937 169 169 $response = rest_get_server()->dispatch( $request ); 170 170 $data = $response->get_data(); 171 $this->assert Equals( 'view', $data['endpoints'][0]['args']['context']['default'] );172 $this->assert Equals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );171 $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); 172 $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 173 173 // Single. 174 174 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/users/' . self::$user ); 175 175 $response = rest_get_server()->dispatch( $request ); 176 176 $data = $response->get_data(); 177 $this->assert Equals( 'view', $data['endpoints'][0]['args']['context']['default'] );178 $this->assert Equals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );177 $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); 178 $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); 179 179 } 180 180 … … 185 185 $keys = array_keys( $data['endpoints'][0]['args'] ); 186 186 sort( $keys ); 187 $this->assert Equals(187 $this->assertSame( 188 188 array( 189 189 'context', … … 211 211 $response = rest_get_server()->dispatch( $request ); 212 212 213 $this->assert Equals( 200, $response->get_status() );213 $this->assertSame( 200, $response->get_status() ); 214 214 215 215 $all_data = $response->get_data(); … … 226 226 $response = rest_get_server()->dispatch( $request ); 227 227 228 $this->assert Equals( 200, $response->get_status() );228 $this->assertSame( 200, $response->get_status() ); 229 229 230 230 $all_data = $response->get_data(); … … 240 240 $response = rest_get_server()->dispatch( $request ); 241 241 242 $this->assert Equals( 401, $response->get_status() );242 $this->assertSame( 401, $response->get_status() ); 243 243 244 244 // Test with a user logged in but without sufficient capabilities; … … 250 250 $response = rest_get_server()->dispatch( $request ); 251 251 252 $this->assert Equals( 403, $response->get_status() );252 $this->assertSame( 403, $response->get_status() ); 253 253 } 254 254 … … 314 314 $response = rest_get_server()->dispatch( $request ); 315 315 $headers = $response->get_headers(); 316 $this->assert Equals( $total_users, $headers['X-WP-Total'] );317 $this->assert Equals( $total_pages, $headers['X-WP-TotalPages'] );316 $this->assertSame( $total_users, $headers['X-WP-Total'] ); 317 $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); 318 318 $next_link = add_query_arg( 319 319 array( … … 333 333 $response = rest_get_server()->dispatch( $request ); 334 334 $headers = $response->get_headers(); 335 $this->assert Equals( $total_users, $headers['X-WP-Total'] );336 $this->assert Equals( $total_pages, $headers['X-WP-TotalPages'] );335 $this->assertSame( $total_users, $headers['X-WP-Total'] ); 336 $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); 337 337 $prev_link = add_query_arg( 338 338 array( … … 355 355 $response = rest_get_server()->dispatch( $request ); 356 356 $headers = $response->get_headers(); 357 $this->assert Equals( $total_users, $headers['X-WP-Total'] );358 $this->assert Equals( $total_pages, $headers['X-WP-TotalPages'] );357 $this->assertSame( $total_users, $headers['X-WP-Total'] ); 358 $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); 359 359 $prev_link = add_query_arg( 360 360 array( … … 371 371 $response = rest_get_server()->dispatch( $request ); 372 372 $headers = $response->get_headers(); 373 $this->assert Equals( $total_users, $headers['X-WP-Total'] );374 $this->assert Equals( $total_pages, $headers['X-WP-TotalPages'] );373 $this->assertSame( $total_users, $headers['X-WP-Total'] ); 374 $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); 375 375 $prev_link = add_query_arg( 376 376 array( … … 388 388 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); 389 389 $response = rest_get_server()->dispatch( $request ); 390 $this->assert Equals( 10, count( $response->get_data() ) );390 $this->assertSame( 10, count( $response->get_data() ) ); 391 391 392 392 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); 393 393 $request->set_param( 'per_page', 5 ); 394 394 $response = rest_get_server()->dispatch( $request ); 395 $this->assert Equals( 5, count( $response->get_data() ) );395 $this->assertSame( 5, count( $response->get_data() ) ); 396 396 } 397 397 … … 403 403 $request->set_param( 'page', 2 ); 404 404 $response = rest_get_server()->dispatch( $request ); 405 $this->assert Equals( 5, count( $response->get_data() ) );405 $this->assertSame( 5, count( $response->get_data() ) ); 406 406 $prev_link = add_query_arg( 407 407 array( … … 428 428 $response = rest_get_server()->dispatch( $request ); 429 429 $data = $response->get_data(); 430 $this->assert Equals( $high_id, $data[0]['id'] );430 $this->assertSame( $high_id, $data[0]['id'] ); 431 431 432 432 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); … … 436 436 $response = rest_get_server()->dispatch( $request ); 437 437 $data = $response->get_data(); 438 $this->assert Equals( $low_id, $data[0]['id'] );438 $this->assertSame( $low_id, $data[0]['id'] ); 439 439 } 440 440 … … 452 452 $response = rest_get_server()->dispatch( $request ); 453 453 $data = $response->get_data(); 454 $this->assert Equals( $high_id, $data[0]['id'] );454 $this->assertSame( $high_id, $data[0]['id'] ); 455 455 456 456 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); … … 461 461 $response = rest_get_server()->dispatch( $request ); 462 462 $data = $response->get_data(); 463 $this->assert Equals( $low_id, $data[0]['id'] );463 $this->assertSame( $low_id, $data[0]['id'] ); 464 464 } 465 465 … … 477 477 $response = rest_get_server()->dispatch( $request ); 478 478 $data = $response->get_data(); 479 $this->assert Equals( $high_id, $data[0]['id'] );479 $this->assertSame( $high_id, $data[0]['id'] ); 480 480 481 481 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); … … 486 486 $response = rest_get_server()->dispatch( $request ); 487 487 $data = $response->get_data(); 488 $this->assert Equals( $low_id, $data[0]['id'] );488 $this->assertSame( $low_id, $data[0]['id'] ); 489 489 } 490 490 … … 502 502 $data = $response->get_data(); 503 503 504 $this->assert Equals( 'taco', $data[0]['slug'] );505 $this->assert Equals( 'burrito', $data[1]['slug'] );506 $this->assert Equals( 'chalupa', $data[2]['slug'] );504 $this->assertSame( 'taco', $data[0]['slug'] ); 505 $this->assertSame( 'burrito', $data[1]['slug'] ); 506 $this->assertSame( 'chalupa', $data[2]['slug'] ); 507 507 } 508 508 … … 520 520 $response = rest_get_server()->dispatch( $request ); 521 521 $data = $response->get_data(); 522 $this->assert Equals( $high_id, $data[0]['id'] );522 $this->assertSame( $high_id, $data[0]['id'] ); 523 523 524 524 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); … … 529 529 $response = rest_get_server()->dispatch( $request ); 530 530 $data = $response->get_data(); 531 $this->assert Equals( $low_id, $data[0]['id'] );531 $this->assertSame( $low_id, $data[0]['id'] ); 532 532 } 533 533 … … 599 599 $response = rest_get_server()->dispatch( $request ); 600 600 $data = $response->get_data(); 601 $this->assert Equals( 2, count( $data ) );602 $this->assert Equals( $id1, $data[0]['id'] );601 $this->assertSame( 2, count( $data ) ); 602 $this->assertSame( $id1, $data[0]['id'] ); 603 603 604 604 // 'orderby' => 'include'. … … 606 606 $response = rest_get_server()->dispatch( $request ); 607 607 $data = $response->get_data(); 608 $this->assert Equals( 2, count( $data ) );609 $this->assert Equals( $id2, $data[0]['id'] );608 $this->assertSame( 2, count( $data ) ); 609 $this->assertSame( $id2, $data[0]['id'] ); 610 610 611 611 // Invalid 'include' should error. … … 619 619 $response = rest_get_server()->dispatch( $request ); 620 620 $data = $response->get_data(); 621 $this->assert Equals( 0, count( $data ) );621 $this->assertSame( 0, count( $data ) ); 622 622 623 623 } … … 656 656 $request->set_param( 'search', 'yololololo' ); 657 657 $response = rest_get_server()->dispatch( $request ); 658 $this->assert Equals( 0, count( $response->get_data() ) );658 $this->assertSame( 0, count( $response->get_data() ) ); 659 659 660 660 $yolo_id = $this->factory->user->create( array( 'display_name' => 'yololololo' ) ); … … 663 663 $request->set_param( 'search', 'yololololo' ); 664 664 $response = rest_get_server()->dispatch( $request ); 665 $this->assert Equals( 1, count( $response->get_data() ) );665 $this->assertSame( 1, count( $response->get_data() ) ); 666 666 // Default to wildcard search. 667 667 $adam_id = $this->factory->user->create( … … 676 676 $response = rest_get_server()->dispatch( $request ); 677 677 $data = $response->get_data(); 678 $this->assert Equals( 1, count( $data ) );679 $this->assert Equals( $adam_id, $data[0]['id'] );678 $this->assertSame( 1, count( $data ) ); 679 $this->assertSame( $adam_id, $data[0]['id'] ); 680 680 } 681 681 … … 700 700 $response = rest_get_server()->dispatch( $request ); 701 701 $data = $response->get_data(); 702 $this->assert Equals( 1, count( $data ) );703 $this->assert Equals( $id2, $data[0]['id'] );702 $this->assertSame( 1, count( $data ) ); 703 $this->assertSame( $id2, $data[0]['id'] ); 704 704 } 705 705 … … 744 744 $request->set_param( 'order', 'asc' ); 745 745 $response = rest_get_server()->dispatch( $request ); 746 $this->assert Equals( 200, $response->get_status() );746 $this->assertSame( 200, $response->get_status() ); 747 747 $data = $response->get_data(); 748 748 $slugs = wp_list_pluck( $data, 'slug' ); 749 $this->assert Equals( array( 'burrito', 'enchilada', 'taco' ), $slugs );749 $this->assertSame( array( 'burrito', 'enchilada', 'taco' ), $slugs ); 750 750 } 751 751 … … 783 783 $request->set_param( 'order', 'desc' ); 784 784 $response = rest_get_server()->dispatch( $request ); 785 $this->assert Equals( 200, $response->get_status() );785 $this->assertSame( 200, $response->get_status() ); 786 786 $data = $response->get_data(); 787 787 $slugs = wp_list_pluck( $data, 'slug' ); 788 $this->assert Equals( array( 'taco', 'enchilada', 'burrito' ), $slugs );788 $this->assertSame( array( 'taco', 'enchilada', 'burrito' ), $slugs ); 789 789 } 790 790 … … 813 813 $response = rest_get_server()->dispatch( $request ); 814 814 $data = $response->get_data(); 815 $this->assert Equals( 3, count( $data ) );816 $this->assert Equals( $tango, $data[1]['id'] );817 $this->assert Equals( $yolo, $data[2]['id'] );815 $this->assertSame( 3, count( $data ) ); 816 $this->assertSame( $tango, $data[1]['id'] ); 817 $this->assertSame( $yolo, $data[2]['id'] ); 818 818 819 819 $request->set_param( 'roles', 'author' ); 820 820 $response = rest_get_server()->dispatch( $request ); 821 821 $data = $response->get_data(); 822 $this->assert Equals( 1, count( $data ) );823 $this->assert Equals( $yolo, $data[0]['id'] );822 $this->assertSame( 1, count( $data ) ); 823 $this->assertSame( $yolo, $data[0]['id'] ); 824 824 825 825 wp_set_current_user( 0 ); … … 850 850 $response = rest_get_server()->dispatch( $request ); 851 851 $data = $response->get_data(); 852 $this->assert Equals( 1, count( $data ) );853 $this->assert Equals( $lolz, $data[0]['id'] );852 $this->assertSame( 1, count( $data ) ); 853 $this->assertSame( $lolz, $data[0]['id'] ); 854 854 855 855 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); … … 857 857 $response = rest_get_server()->dispatch( $request ); 858 858 $data = $response->get_data(); 859 $this->assert Equals( 0, count( $data ) );860 $this->assert Equals( array(), $data );859 $this->assertSame( 0, count( $data ) ); 860 $this->assertSame( array(), $data ); 861 861 } 862 862 … … 868 868 $request->set_param( 'search', 'subscriber' ); 869 869 $response = rest_get_server()->dispatch( $request ); 870 $this->assert Equals( 200, $response->get_status() );870 $this->assertSame( 200, $response->get_status() ); 871 871 $this->assertCount( 1, $response->get_data() ); 872 872 … … 876 876 $request->set_param( 'search', 'subscriber' ); 877 877 $response = rest_get_server()->dispatch( $request ); 878 $this->assert Equals( 200, $response->get_status() );878 $this->assertSame( 200, $response->get_status() ); 879 879 $this->assertCount( 0, $response->get_data() ); 880 880 } … … 930 930 $user = get_user_by( 'id', get_current_user_id() ); 931 931 $response = $this->endpoint->prepare_item_for_response( $user, $request ); 932 $this->assert Equals(932 $this->assertSame( 933 933 array( 934 934 'id', … … 953 953 // Ignore the subdomain, since get_avatar_url() randomly sets 954 954 // the Gravatar server when building the URL string. 955 $this->assert Equals( substr( get_avatar_url( $user->user_email ), 9 ), substr( $data['avatar_urls'][96], 9 ) );955 $this->assertSame( substr( get_avatar_url( $user->user_email ), 9 ), substr( $data['avatar_urls'][96], 9 ) ); 956 956 } 957 957 … … 1005 1005 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$authors['r_true_p_true'] ) ); 1006 1006 $response = rest_get_server()->dispatch( $request ); 1007 $this->assert Equals( 200, $response->get_status() );1007 $this->assertSame( 200, $response->get_status() ); 1008 1008 } 1009 1009 … … 1013 1013 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$authors['r_true_p_true'] ) ); 1014 1014 $response = rest_get_server()->dispatch( $request ); 1015 $this->assert Equals( 200, $response->get_status() );1015 $this->assertSame( 200, $response->get_status() ); 1016 1016 } 1017 1017 … … 1019 1019 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$authors['r_true_p_false'] ) ); 1020 1020 $response = rest_get_server()->dispatch( $request ); 1021 $this->assert Equals( 200, $response->get_status() );1021 $this->assertSame( 200, $response->get_status() ); 1022 1022 } 1023 1023 … … 1045 1045 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$editor ) ); 1046 1046 $response = rest_get_server()->dispatch( $request ); 1047 $this->assert Equals( 200, $response->get_status() );1047 $this->assertSame( 200, $response->get_status() ); 1048 1048 } 1049 1049 … … 1085 1085 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', $this->author_id ) ); 1086 1086 $response = rest_get_server()->dispatch( $request ); 1087 $this->assert Equals( 401, $response->get_status() );1087 $this->assertSame( 401, $response->get_status() ); 1088 1088 1089 1089 $this->post_id = $this->factory->post->create( … … 1135 1135 $request = new WP_REST_Request( 'GET', '/wp/v2/users/me' ); 1136 1136 $response = rest_get_server()->dispatch( $request ); 1137 $this->assert Equals( 200, $response->get_status() );1137 $this->assertSame( 200, $response->get_status() ); 1138 1138 $this->check_get_user_response( $response, 'view' ); 1139 1139 … … 1142 1142 1143 1143 $links = $response->get_links(); 1144 $this->assert Equals( rest_url( 'wp/v2/users/' . self::$user ), $links['self'][0]['href'] );1144 $this->assertSame( rest_url( 'wp/v2/users/' . self::$user ), $links['self'][0]['href'] ); 1145 1145 } 1146 1146 … … 1176 1176 1177 1177 $data = $response->get_data(); 1178 $this->assert Equals( 'http://example.com', $data['url'] );1179 $this->assert Equals( array( 'editor' ), $data['roles'] );1178 $this->assertSame( 'http://example.com', $data['url'] ); 1179 $this->assertSame( array( 'editor' ), $data['roles'] ); 1180 1180 $this->check_add_edit_user_response( $response ); 1181 1181 } … … 1215 1215 $this->assertCount( 1, $data['additional_errors'] ); 1216 1216 $error = $data['additional_errors'][0]; 1217 $this->assert Equals( 'user_name', $error['code'] );1218 $this->assert Equals( 'Usernames can only contain lowercase letters (a-z) and numbers.', $error['message'] );1217 $this->assertSame( 'user_name', $error['code'] ); 1218 $this->assertSame( 'Usernames can only contain lowercase letters (a-z) and numbers.', $error['message'] ); 1219 1219 } else { 1220 1220 $this->assertInternalType( 'array', $data['data']['params'] ); 1221 1221 $errors = $data['data']['params']; 1222 1222 $this->assertInternalType( 'string', $errors['username'] ); 1223 $this->assert Equals( 'This username is invalid because it uses illegal characters. Please enter a valid username.', $errors['username'] );1223 $this->assertSame( 'This username is invalid because it uses illegal characters. Please enter a valid username.', $errors['username'] ); 1224 1224 } 1225 1225 } … … 1261 1261 $errors = $data['data']['params']; 1262 1262 $this->assertInternalType( 'string', $errors['username'] ); 1263 $this->assert Equals( 'Sorry, that username is not allowed.', $errors['username'] );1263 $this->assertSame( 'Sorry, that username is not allowed.', $errors['username'] ); 1264 1264 } 1265 1265 … … 1389 1389 $this->assertContains( $error['code'], array( 'user_name', 'user_email' ) ); 1390 1390 if ( 'user_name' === $error['code'] ) { 1391 $this->assert Equals( 'Sorry, that username already exists!', $error['message'] );1391 $this->assertSame( 'Sorry, that username already exists!', $error['message'] ); 1392 1392 } else { 1393 $this->assert Equals( 'Sorry, that email address is already used!', $error['message'] );1393 $this->assertSame( 'Sorry, that email address is already used!', $error['message'] ); 1394 1394 } 1395 1395 } … … 1525 1525 // Check that the name has been updated correctly. 1526 1526 $new_data = $response->get_data(); 1527 $this->assert Equals( 'New Name', $new_data['first_name'] );1527 $this->assertSame( 'New Name', $new_data['first_name'] ); 1528 1528 $user = get_userdata( $user_id ); 1529 $this->assert Equals( 'New Name', $user->first_name );1530 1531 $this->assert Equals( 'http://google.com', $new_data['url'] );1532 $this->assert Equals( 'http://google.com', $user->user_url );1533 $this->assert Equals( 'de_DE', $user->locale );1529 $this->assertSame( 'New Name', $user->first_name ); 1530 1531 $this->assertSame( 'http://google.com', $new_data['url'] ); 1532 $this->assertSame( 'http://google.com', $user->user_url ); 1533 $this->assertSame( 'de_DE', $user->locale ); 1534 1534 1535 1535 // Check that we haven't inadvertently changed the user's password, 1536 1536 // as per https://core.trac.wordpress.org/ticket/21429 1537 $this->assert Equals( $pw_before, $user->user_pass );1537 $this->assertSame( $pw_before, $user->user_pass ); 1538 1538 } 1539 1539 … … 1551 1551 // even if no DB rows are updated. 1552 1552 $response = rest_get_server()->dispatch( $request ); 1553 $this->assert Equals( 200, $response->get_status() );1554 1555 $response = rest_get_server()->dispatch( $request ); 1556 $this->assert Equals( 200, $response->get_status() );1553 $this->assertSame( 200, $response->get_status() ); 1554 1555 $response = rest_get_server()->dispatch( $request ); 1556 $this->assertSame( 200, $response->get_status() ); 1557 1557 } 1558 1558 … … 1579 1579 $response = rest_get_server()->dispatch( $request ); 1580 1580 $this->assertInstanceOf( 'WP_Error', $response->as_error() ); 1581 $this->assert Equals( 'rest_user_invalid_email', $response->as_error()->get_error_code() );1581 $this->assertSame( 'rest_user_invalid_email', $response->as_error()->get_error_code() ); 1582 1582 } 1583 1583 … … 1597 1597 $data = $response->get_data(); 1598 1598 1599 $this->assert Equals( 200, $response->get_status() );1600 $this->assert Equals( $updated_email_with_case_change, $data['email'] );1599 $this->assertSame( 200, $response->get_status() ); 1600 $this->assertSame( $updated_email_with_case_change, $data['email'] ); 1601 1601 } 1602 1602 … … 1617 1617 $data = $response->get_data(); 1618 1618 1619 $this->assert Equals( 400, $response->get_status() );1619 $this->assertSame( 400, $response->get_status() ); 1620 1620 $this->assertSame( 'rest_user_invalid_email', $data['code'] ); 1621 1621 } … … 1637 1637 $response = rest_get_server()->dispatch( $request ); 1638 1638 $this->assertInstanceOf( 'WP_Error', $response->as_error() ); 1639 $this->assert Equals( 'rest_invalid_param', $response->as_error()->get_error_code() );1639 $this->assertSame( 'rest_invalid_param', $response->as_error()->get_error_code() ); 1640 1640 } 1641 1641 … … 1658 1658 1659 1659 $user = get_userdata( $user_id ); 1660 $this->assert Equals( 'en_US', $user->locale );1660 $this->assertSame( 'en_US', $user->locale ); 1661 1661 } 1662 1662 … … 1683 1683 1684 1684 $data = $response->get_data(); 1685 $this->assert Equals( get_locale(), $data['locale'] );1685 $this->assertSame( get_locale(), $data['locale'] ); 1686 1686 $user = get_userdata( $user_id ); 1687 $this->assert Equals( '', $user->locale );1687 $this->assertSame( '', $user->locale ); 1688 1688 } 1689 1689 … … 1710 1710 $response = rest_get_server()->dispatch( $request ); 1711 1711 $this->assertInstanceOf( 'WP_Error', $response->as_error() ); 1712 $this->assert Equals( 'rest_user_invalid_argument', $response->as_error()->get_error_code() );1712 $this->assertSame( 'rest_user_invalid_argument', $response->as_error()->get_error_code() ); 1713 1713 } 1714 1714 … … 1735 1735 $response = rest_get_server()->dispatch( $request ); 1736 1736 $this->assertInstanceOf( 'WP_Error', $response->as_error() ); 1737 $this->assert Equals( 'rest_user_invalid_slug', $response->as_error()->get_error_code() );1737 $this->assertSame( 'rest_user_invalid_slug', $response->as_error()->get_error_code() ); 1738 1738 } 1739 1739 … … 1772 1772 // Check that the name has been updated correctly. 1773 1773 $new_data = $response->get_data(); 1774 $this->assert Equals( 'JSON Name', $new_data['first_name'] );1775 $this->assert Equals( 'New Last', $new_data['last_name'] );1774 $this->assertSame( 'JSON Name', $new_data['first_name'] ); 1775 $this->assertSame( 'New Last', $new_data['last_name'] ); 1776 1776 $user = get_userdata( $user_id ); 1777 $this->assert Equals( 'JSON Name', $user->first_name );1778 $this->assert Equals( 'New Last', $user->last_name );1777 $this->assertSame( 'JSON Name', $user->first_name ); 1778 $this->assertSame( 'New Last', $user->last_name ); 1779 1779 1780 1780 // Check that we haven't inadvertently changed the user's password, 1781 1781 // as per https://core.trac.wordpress.org/ticket/21429 1782 $this->assert Equals( $pw_before, $user->user_pass );1782 $this->assertSame( $pw_before, $user->user_pass ); 1783 1783 } 1784 1784 … … 1796 1796 $new_data = $response->get_data(); 1797 1797 1798 $this->assert Equals( 'editor', $new_data['roles'][0] );1798 $this->assertSame( 'editor', $new_data['roles'][0] ); 1799 1799 $this->assertNotEquals( 'administrator', $new_data['roles'][0] ); 1800 1800 … … 1817 1817 $new_data = $response->get_data(); 1818 1818 1819 $this->assert Equals( array( 'author', 'editor' ), $new_data['roles'] );1819 $this->assertSame( array( 'author', 'editor' ), $new_data['roles'] ); 1820 1820 1821 1821 $user = get_userdata( $user_id ); … … 1891 1891 1892 1892 $new_data = $response->get_data(); 1893 $this->assert Equals( 'editor', $new_data['roles'][0] );1893 $this->assertSame( 'editor', $new_data['roles'][0] ); 1894 1894 $this->assertNotEquals( 'administrator', $new_data['roles'][0] ); 1895 1895 … … 1905 1905 1906 1906 $new_data = $response->get_data(); 1907 $this->assert Equals( 'editor', $new_data['roles'][0] );1907 $this->assertSame( 'editor', $new_data['roles'][0] ); 1908 1908 $this->assertNotEquals( 'administrator', $new_data['roles'][0] ); 1909 1909 } … … 2013 2013 $request->set_param( 'roles', array( 'editor' ) ); 2014 2014 $response = rest_get_server()->dispatch( $request ); 2015 $this->assert Equals( 200, $response->get_status() );2015 $this->assertSame( 200, $response->get_status() ); 2016 2016 2017 2017 $new_data = $response->get_data(); 2018 $this->assert Equals( 'editor', $new_data['roles'][0] );2018 $this->assertSame( 'editor', $new_data['roles'][0] ); 2019 2019 } 2020 2020 … … 2045 2045 $this->assertErrorResponse( 'rest_cannot_edit', $response, 403 ); 2046 2046 } else { 2047 $this->assert Equals( 200, $response->get_status() );2047 $this->assertSame( 200, $response->get_status() ); 2048 2048 2049 2049 $new_data = $response->get_data(); 2050 $this->assert Equals( 'editor', $new_data['roles'][0] );2050 $this->assertSame( 'editor', $new_data['roles'][0] ); 2051 2051 } 2052 2052 } … … 2079 2079 $request->set_param( 'email', 'cbg@androidsdungeon.com' ); 2080 2080 $response = rest_get_server()->dispatch( $request ); 2081 $this->assert Equals( 201, $response->get_status() );2081 $this->assertSame( 201, $response->get_status() ); 2082 2082 $actual_output = $response->get_data(); 2083 2083 2084 2084 // Compare expected API output to actual API output. 2085 $this->assert Equals( $expected_output['username'], $actual_output['username'] );2086 $this->assert Equals( $expected_output['name'], $actual_output['name'] );2087 $this->assert Equals( $expected_output['first_name'], $actual_output['first_name'] );2088 $this->assert Equals( $expected_output['last_name'], $actual_output['last_name'] );2089 $this->assert Equals( $expected_output['url'], $actual_output['url'] );2090 $this->assert Equals( $expected_output['description'], $actual_output['description'] );2091 $this->assert Equals( $expected_output['nickname'], $actual_output['nickname'] );2085 $this->assertSame( $expected_output['username'], $actual_output['username'] ); 2086 $this->assertSame( $expected_output['name'], $actual_output['name'] ); 2087 $this->assertSame( $expected_output['first_name'], $actual_output['first_name'] ); 2088 $this->assertSame( $expected_output['last_name'], $actual_output['last_name'] ); 2089 $this->assertSame( $expected_output['url'], $actual_output['url'] ); 2090 $this->assertSame( $expected_output['description'], $actual_output['description'] ); 2091 $this->assertSame( $expected_output['nickname'], $actual_output['nickname'] ); 2092 2092 2093 2093 // Compare expected API output to WP internal values. 2094 2094 $user = get_userdata( $actual_output['id'] ); 2095 $this->assert Equals( $expected_output['username'], $user->user_login );2096 $this->assert Equals( $expected_output['name'], $user->display_name );2097 $this->assert Equals( $expected_output['first_name'], $user->first_name );2098 $this->assert Equals( $expected_output['last_name'], $user->last_name );2099 $this->assert Equals( $expected_output['url'], $user->user_url );2100 $this->assert Equals( $expected_output['description'], $user->description );2101 $this->assert Equals( $expected_output['nickname'], $user->nickname );2095 $this->assertSame( $expected_output['username'], $user->user_login ); 2096 $this->assertSame( $expected_output['name'], $user->display_name ); 2097 $this->assertSame( $expected_output['first_name'], $user->first_name ); 2098 $this->assertSame( $expected_output['last_name'], $user->last_name ); 2099 $this->assertSame( $expected_output['url'], $user->user_url ); 2100 $this->assertSame( $expected_output['description'], $user->description ); 2101 $this->assertSame( $expected_output['nickname'], $user->nickname ); 2102 2102 $this->assertTrue( wp_check_password( addslashes( $expected_output['password'] ), $user->user_pass ) ); 2103 2103 … … 2113 2113 } 2114 2114 $response = rest_get_server()->dispatch( $request ); 2115 $this->assert Equals( 200, $response->get_status() );2115 $this->assertSame( 200, $response->get_status() ); 2116 2116 $actual_output = $response->get_data(); 2117 2117 2118 2118 // Compare expected API output to actual API output. 2119 2119 if ( isset( $expected_output['username'] ) ) { 2120 $this->assert Equals( $expected_output['username'], $actual_output['username'] );2121 } 2122 $this->assert Equals( $expected_output['name'], $actual_output['name'] );2123 $this->assert Equals( $expected_output['first_name'], $actual_output['first_name'] );2124 $this->assert Equals( $expected_output['last_name'], $actual_output['last_name'] );2125 $this->assert Equals( $expected_output['url'], $actual_output['url'] );2126 $this->assert Equals( $expected_output['description'], $actual_output['description'] );2127 $this->assert Equals( $expected_output['nickname'], $actual_output['nickname'] );2120 $this->assertSame( $expected_output['username'], $actual_output['username'] ); 2121 } 2122 $this->assertSame( $expected_output['name'], $actual_output['name'] ); 2123 $this->assertSame( $expected_output['first_name'], $actual_output['first_name'] ); 2124 $this->assertSame( $expected_output['last_name'], $actual_output['last_name'] ); 2125 $this->assertSame( $expected_output['url'], $actual_output['url'] ); 2126 $this->assertSame( $expected_output['description'], $actual_output['description'] ); 2127 $this->assertSame( $expected_output['nickname'], $actual_output['nickname'] ); 2128 2128 2129 2129 // Compare expected API output to WP internal values. 2130 2130 $user = get_userdata( $actual_output['id'] ); 2131 2131 if ( isset( $expected_output['username'] ) ) { 2132 $this->assert Equals( $expected_output['username'], $user->user_login );2133 } 2134 $this->assert Equals( $expected_output['name'], $user->display_name );2135 $this->assert Equals( $expected_output['first_name'], $user->first_name );2136 $this->assert Equals( $expected_output['last_name'], $user->last_name );2137 $this->assert Equals( $expected_output['url'], $user->user_url );2138 $this->assert Equals( $expected_output['description'], $user->description );2139 $this->assert Equals( $expected_output['nickname'], $user->nickname );2132 $this->assertSame( $expected_output['username'], $user->user_login ); 2133 } 2134 $this->assertSame( $expected_output['name'], $user->display_name ); 2135 $this->assertSame( $expected_output['first_name'], $user->first_name ); 2136 $this->assertSame( $expected_output['last_name'], $user->last_name ); 2137 $this->assertSame( $expected_output['url'], $user->user_url ); 2138 $this->assertSame( $expected_output['description'], $user->description ); 2139 $this->assertSame( $expected_output['nickname'], $user->nickname ); 2140 2140 $this->assertTrue( wp_check_password( addslashes( $expected_output['password'] ), $user->user_pass ) ); 2141 2141 } … … 2144 2144 wp_set_current_user( self::$editor ); 2145 2145 2146 $this->assert Equals( ! is_multisite(), current_user_can( 'unfiltered_html' ) );2146 $this->assertSame( ! is_multisite(), current_user_can( 'unfiltered_html' ) ); 2147 2147 $this->verify_user_roundtrip( 2148 2148 array( … … 2297 2297 } 2298 2298 2299 $this->assert Equals( 200, $response->get_status() );2299 $this->assertSame( 200, $response->get_status() ); 2300 2300 $data = $response->get_data(); 2301 2301 $this->assertTrue( $data['deleted'] ); 2302 $this->assert Equals( 'Deleted User', $data['previous']['name'] );2302 $this->assertSame( 'Deleted User', $data['previous']['name'] ); 2303 2303 } 2304 2304 … … 2356 2356 } 2357 2357 2358 $this->assert Equals( 200, $response->get_status() );2358 $this->assertSame( 200, $response->get_status() ); 2359 2359 $data = $response->get_data(); 2360 2360 $this->assertTrue( $data['deleted'] ); 2361 $this->assert Equals( 'Deleted User', $data['previous']['name'] );2361 $this->assertSame( 'Deleted User', $data['previous']['name'] ); 2362 2362 } 2363 2363 … … 2460 2460 } 2461 2461 2462 $this->assert Equals( 200, $response->get_status() );2462 $this->assertSame( 200, $response->get_status() ); 2463 2463 2464 2464 // Check that the post has been updated correctly. … … 2528 2528 2529 2529 $test_post = get_post( $test_post ); 2530 $this->assert Equals( 'trash', $test_post->post_status );2530 $this->assertSame( 'trash', $test_post->post_status ); 2531 2531 } 2532 2532 … … 2556 2556 2557 2557 $test_post = get_post( $test_post ); 2558 $this->assert Equals( 'trash', $test_post->post_status );2558 $this->assertSame( 'trash', $test_post->post_status ); 2559 2559 } 2560 2560 … … 2584 2584 2585 2585 $test_post = get_post( $test_post ); 2586 $this->assert Equals( 'trash', $test_post->post_status );2586 $this->assertSame( 'trash', $test_post->post_status ); 2587 2587 } 2588 2588 … … 2621 2621 $properties = $data['schema']['properties']; 2622 2622 2623 $this->assert Equals( 19, count( $properties ) );2623 $this->assertSame( 19, count( $properties ) ); 2624 2624 $this->assertArrayHasKey( 'avatar_urls', $properties ); 2625 2625 $this->assertArrayHasKey( 'capabilities', $properties ); … … 2685 2685 2686 2686 $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] ); 2687 $this->assert Equals( $schema, $data['schema']['properties']['my_custom_int'] );2687 $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); 2688 2688 2689 2689 wp_set_current_user( 1 ); … … 2910 2910 $response = rest_get_server()->dispatch( $request ); 2911 2911 2912 $this->assert Equals( 200, $response->get_status() );2912 $this->assertSame( 200, $response->get_status() ); 2913 2913 2914 2914 $data = $response->get_data(); … … 2917 2917 $meta = (array) $data['meta']; 2918 2918 $this->assertArrayHasKey( $meta_key, $meta ); 2919 $this->assert Equals( $expected, $meta[ $meta_key ] );2919 $this->assertSame( $expected, $meta[ $meta_key ] ); 2920 2920 } 2921 2921 … … 3022 3022 3023 3023 protected function check_user_data( $user, $data, $context, $links ) { 3024 $this->assert Equals( $user->ID, $data['id'] );3025 $this->assert Equals( $user->display_name, $data['name'] );3026 $this->assert Equals( $user->user_url, $data['url'] );3027 $this->assert Equals( $user->description, $data['description'] );3028 $this->assert Equals( get_author_posts_url( $user->ID ), $data['link'] );3024 $this->assertSame( $user->ID, $data['id'] ); 3025 $this->assertSame( $user->display_name, $data['name'] ); 3026 $this->assertSame( $user->user_url, $data['url'] ); 3027 $this->assertSame( $user->description, $data['description'] ); 3028 $this->assertSame( get_author_posts_url( $user->ID ), $data['link'] ); 3029 3029 $this->assertArrayHasKey( 'avatar_urls', $data ); 3030 $this->assert Equals( $user->user_nicename, $data['slug'] );3030 $this->assertSame( $user->user_nicename, $data['slug'] ); 3031 3031 3032 3032 if ( 'edit' === $context ) { 3033 $this->assert Equals( $user->first_name, $data['first_name'] );3034 $this->assert Equals( $user->last_name, $data['last_name'] );3035 $this->assert Equals( $user->nickname, $data['nickname'] );3036 $this->assert Equals( $user->user_email, $data['email'] );3033 $this->assertSame( $user->first_name, $data['first_name'] ); 3034 $this->assertSame( $user->last_name, $data['last_name'] ); 3035 $this->assertSame( $user->nickname, $data['nickname'] ); 3036 $this->assertSame( $user->user_email, $data['email'] ); 3037 3037 $this->assertEquals( (object) $user->allcaps, $data['capabilities'] ); 3038 3038 $this->assertEquals( (object) $user->caps, $data['extra_capabilities'] ); 3039 $this->assert Equals( gmdate( 'c', strtotime( $user->user_registered ) ), $data['registered_date'] );3040 $this->assert Equals( $user->user_login, $data['username'] );3041 $this->assert Equals( $user->roles, $data['roles'] );3042 $this->assert Equals( get_user_locale( $user ), $data['locale'] );3039 $this->assertSame( gmdate( 'c', strtotime( $user->user_registered ) ), $data['registered_date'] ); 3040 $this->assertSame( $user->user_login, $data['username'] ); 3041 $this->assertSame( $user->roles, $data['roles'] ); 3042 $this->assertSame( get_user_locale( $user ), $data['locale'] ); 3043 3043 } 3044 3044 … … 3068 3068 3069 3069 protected function check_get_user_response( $response, $context = 'view' ) { 3070 $this->assert Equals( 200, $response->get_status() );3070 $this->assertSame( 200, $response->get_status() ); 3071 3071 3072 3072 $data = $response->get_data(); … … 3077 3077 protected function check_add_edit_user_response( $response, $update = false ) { 3078 3078 if ( $update ) { 3079 $this->assert Equals( 200, $response->get_status() );3079 $this->assertSame( 200, $response->get_status() ); 3080 3080 } else { 3081 $this->assert Equals( 201, $response->get_status() );3081 $this->assertSame( 201, $response->get_status() ); 3082 3082 } 3083 3083
Note: See TracChangeset
for help on using the changeset viewer.