Changeset 30719
- Timestamp:
- 12/03/2014 05:51:33 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/multisite/site.php
r30715 r30719 883 883 */ 884 884 function test_get_blog_id_from_url() { 885 $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); 886 $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id, 'path' => '/testdomainexists', 'title' => 'Test Title' ) ); 887 885 $blog_id = $this->factory->blog->create( array( 'path' => '/xyz', 'title' => 'Test Title' ) ); 888 886 $details = get_blog_details( $blog_id, false ); 889 887 $key = md5( $details->domain . $details->path ); … … 892 890 $this->assertEquals( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) ); 893 891 $this->assertEquals( $blog_id, wp_cache_get( $key, 'blog-id-cache' ) ); 894 895 // Test the case insensitivity of the site lookup. 896 $this->assertEquals( $blog_id, get_blog_id_from_url( strtoupper( $details->domain ) , strtoupper( $details->path ) ) ); 897 898 // Test the first and cached responses for a non existent site. 892 } 893 894 /** 895 * Test the case insensitivity of the site lookup. 896 */ 897 function test_get_blog_id_from_url_is_case_insensitive() { 898 $blog_id = $this->factory->blog->create( array( 'path' => '/xyz', 'title' => 'Test Title' ) ); 899 $details = get_blog_details( $blog_id, false ); 900 901 $this->assertEquals( $blog_id, get_blog_id_from_url( strtoupper( $details->domain ), strtoupper( $details->path ) ) ); 902 } 903 904 /** 905 * Test the first and cached responses for a site that does not exist. 906 */ 907 function test_get_blog_id_from_url_that_does_not_exist() { 908 $blog_id = $this->factory->blog->create( array( 'path' => '/xyz', 'title' => 'Test Title' ) ); 909 $details = get_blog_details( $blog_id, false ); 910 899 911 $this->assertEquals( 0, get_blog_id_from_url( $details->domain, 'foo' ) ); 900 912 $this->assertEquals( -1, wp_cache_get( md5( $details->domain . 'foo' ), 'blog-id-cache' ) ); 901 902 // A blog ID is still available if only the 'deleted' flag is set for a site. 913 } 914 915 /** 916 * A blog ID is still available if only the `deleted` flag is set for a site. The same 917 * behavior would be expected if passing `false` explicitly to `wpmu_delete_blog()`. 918 */ 919 function test_get_blog_id_from_url_with_deleted_flag() { 920 $blog_id = $this->factory->blog->create( array( 'path' => '/xyz', 'title' => 'Test Title' ) ); 921 $details = get_blog_details( $blog_id, false ); 922 $key = md5( $details->domain . $details->path ); 903 923 wpmu_delete_blog( $blog_id ); 924 904 925 $this->assertEquals( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) ); 905 926 $this->assertEquals( $blog_id, wp_cache_get( $key, 'blog-id-cache' ) ); 906 907 // Explicitly pass $drop = false (default), a blog ID will still be available. 908 wpmu_delete_blog( $blog_id, false ); 909 $this->assertEquals( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) ); 910 $this->assertEquals( $blog_id, wp_cache_get( $key, 'blog-id-cache' ) ); 911 912 // When deleted with the drop parameter at true, the cache will first be false, and then 913 // set to -1 after an attempt at get_blog_id_from_url() is made. 927 } 928 929 /** 930 * When deleted with the drop parameter as true, the cache will first be false, then set to 931 * -1 after an attempt at `get_blog_id_from_url()` is made. 932 */ 933 function test_get_blog_id_from_url_after_dropped() { 934 $blog_id = $this->factory->blog->create( array( 'path' => '/xyz', 'title' => 'Test Title' ) ); 935 $details = get_blog_details( $blog_id, false ); 936 $key = md5( $details->domain . $details->path ); 914 937 wpmu_delete_blog( $blog_id, true ); 938 915 939 $this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) ); 916 940 $this->assertEquals( 0, get_blog_id_from_url( $details->domain, $details->path ) );
Note: See TracChangeset
for help on using the changeset viewer.