Changeset 41715
- Timestamp:
- 10/03/2017 06:20:37 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/multisite/site.php
r41661 r41715 1058 1058 $this->assertFalse( is_main_site( self::$site_ids['make.wordpress.org/foo/'], self::$network_ids['make.wordpress.org/'] ) ); 1059 1059 } 1060 1061 /** 1062 * @ticket 40201 1063 * @dataProvider data_get_site_caches 1064 */ 1065 public function test_clean_blog_cache( $key, $group ) { 1066 $site = get_site( self::$site_ids['make.wordpress.org/'] ); 1067 1068 $replacements = array( 1069 '%blog_id%' => $site->blog_id, 1070 '%domain%' => $site->domain, 1071 '%path%' => $site->path, 1072 '%domain_path_key%' => md5( $site->domain . $site->path ), 1073 ); 1074 1075 $key = str_replace( array_keys( $replacements ), array_values( $replacements ), $key ); 1076 1077 if ( 'sites' === $group ) { // This needs to be actual data for get_site() lookups. 1078 wp_cache_set( $key, (object) $site->to_array(), $group ); 1079 } else { 1080 wp_cache_set( $key, 'something', $group ); 1081 } 1082 1083 clean_blog_cache( $site ); 1084 $this->assertFalse( wp_cache_get( $key, $group ) ); 1085 } 1086 1087 /** 1088 * @ticket 40201 1089 */ 1090 public function test_clean_blog_cache_resets_last_changed() { 1091 $site = get_site( self::$site_ids['make.wordpress.org/'] ); 1092 1093 wp_cache_delete( 'last_changed', 'sites' ); 1094 1095 clean_blog_cache( $site ); 1096 $this->assertNotFalse( wp_cache_get( 'last_changed', 'sites' ) ); 1097 } 1098 1099 /** 1100 * @ticket 40201 1101 */ 1102 public function test_clean_blog_cache_fires_action() { 1103 $site = get_site( self::$site_ids['make.wordpress.org/'] ); 1104 1105 $old_count = did_action( 'clean_site_cache' ); 1106 1107 clean_blog_cache( $site ); 1108 $this->assertEquals( $old_count + 1, did_action( 'clean_site_cache' ) ); 1109 } 1110 1111 /** 1112 * @ticket 40201 1113 */ 1114 public function test_clean_blog_cache_bails_on_suspend_cache_invalidation() { 1115 $site = get_site( self::$site_ids['make.wordpress.org/'] ); 1116 1117 $old_count = did_action( 'clean_site_cache' ); 1118 1119 $suspend = wp_suspend_cache_invalidation(); 1120 clean_blog_cache( $site ); 1121 wp_suspend_cache_invalidation( $suspend ); 1122 $this->assertEquals( $old_count, did_action( 'clean_site_cache' ) ); 1123 } 1124 1125 /** 1126 * @ticket 40201 1127 * @dataProvider data_get_site_caches 1128 */ 1129 public function test_refresh_blog_details( $key, $group ) { 1130 $site = get_site( self::$site_ids['make.wordpress.org/'] ); 1131 1132 $replacements = array( 1133 '%blog_id%' => $site->blog_id, 1134 '%domain%' => $site->domain, 1135 '%path%' => $site->path, 1136 '%domain_path_key%' => md5( $site->domain . $site->path ), 1137 ); 1138 1139 $key = str_replace( array_keys( $replacements ), array_values( $replacements ), $key ); 1140 1141 if ( 'sites' === $group ) { // This needs to be actual data for get_site() lookups. 1142 wp_cache_set( $key, (object) $site->to_array(), $group ); 1143 } else { 1144 wp_cache_set( $key, 'something', $group ); 1145 } 1146 1147 refresh_blog_details( $site->blog_id ); 1148 $this->assertFalse( wp_cache_get( $key, $group ) ); 1149 } 1150 1151 /** 1152 * @ticket 40201 1153 */ 1154 public function test_refresh_blog_details_works_with_deleted_site() { 1155 $site_id = 12345; 1156 1157 wp_cache_set( $site_id, 'something', 'site-details' ); 1158 1159 refresh_blog_details( $site_id ); 1160 $this->assertFalse( wp_cache_get( $site_id, 'site-details' ) ); 1161 } 1162 1163 /** 1164 * @ticket 40201 1165 */ 1166 public function test_refresh_blog_details_uses_current_site_as_default() { 1167 $site_id = get_current_blog_id(); 1168 1169 wp_cache_set( $site_id, 'something', 'site-details' ); 1170 1171 refresh_blog_details(); 1172 $this->assertFalse( wp_cache_get( $site_id, 'site-details' ) ); 1173 } 1174 1175 public function data_get_site_caches() { 1176 return array( 1177 array( '%blog_id%', 'sites' ), 1178 array( '%blog_id%', 'site-details' ), 1179 array( '%blog_id%', 'blog-details' ), 1180 array( '%blog_id%' . 'short' , 'blog-details' ), 1181 array( '%domain_path_key%', 'blog-lookup' ), 1182 array( '%domain_path_key%', 'blog-id-cache' ), 1183 array( 'current_blog_%domain%', 'site-options' ), 1184 array( 'current_blog_%domain%%path%', 'site-options' ), 1185 ); 1186 } 1060 1187 } 1061 1188
Note: See TracChangeset
for help on using the changeset viewer.