Changeset 30114
- Timestamp:
- 10/30/2014 05:43:31 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/multisite/site.php
r30106 r30114 1015 1015 } 1016 1016 1017 /** 1018 * Added as a callback to the domain_exists filter to provide manual results for 1019 * the testing of the filter and for a test which does not need the database. 1020 */ 1017 1021 function _domain_exists_cb( $exists, $domain, $path, $site_id ) { 1018 1022 if ( 'foo' == $domain && 'bar/' == $path ) … … 1022 1026 } 1023 1027 1024 function test_domain_exists() { 1025 $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); 1026 $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id, 'path' => '/testdomainexists', 'title' => 'Test Title' ) ); 1027 1028 $details = get_blog_details( $blog_id, false ); 1029 1030 $this->assertEquals( $blog_id, domain_exists( $details->domain, $details->path ) ); 1031 $this->assertEquals( $blog_id, domain_exists( $details->domain, $details->path, $details->site_id ) ); 1028 function test_domain_exists_with_default_site_id() { 1029 $details = get_blog_details( 1, false ); 1030 1031 $this->assertEquals( 1, domain_exists( $details->domain, $details->path ) ); 1032 } 1033 1034 function test_domain_exists_with_specified_site_id() { 1035 $details = get_blog_details( 1, false ); 1036 1037 $this->assertEquals( 1, domain_exists( $details->domain, $details->path, $details->site_id ) ); 1038 } 1039 1040 /** 1041 * When the domain is valid, but the resulting site does not belong to the specified network, 1042 * it is marked as not existing. 1043 */ 1044 function test_domain_does_not_exist_with_invalid_site_id() { 1045 $details = get_blog_details( 1, false ); 1046 1032 1047 $this->assertEquals( null, domain_exists( $details->domain, $details->path, 999 ) ); 1048 } 1049 1050 function test_invalid_domain_does_not_exist_with_default_site_id() { 1033 1051 $this->assertEquals( null, domain_exists( 'foo', 'bar' ) ); 1034 1052 } 1053 1054 function test_domain_filtered_to_exist() { 1035 1055 add_filter( 'domain_exists', array( $this, '_domain_exists_cb' ), 10, 4 ); 1056 1036 1057 $this->assertEquals( 1234, domain_exists( 'foo', 'bar' ) ); 1037 $this->assertEquals( null, domain_exists( 'foo', 'baz' ) ); 1038 $this->assertEquals( null, domain_exists( 'bar', 'foo' ) ); 1058 1059 remove_filter( 'domain_exists', array( $this, '_domain_exists_cb' ), 10, 4 ); 1060 } 1061 1062 /** 1063 * When a path is passed to domain_exists, it is immediately trailing slashed. A path 1064 * value with or without the slash should result in the same return value. 1065 */ 1066 function test_slashed_path_in_domain_exists() { 1067 add_filter( 'domain_exists', array( $this, '_domain_exists_cb' ), 10, 4 ); 1039 1068 1040 1069 // Make sure the same result is returned with or without a trailing slash … … 1042 1071 1043 1072 remove_filter( 'domain_exists', array( $this, '_domain_exists_cb' ), 10, 4 ); 1044 $this->assertEquals( null, domain_exists( 'foo', 'bar' ) );1045 1046 wpmu_delete_blog( $blog_id );1047 $this->assertEquals( $blog_id, domain_exists( $details->domain, $details->path ) );1048 wpmu_delete_blog( $blog_id, true );1049 $this->assertEquals( null, domain_exists( $details->domain, $details->path ) );1050 1073 } 1051 1074 }
Note: See TracChangeset
for help on using the changeset viewer.