Changeset 52010 for trunk/tests/phpunit/tests/multisite/site.php
- Timestamp:
- 11/04/2021 03:22:47 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/multisite/site.php
r51587 r52010 18 18 protected static $uninitialized_site_id; 19 19 20 function set_up() {20 public function set_up() { 21 21 global $wpdb; 22 22 parent::set_up(); … … 24 24 } 25 25 26 function tear_down() {26 public function tear_down() { 27 27 global $wpdb; 28 28 $wpdb->suppress_errors( $this->suppress ); … … 89 89 } 90 90 91 function test_switch_restore_blog() {91 public function test_switch_restore_blog() { 92 92 global $_wp_switched_stack, $wpdb; 93 93 … … 137 137 * Test the cache keys and database tables setup through the creation of a site. 138 138 */ 139 function test_created_site_details() {139 public function test_created_site_details() { 140 140 global $wpdb; 141 141 … … 222 222 * When a site is flagged as 'deleted', its data should be cleared from cache. 223 223 */ 224 function test_data_in_cache_after_wpmu_delete_blog_drop_false() {224 public function test_data_in_cache_after_wpmu_delete_blog_drop_false() { 225 225 $blog_id = self::factory()->blog->create(); 226 226 … … 240 240 * When a site is flagged as 'deleted', its data should remain in the database. 241 241 */ 242 function test_data_in_tables_after_wpmu_delete_blog_drop_false() {242 public function test_data_in_tables_after_wpmu_delete_blog_drop_false() { 243 243 global $wpdb; 244 244 … … 263 263 * When a site is fully deleted, its data should be cleared from cache. 264 264 */ 265 function test_data_in_cache_after_wpmu_delete_blog_drop_true() {265 public function test_data_in_cache_after_wpmu_delete_blog_drop_true() { 266 266 $blog_id = self::factory()->blog->create(); 267 267 … … 281 281 * When a site is fully deleted, its data should be removed from the database. 282 282 */ 283 function test_data_in_tables_after_wpmu_delete_blog_drop_true() {283 public function test_data_in_tables_after_wpmu_delete_blog_drop_true() { 284 284 global $wpdb; 285 285 … … 304 304 * When the main site of a network is fully deleted, its data should be cleared from cache. 305 305 */ 306 function test_data_in_cache_after_wpmu_delete_blog_main_site_drop_true() {306 public function test_data_in_cache_after_wpmu_delete_blog_main_site_drop_true() { 307 307 $blog_id = 1; // The main site in our test suite has an ID of 1. 308 308 … … 322 322 * When the main site of a network is fully deleted, its data should remain in the database. 323 323 */ 324 function test_data_in_tables_after_wpmu_delete_blog_main_site_drop_true() {324 public function test_data_in_tables_after_wpmu_delete_blog_main_site_drop_true() { 325 325 global $wpdb; 326 326 … … 345 345 * The site count of a network should change when a site is flagged as 'deleted'. 346 346 */ 347 function test_network_count_after_wpmu_delete_blog_drop_false() {347 public function test_network_count_after_wpmu_delete_blog_drop_false() { 348 348 $blog_id = self::factory()->blog->create(); 349 349 … … 359 359 * The site count of a network should change when a site is fully deleted. 360 360 */ 361 function test_blog_count_after_wpmu_delete_blog_drop_true() {361 public function test_blog_count_after_wpmu_delete_blog_drop_true() { 362 362 $blog_id = self::factory()->blog->create(); 363 363 … … 375 375 * should change with upload directories. 376 376 */ 377 function test_upload_directories_after_multiple_wpmu_delete_blog() {377 public function test_upload_directories_after_multiple_wpmu_delete_blog() { 378 378 $filename = __FUNCTION__ . '.jpg'; 379 379 $contents = __FUNCTION__ . '_contents'; … … 401 401 } 402 402 403 function test_wpmu_update_blogs_date() {403 public function test_wpmu_update_blogs_date() { 404 404 global $wpdb; 405 405 … … 416 416 * Provide a counter to determine that hooks are firing when intended. 417 417 */ 418 function _action_counter_cb() {418 public function action_counter_cb() { 419 419 global $test_action_counter; 420 420 $test_action_counter++; … … 426 426 * @ticket 23405 427 427 */ 428 function test_get_blog_details_when_site_does_not_exist() {428 public function test_get_blog_details_when_site_does_not_exist() { 429 429 // Create an unused site so that we can then assume an invalid site ID. 430 430 $blog_id = self::factory()->blog->create(); … … 452 452 * Updating a field returns the sme value that was passed. 453 453 */ 454 function test_update_blog_status() {454 public function test_update_blog_status() { 455 455 $result = update_blog_status( 1, 'spam', 0 ); 456 456 $this->assertSame( 0, $result ); … … 460 460 * Updating an invalid field returns the same value that was passed. 461 461 */ 462 function test_update_blog_status_invalid_status() {462 public function test_update_blog_status_invalid_status() { 463 463 $result = update_blog_status( 1, 'doesnotexist', 'invalid' ); 464 464 $this->assertSame( 'invalid', $result ); 465 465 } 466 466 467 function test_update_blog_status_make_ham_blog_action() {467 public function test_update_blog_status_make_ham_blog_action() { 468 468 global $test_action_counter; 469 469 $test_action_counter = 0; … … 472 472 update_blog_details( $blog_id, array( 'spam' => 1 ) ); 473 473 474 add_action( 'make_ham_blog', array( $this, ' _action_counter_cb' ), 10 );474 add_action( 'make_ham_blog', array( $this, 'action_counter_cb' ), 10 ); 475 475 update_blog_status( $blog_id, 'spam', 0 ); 476 476 $blog = get_site( $blog_id ); … … 486 486 $this->assertSame( 1, $test_action_counter ); 487 487 488 remove_action( 'make_ham_blog', array( $this, ' _action_counter_cb' ), 10 );489 } 490 491 function test_content_from_spam_blog_is_not_available() {488 remove_action( 'make_ham_blog', array( $this, 'action_counter_cb' ), 10 ); 489 } 490 491 public function test_content_from_spam_blog_is_not_available() { 492 492 $spam_blog_id = self::factory()->blog->create(); 493 493 switch_to_blog( $spam_blog_id ); … … 519 519 } 520 520 521 function test_update_blog_status_make_spam_blog_action() {521 public function test_update_blog_status_make_spam_blog_action() { 522 522 global $test_action_counter; 523 523 $test_action_counter = 0; … … 525 525 $blog_id = self::factory()->blog->create(); 526 526 527 add_action( 'make_spam_blog', array( $this, ' _action_counter_cb' ), 10 );527 add_action( 'make_spam_blog', array( $this, 'action_counter_cb' ), 10 ); 528 528 update_blog_status( $blog_id, 'spam', 1 ); 529 529 $blog = get_site( $blog_id ); … … 539 539 $this->assertSame( 1, $test_action_counter ); 540 540 541 remove_action( 'make_spam_blog', array( $this, ' _action_counter_cb' ), 10 );542 } 543 544 function test_update_blog_status_archive_blog_action() {541 remove_action( 'make_spam_blog', array( $this, 'action_counter_cb' ), 10 ); 542 } 543 544 public function test_update_blog_status_archive_blog_action() { 545 545 global $test_action_counter; 546 546 $test_action_counter = 0; … … 548 548 $blog_id = self::factory()->blog->create(); 549 549 550 add_action( 'archive_blog', array( $this, ' _action_counter_cb' ), 10 );550 add_action( 'archive_blog', array( $this, 'action_counter_cb' ), 10 ); 551 551 update_blog_status( $blog_id, 'archived', 1 ); 552 552 $blog = get_site( $blog_id ); … … 562 562 $this->assertSame( 1, $test_action_counter ); 563 563 564 remove_action( 'archive_blog', array( $this, ' _action_counter_cb' ), 10 );565 } 566 567 function test_update_blog_status_unarchive_blog_action() {564 remove_action( 'archive_blog', array( $this, 'action_counter_cb' ), 10 ); 565 } 566 567 public function test_update_blog_status_unarchive_blog_action() { 568 568 global $test_action_counter; 569 569 $test_action_counter = 0; … … 572 572 update_blog_details( $blog_id, array( 'archived' => 1 ) ); 573 573 574 add_action( 'unarchive_blog', array( $this, ' _action_counter_cb' ), 10 );574 add_action( 'unarchive_blog', array( $this, 'action_counter_cb' ), 10 ); 575 575 update_blog_status( $blog_id, 'archived', 0 ); 576 576 $blog = get_site( $blog_id ); … … 585 585 $this->assertSame( 1, $test_action_counter ); 586 586 587 remove_action( 'unarchive_blog', array( $this, ' _action_counter_cb' ), 10 );588 } 589 590 function test_update_blog_status_make_delete_blog_action() {587 remove_action( 'unarchive_blog', array( $this, 'action_counter_cb' ), 10 ); 588 } 589 590 public function test_update_blog_status_make_delete_blog_action() { 591 591 global $test_action_counter; 592 592 $test_action_counter = 0; … … 594 594 $blog_id = self::factory()->blog->create(); 595 595 596 add_action( 'make_delete_blog', array( $this, ' _action_counter_cb' ), 10 );596 add_action( 'make_delete_blog', array( $this, 'action_counter_cb' ), 10 ); 597 597 update_blog_status( $blog_id, 'deleted', 1 ); 598 598 $blog = get_site( $blog_id ); … … 608 608 $this->assertSame( 1, $test_action_counter ); 609 609 610 remove_action( 'make_delete_blog', array( $this, ' _action_counter_cb' ), 10 );611 } 612 613 function test_update_blog_status_make_undelete_blog_action() {610 remove_action( 'make_delete_blog', array( $this, 'action_counter_cb' ), 10 ); 611 } 612 613 public function test_update_blog_status_make_undelete_blog_action() { 614 614 global $test_action_counter; 615 615 $test_action_counter = 0; … … 618 618 update_blog_details( $blog_id, array( 'deleted' => 1 ) ); 619 619 620 add_action( 'make_undelete_blog', array( $this, ' _action_counter_cb' ), 10 );620 add_action( 'make_undelete_blog', array( $this, 'action_counter_cb' ), 10 ); 621 621 update_blog_status( $blog_id, 'deleted', 0 ); 622 622 $blog = get_site( $blog_id ); … … 632 632 $this->assertSame( 1, $test_action_counter ); 633 633 634 remove_action( 'make_undelete_blog', array( $this, ' _action_counter_cb' ), 10 );635 } 636 637 function test_update_blog_status_mature_blog_action() {634 remove_action( 'make_undelete_blog', array( $this, 'action_counter_cb' ), 10 ); 635 } 636 637 public function test_update_blog_status_mature_blog_action() { 638 638 global $test_action_counter; 639 639 $test_action_counter = 0; … … 641 641 $blog_id = self::factory()->blog->create(); 642 642 643 add_action( 'mature_blog', array( $this, ' _action_counter_cb' ), 10 );643 add_action( 'mature_blog', array( $this, 'action_counter_cb' ), 10 ); 644 644 update_blog_status( $blog_id, 'mature', 1 ); 645 645 $blog = get_site( $blog_id ); … … 655 655 $this->assertSame( 1, $test_action_counter ); 656 656 657 remove_action( 'mature_blog', array( $this, ' _action_counter_cb' ), 10 );658 } 659 660 function test_update_blog_status_unmature_blog_action() {657 remove_action( 'mature_blog', array( $this, 'action_counter_cb' ), 10 ); 658 } 659 660 public function test_update_blog_status_unmature_blog_action() { 661 661 global $test_action_counter; 662 662 $test_action_counter = 0; … … 665 665 update_blog_details( $blog_id, array( 'mature' => 1 ) ); 666 666 667 add_action( 'unmature_blog', array( $this, ' _action_counter_cb' ), 10 );667 add_action( 'unmature_blog', array( $this, 'action_counter_cb' ), 10 ); 668 668 update_blog_status( $blog_id, 'mature', 0 ); 669 669 … … 679 679 $this->assertSame( 1, $test_action_counter ); 680 680 681 remove_action( 'unmature_blog', array( $this, ' _action_counter_cb' ), 10 );682 } 683 684 function test_update_blog_status_update_blog_public_action() {681 remove_action( 'unmature_blog', array( $this, 'action_counter_cb' ), 10 ); 682 } 683 684 public function test_update_blog_status_update_blog_public_action() { 685 685 global $test_action_counter; 686 686 $test_action_counter = 0; … … 688 688 $blog_id = self::factory()->blog->create(); 689 689 690 add_action( 'update_blog_public', array( $this, ' _action_counter_cb' ), 10 );690 add_action( 'update_blog_public', array( $this, 'action_counter_cb' ), 10 ); 691 691 update_blog_status( $blog_id, 'public', 0 ); 692 692 … … 702 702 $this->assertSame( 1, $test_action_counter ); 703 703 704 remove_action( 'update_blog_public', array( $this, ' _action_counter_cb' ), 10 );704 remove_action( 'update_blog_public', array( $this, 'action_counter_cb' ), 10 ); 705 705 } 706 706 … … 708 708 * @ticket 27952 709 709 */ 710 function test_posts_count() {710 public function test_posts_count() { 711 711 self::factory()->post->create(); 712 712 $post2 = self::factory()->post->create(); … … 720 720 * @ticket 26410 721 721 */ 722 function test_blog_details_cache_invalidation() {722 public function test_blog_details_cache_invalidation() { 723 723 update_option( 'blogname', 'foo' ); 724 724 $details = get_site( get_current_blog_id() ); … … 734 734 * the blog ID is requested through get_blog_id_from_url(). 735 735 */ 736 function test_get_blog_id_from_url() {736 public function test_get_blog_id_from_url() { 737 737 $blog_id = self::factory()->blog->create(); 738 738 $details = get_site( $blog_id ); … … 747 747 * Test the case insensitivity of the site lookup. 748 748 */ 749 function test_get_blog_id_from_url_is_case_insensitive() {749 public function test_get_blog_id_from_url_is_case_insensitive() { 750 750 $blog_id = self::factory()->blog->create( 751 751 array( … … 762 762 * Test the first and cached responses for a site that does not exist. 763 763 */ 764 function test_get_blog_id_from_url_that_does_not_exist() {764 public function test_get_blog_id_from_url_that_does_not_exist() { 765 765 $blog_id = self::factory()->blog->create( array( 'path' => '/xyz' ) ); 766 766 $details = get_site( $blog_id ); … … 774 774 * behavior would be expected if passing `false` explicitly to `wpmu_delete_blog()`. 775 775 */ 776 function test_get_blog_id_from_url_with_deleted_flag() {776 public function test_get_blog_id_from_url_with_deleted_flag() { 777 777 $blog_id = self::factory()->blog->create(); 778 778 $details = get_site( $blog_id ); … … 788 788 * -1 after an attempt at `get_blog_id_from_url()` is made. 789 789 */ 790 function test_get_blog_id_from_url_after_dropped() {790 public function test_get_blog_id_from_url_after_dropped() { 791 791 $blog_id = self::factory()->blog->create(); 792 792 $details = get_site( $blog_id ); … … 802 802 * Test with default parameter of site_id as null. 803 803 */ 804 function test_is_main_site() {804 public function test_is_main_site() { 805 805 $this->assertTrue( is_main_site() ); 806 806 } … … 810 810 * default parameter tested above. 811 811 */ 812 function test_current_blog_id_is_main_site() {812 public function test_current_blog_id_is_main_site() { 813 813 $this->assertTrue( is_main_site( get_current_blog_id() ) ); 814 814 } … … 817 817 * Test with a site ID other than the main site to ensure a false response. 818 818 */ 819 function test_is_main_site_is_false_with_other_blog_id() {819 public function test_is_main_site_is_false_with_other_blog_id() { 820 820 $blog_id = self::factory()->blog->create(); 821 821 … … 826 826 * Test with no passed ID after switching to another site ID. 827 827 */ 828 function test_is_main_site_is_false_after_switch_to_blog() {828 public function test_is_main_site_is_false_after_switch_to_blog() { 829 829 $blog_id = self::factory()->blog->create(); 830 830 switch_to_blog( $blog_id ); … … 835 835 } 836 836 837 function test_switch_upload_dir() {837 public function test_switch_upload_dir() { 838 838 $this->assertTrue( is_main_site() ); 839 839 … … 868 868 * another site on the network. 869 869 */ 870 function test_get_blog_post_from_another_site_on_network() {870 public function test_get_blog_post_from_another_site_on_network() { 871 871 $blog_id = self::factory()->blog->create(); 872 872 $post_id = self::factory()->post->create(); // Create a post on the primary site, ID 1. … … 883 883 * If get_blog_post() is used on the same site, it should still work. 884 884 */ 885 function test_get_blog_post_from_same_site() {885 public function test_get_blog_post_from_same_site() { 886 886 $post_id = self::factory()->post->create(); 887 887 … … 892 892 * A null response should be returned if an invalid post is requested. 893 893 */ 894 function test_get_blog_post_invalid_returns_null() {894 public function test_get_blog_post_invalid_returns_null() { 895 895 $this->assertNull( get_blog_post( 1, 999999 ) ); 896 896 } … … 900 900 * the testing of the filter and for a test which does not need the database. 901 901 */ 902 function _domain_exists_cb( $exists, $domain, $path, $site_id ) {902 public function domain_exists_cb( $exists, $domain, $path, $site_id ) { 903 903 if ( 'foo' === $domain && 'bar/' === $path ) { 904 904 return 1234; … … 908 908 } 909 909 910 function test_domain_exists_with_default_site_id() {910 public function test_domain_exists_with_default_site_id() { 911 911 $details = get_site( 1 ); 912 912 … … 914 914 } 915 915 916 function test_domain_exists_with_specified_site_id() {916 public function test_domain_exists_with_specified_site_id() { 917 917 $details = get_site( 1 ); 918 918 … … 924 924 * it is marked as not existing. 925 925 */ 926 function test_domain_does_not_exist_with_invalid_site_id() {926 public function test_domain_does_not_exist_with_invalid_site_id() { 927 927 $details = get_site( 1 ); 928 928 … … 930 930 } 931 931 932 function test_invalid_domain_does_not_exist_with_default_site_id() {932 public function test_invalid_domain_does_not_exist_with_default_site_id() { 933 933 $this->assertNull( domain_exists( 'foo', 'bar' ) ); 934 934 } 935 935 936 function test_domain_filtered_to_exist() {937 add_filter( 'domain_exists', array( $this, ' _domain_exists_cb' ), 10, 4 );936 public function test_domain_filtered_to_exist() { 937 add_filter( 'domain_exists', array( $this, 'domain_exists_cb' ), 10, 4 ); 938 938 $exists = domain_exists( 'foo', 'bar' ); 939 remove_filter( 'domain_exists', array( $this, ' _domain_exists_cb' ), 10, 4 );939 remove_filter( 'domain_exists', array( $this, 'domain_exists_cb' ), 10, 4 ); 940 940 $this->assertSame( 1234, $exists ); 941 941 } … … 945 945 * value with or without the slash should result in the same return value. 946 946 */ 947 function test_slashed_path_in_domain_exists() {948 add_filter( 'domain_exists', array( $this, ' _domain_exists_cb' ), 10, 4 );947 public function test_slashed_path_in_domain_exists() { 948 add_filter( 'domain_exists', array( $this, 'domain_exists_cb' ), 10, 4 ); 949 949 $exists1 = domain_exists( 'foo', 'bar' ); 950 950 $exists2 = domain_exists( 'foo', 'bar/' ); 951 remove_filter( 'domain_exists', array( $this, ' _domain_exists_cb' ), 10, 4 );951 remove_filter( 'domain_exists', array( $this, 'domain_exists_cb' ), 10, 4 ); 952 952 953 953 // Make sure the same result is returned with or without a trailing slash. … … 958 958 * Tests returning an address for a given valid ID. 959 959 */ 960 function test_get_blogaddress_by_id_with_valid_id() {960 public function test_get_blogaddress_by_id_with_valid_id() { 961 961 $blogaddress = get_blogaddress_by_id( 1 ); 962 962 $this->assertSame( 'http://' . WP_TESTS_DOMAIN . '/', $blogaddress ); … … 966 966 * Tests returning the appropriate response for a invalid id given. 967 967 */ 968 function test_get_blogaddress_by_id_with_invalid_id() {968 public function test_get_blogaddress_by_id_with_invalid_id() { 969 969 $blogaddress = get_blogaddress_by_id( 42 ); 970 970 $this->assertSame( '', $blogaddress ); … … 974 974 * @ticket 14867 975 975 */ 976 function test_get_blogaddress_by_id_scheme_reflects_blog_scheme() {976 public function test_get_blogaddress_by_id_scheme_reflects_blog_scheme() { 977 977 $blog = self::factory()->blog->create(); 978 978 … … 987 987 * @ticket 14867 988 988 */ 989 function test_get_blogaddress_by_id_scheme_is_unaffected_by_request() {989 public function test_get_blogaddress_by_id_scheme_is_unaffected_by_request() { 990 990 $blog = self::factory()->blog->create(); 991 991 … … 1006 1006 * @dataProvider data_new_blog_url_schemes 1007 1007 */ 1008 function test_new_blog_url_schemes( $home_scheme, $siteurl_scheme, $force_ssl_admin ) {1008 public function test_new_blog_url_schemes( $home_scheme, $siteurl_scheme, $force_ssl_admin ) { 1009 1009 $current_site = get_current_site(); 1010 1010 … … 1032 1032 } 1033 1033 1034 function data_new_blog_url_schemes() {1034 public function data_new_blog_url_schemes() { 1035 1035 return array( 1036 1036 array( … … 1065 1065 * @ticket 36918 1066 1066 */ 1067 function test_new_blog_locale() {1067 public function test_new_blog_locale() { 1068 1068 $current_site = get_current_site(); 1069 1069 … … 1100 1100 * @ticket 40503 1101 1101 */ 1102 function test_different_network_language() {1102 public function test_different_network_language() { 1103 1103 $network = get_network( self::$network_ids['make.wordpress.org/'] ); 1104 1104 … … 1121 1121 * @return string The orginal value. 1122 1122 */ 1123 function filter_allow_unavailable_languages( $value, $option, $original_value ) {1123 public function filter_allow_unavailable_languages( $value, $option, $original_value ) { 1124 1124 return $original_value; 1125 1125 }
Note: See TracChangeset
for help on using the changeset viewer.