Changeset 52010 for trunk/tests/phpunit/tests/user.php
- Timestamp:
- 11/04/2021 03:22:47 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/user.php
r51738 r52010 61 61 } 62 62 63 function set_up() {63 public function set_up() { 64 64 parent::set_up(); 65 65 … … 67 67 } 68 68 69 function test_get_users_of_blog() {69 public function test_get_users_of_blog() { 70 70 // Add one of each user role. 71 71 $nusers = array( … … 93 93 94 94 // Simple get/set tests for user_option functions. 95 function test_user_option() {95 public function test_user_option() { 96 96 $key = rand_str(); 97 97 $val = rand_str(); … … 113 113 * Simple tests for usermeta functions. 114 114 */ 115 function test_usermeta() {115 public function test_usermeta() { 116 116 $key = 'key'; 117 117 $val = 'value1'; … … 147 147 * Test usermeta functions in array mode. 148 148 */ 149 function test_usermeta_array() {149 public function test_usermeta_array() { 150 150 // Some values to set. 151 151 $vals = array( … … 189 189 * Test property magic functions for property get/set/isset. 190 190 */ 191 function test_user_properties() {191 public function test_user_properties() { 192 192 $user = new WP_User( self::$author_id ); 193 193 … … 248 248 * @ticket 20043 249 249 */ 250 function test_user_unset_lowercase_id( $user ) {250 public function test_user_unset_lowercase_id( $user ) { 251 251 $id = $user->id; 252 252 unset( $user->id ); … … 261 261 * @ticket 20043 262 262 */ 263 function test_user_unset_uppercase_id( $user ) {263 public function test_user_unset_uppercase_id( $user ) { 264 264 $this->assertNotEmpty( $user->ID ); 265 265 unset( $user->ID ); … … 270 270 * Test meta property magic functions for property get/set/isset. 271 271 */ 272 function test_user_meta_properties() {272 public function test_user_meta_properties() { 273 273 $user = new WP_User( self::$author_id ); 274 274 … … 283 283 * @expectedDeprecated WP_User->id 284 284 */ 285 function test_id_property_back_compat() {285 public function test_id_property_back_compat() { 286 286 $user = new WP_User( self::$author_id ); 287 287 … … 295 295 * @ticket 19265 296 296 */ 297 function test_user_level_property_back_compat() {297 public function test_user_level_property_back_compat() { 298 298 $roles = array( 299 299 self::$admin_id => 10, … … 312 312 } 313 313 314 function test_construction() {314 public function test_construction() { 315 315 $user = new WP_User( self::$author_id ); 316 316 $this->assertInstanceOf( 'WP_User', $user ); … … 351 351 } 352 352 353 function test_get() {353 public function test_get() { 354 354 $user = new WP_User( self::$author_id ); 355 355 $this->assertSame( 'author_login', $user->get( 'user_login' ) ); … … 362 362 } 363 363 364 function test_has_prop() {364 public function test_has_prop() { 365 365 $user = new WP_User( self::$author_id ); 366 366 $this->assertTrue( $user->has_prop( 'user_email' ) ); … … 372 372 } 373 373 374 function test_update_user() {374 public function test_update_user() { 375 375 $user = new WP_User( self::$author_id ); 376 376 … … 430 430 * @ticket 19595 431 431 */ 432 function test_global_userdata() {432 public function test_global_userdata() { 433 433 global $userdata, $wpdb; 434 434 … … 446 446 * @ticket 19769 447 447 */ 448 function test_global_userdata_is_null_when_logged_out() {448 public function test_global_userdata_is_null_when_logged_out() { 449 449 global $userdata; 450 450 wp_set_current_user( 0 ); … … 452 452 } 453 453 454 function test_exists() {454 public function test_exists() { 455 455 $user = new WP_User( self::$author_id ); 456 456 … … 466 466 } 467 467 468 function test_global_authordata() {468 public function test_global_authordata() { 469 469 global $authordata, $id; 470 470 … … 499 499 * @ticket 13317 500 500 */ 501 function test_get_userdata() {501 public function test_get_userdata() { 502 502 $this->assertFalse( get_userdata( 0 ) ); 503 503 $this->assertFalse( get_userdata( '0' ) ); … … 509 509 * @ticket 23480 510 510 */ 511 function test_user_get_data_by_id() {511 public function test_user_get_data_by_id() { 512 512 $user = WP_User::get_data_by( 'id', self::$author_id ); 513 513 $this->assertInstanceOf( 'stdClass', $user ); … … 548 548 * @ticket 21431 549 549 */ 550 function test_count_many_users_posts() {550 public function test_count_many_users_posts() { 551 551 $user_id_b = self::factory()->user->create( array( 'role' => 'author' ) ); 552 552 $post_id_a = self::factory()->post->create( array( 'post_author' => self::$author_id ) ); … … 581 581 * @ticket 22858 582 582 */ 583 function test_wp_update_user_on_nonexistent_users() {583 public function test_wp_update_user_on_nonexistent_users() { 584 584 $user_id = 1; 585 585 // Find me a non-existent user ID. … … 595 595 * @ticket 28435 596 596 */ 597 function test_wp_update_user_should_not_change_password_when_passed_WP_User_instance() {597 public function test_wp_update_user_should_not_change_password_when_passed_WP_User_instance() { 598 598 $testuserid = 1; 599 599 $user = get_userdata( $testuserid ); … … 610 610 * @group ms-excluded 611 611 */ 612 function test_wp_update_user_should_not_mark_user_as_spam_on_single_site() {612 public function test_wp_update_user_should_not_mark_user_as_spam_on_single_site() { 613 613 $u = wp_update_user( 614 614 array( … … 634 634 * @ticket 28315 635 635 */ 636 function test_user_meta_error() {636 public function test_user_meta_error() { 637 637 $id1 = wp_insert_user( 638 638 array( … … 665 665 * @ticket 30647 666 666 */ 667 function test_user_update_email_error() {667 public function test_user_update_email_error() { 668 668 $id1 = wp_insert_user( 669 669 array( … … 708 708 /** 709 709 * @ticket 27317 710 * @dataProvider _illegal_user_logins_data711 */ 712 function test_illegal_user_logins_single( $user_login ) {710 * @dataProvider data_illegal_user_logins 711 */ 712 public function test_illegal_user_logins_single( $user_login ) { 713 713 $user_data = array( 714 714 'user_login' => $user_login, … … 717 717 ); 718 718 719 add_filter( 'illegal_user_logins', array( $this, ' _illegal_user_logins' ) );719 add_filter( 'illegal_user_logins', array( $this, 'illegal_user_logins' ) ); 720 720 721 721 $response = wp_insert_user( $user_data ); … … 723 723 $this->assertSame( 'invalid_username', $response->get_error_code() ); 724 724 725 remove_filter( 'illegal_user_logins', array( $this, ' _illegal_user_logins' ) );725 remove_filter( 'illegal_user_logins', array( $this, 'illegal_user_logins' ) ); 726 726 727 727 $user_id = wp_insert_user( $user_data ); … … 732 732 /** 733 733 * @ticket 27317 734 * @dataProvider _illegal_user_logins_data735 */ 736 function test_illegal_user_logins_single_wp_create_user( $user_login ) {734 * @dataProvider data_illegal_user_logins 735 */ 736 public function test_illegal_user_logins_single_wp_create_user( $user_login ) { 737 737 $user_email = 'testuser-' . $user_login . '@example.com'; 738 738 739 add_filter( 'illegal_user_logins', array( $this, ' _illegal_user_logins' ) );739 add_filter( 'illegal_user_logins', array( $this, 'illegal_user_logins' ) ); 740 740 741 741 $response = register_new_user( $user_login, $user_email ); … … 743 743 $this->assertSame( 'invalid_username', $response->get_error_code() ); 744 744 745 remove_filter( 'illegal_user_logins', array( $this, ' _illegal_user_logins' ) );745 remove_filter( 'illegal_user_logins', array( $this, 'illegal_user_logins' ) ); 746 746 747 747 $response = register_new_user( $user_login, $user_email ); … … 754 754 * @group ms-required 755 755 */ 756 function test_illegal_user_logins_multisite() {756 public function test_illegal_user_logins_multisite() { 757 757 $user_data = array( 758 758 'user_login' => 'testuser', … … 760 760 ); 761 761 762 add_filter( 'illegal_user_logins', array( $this, ' _illegal_user_logins' ) );762 add_filter( 'illegal_user_logins', array( $this, 'illegal_user_logins' ) ); 763 763 764 764 $response = wpmu_validate_user_signup( $user_data['user_login'], $user_data['user_email'] ); … … 766 766 $this->assertSame( 'user_name', $response['errors']->get_error_code() ); 767 767 768 remove_filter( 'illegal_user_logins', array( $this, ' _illegal_user_logins' ) );768 remove_filter( 'illegal_user_logins', array( $this, 'illegal_user_logins' ) ); 769 769 770 770 $response = wpmu_validate_user_signup( $user_data['user_login'], $user_data['user_email'] ); … … 773 773 } 774 774 775 function _illegal_user_logins_data() {775 public function data_illegal_user_logins() { 776 776 $data = array( 777 777 array( 'testuser' ), … … 785 785 } 786 786 787 function _illegal_user_logins() {787 public function illegal_user_logins() { 788 788 return array( 'testuser' ); 789 789 } … … 1164 1164 * @ticket 32158 1165 1165 */ 1166 function test_email_case() {1166 public function test_email_case() { 1167 1167 // Alter the case of the email address (which stays the same). 1168 1168 $userdata = array( … … 1178 1178 * @ticket 32158 1179 1179 */ 1180 function test_email_change() {1180 public function test_email_change() { 1181 1181 // Change the email address. 1182 1182 $userdata = array( … … 1201 1201 * @ticket 36009 1202 1202 */ 1203 function test_wp_new_user_notification( $notify, $admin_email_sent_expected, $user_email_sent_expected ) {1203 public function test_wp_new_user_notification( $notify, $admin_email_sent_expected, $user_email_sent_expected ) { 1204 1204 reset_phpmailer_instance(); 1205 1205 … … 1244 1244 * } 1245 1245 */ 1246 function data_wp_new_user_notifications() {1246 public function data_wp_new_user_notifications() { 1247 1247 return array( 1248 1248 array( … … 1281 1281 * @expectedDeprecated wp_new_user_notification 1282 1282 */ 1283 function test_wp_new_user_notification_old_signature_throws_deprecated_warning_but_sends() {1283 public function test_wp_new_user_notification_old_signature_throws_deprecated_warning_but_sends() { 1284 1284 reset_phpmailer_instance(); 1285 1285 … … 1306 1306 * @ticket 34377 1307 1307 */ 1308 function test_wp_new_user_notification_old_signature_no_password() {1308 public function test_wp_new_user_notification_old_signature_no_password() { 1309 1309 reset_phpmailer_instance(); 1310 1310 … … 1331 1331 * @ticket 40015 1332 1332 */ 1333 function test_new_admin_email_notification_html_entities_decoded() {1333 public function test_new_admin_email_notification_html_entities_decoded() { 1334 1334 reset_phpmailer_instance(); 1335 1335 … … 1364 1364 * @dataProvider data_user_admin_email_confirmation_emails 1365 1365 */ 1366 function test_new_admin_email_confirmation_not_sent_when_email_invalid( $email, $message ) {1366 public function test_new_admin_email_confirmation_not_sent_when_email_invalid( $email, $message ) { 1367 1367 reset_phpmailer_instance(); 1368 1368 … … 1384 1384 * } 1385 1385 */ 1386 function data_user_admin_email_confirmation_emails() {1386 public function data_user_admin_email_confirmation_emails() { 1387 1387 return array( 1388 1388 array( … … 1405 1405 * @dataProvider data_user_change_email_confirmation_emails 1406 1406 */ 1407 function test_profile_email_confirmation_not_sent_invalid_email( $email, $message ) {1407 public function test_profile_email_confirmation_not_sent_invalid_email( $email, $message ) { 1408 1408 1409 1409 $old_current = get_current_user_id(); … … 1448 1448 * } 1449 1449 */ 1450 function data_user_change_email_confirmation_emails() {1450 public function data_user_change_email_confirmation_emails() { 1451 1451 return array( 1452 1452 array( … … 1471 1471 * @ticket 42766 1472 1472 */ 1473 function test_edit_user_blank_password() {1473 public function test_edit_user_blank_password() { 1474 1474 $_POST = array(); 1475 1475 $_GET = array(); … … 1545 1545 * Check passwords action for test_edit_user_blank_password(). 1546 1546 */ 1547 function action_check_passwords_blank_password( $user_login, &$pass1 ) {1547 public function action_check_passwords_blank_password( $user_login, &$pass1 ) { 1548 1548 $pass1 = ''; 1549 1549 } … … 1552 1552 * @ticket 16470 1553 1553 */ 1554 function test_send_confirmation_on_profile_email() {1554 public function test_send_confirmation_on_profile_email() { 1555 1555 reset_phpmailer_instance(); 1556 1556 $was_confirmation_email_sent = false; … … 1587 1587 * @ticket 16470 1588 1588 */ 1589 function test_remove_send_confirmation_on_profile_email() {1589 public function test_remove_send_confirmation_on_profile_email() { 1590 1590 remove_action( 'personal_options_update', 'send_confirmation_on_profile_email' ); 1591 1591 … … 1627 1627 * @ticket 40015 1628 1628 */ 1629 function test_send_confirmation_on_profile_email_html_entities_decoded() {1629 public function test_send_confirmation_on_profile_email_html_entities_decoded() { 1630 1630 $user_id = self::factory()->user->create( 1631 1631 array( … … 1663 1663 * @ticket 42564 1664 1664 */ 1665 function test_edit_user_role_update() {1665 public function test_edit_user_role_update() { 1666 1666 $_POST = array(); 1667 1667 $_GET = array(); … … 1706 1706 * @ticket 43547 1707 1707 */ 1708 function test_wp_user_personal_data_exporter_no_user() {1708 public function test_wp_user_personal_data_exporter_no_user() { 1709 1709 $actual = wp_user_personal_data_exporter( 'not-a-user-email@test.com' ); 1710 1710 … … 1723 1723 * @ticket 43547 1724 1724 */ 1725 function test_wp_user_personal_data_exporter() {1725 public function test_wp_user_personal_data_exporter() { 1726 1726 $test_user = new WP_User( self::$contrib_id ); 1727 1727 … … 1743 1743 * @ticket 43921 1744 1744 */ 1745 function test_wp_community_events_location_ip_personal_data_exporter() {1745 public function test_wp_community_events_location_ip_personal_data_exporter() { 1746 1746 $test_user = new WP_User( self::$contrib_id ); 1747 1747 … … 1767 1767 * @ticket 43921 1768 1768 */ 1769 function test_wp_community_events_location_city_personal_data_exporter() {1769 public function test_wp_community_events_location_city_personal_data_exporter() { 1770 1770 $test_user = new WP_User( self::$contrib_id ); 1771 1771 … … 1809 1809 * @ticket 45889 1810 1810 */ 1811 function test_wp_session_tokens_personal_data_exporter() {1811 public function test_wp_session_tokens_personal_data_exporter() { 1812 1812 $test_user = new WP_User( self::$contrib_id ); 1813 1813 … … 1925 1925 * @ticket 47509 1926 1926 */ 1927 function test_filter_wp_privacy_additional_user_profile_data() {1927 public function test_filter_wp_privacy_additional_user_profile_data() { 1928 1928 $test_user = new WP_User( self::$contrib_id ); 1929 1929
Note: See TracChangeset
for help on using the changeset viewer.