Changeset 43628 for trunk/tests/phpunit/tests/admin/includesSchema.php
- Timestamp:
- 09/05/2018 10:44:02 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/admin/includesSchema.php
r43627 r43628 1 1 <?php 2 // phpcs:ignoreFile WordPress.WP.PreparedSQL.NotPrepared 2 3 3 4 /** … … 7 8 8 9 private static $options; 10 private static $sitemeta; 9 11 10 12 /** … … 15 17 16 18 self::$options = 'testprefix_options'; 17 18 $options = self::$options; 19 self::$sitemeta = 'testprefix_sitemeta'; 20 21 $options = self::$options; 22 $sitemeta = self::$sitemeta; 19 23 20 24 require_once( ABSPATH . 'wp-admin/includes/schema.php' ); … … 35 39 " 36 40 ); 41 $wpdb->query( 42 " 43 CREATE TABLE {$sitemeta} ( 44 meta_id bigint(20) unsigned NOT NULL auto_increment, 45 site_id bigint(20) unsigned NOT NULL default '0', 46 meta_key varchar(255) default NULL, 47 meta_value longtext, 48 PRIMARY KEY (meta_id), 49 KEY meta_key (meta_key({$max_index_length})), 50 KEY site_id (site_id) 51 ) {$charset_collate} 52 " 53 ); 37 54 } 38 55 … … 43 60 global $wpdb; 44 61 45 $options = self::$options; 62 $options = self::$options; 63 $sitemeta = self::$sitemeta; 46 64 47 65 $wpdb->query( "DROP TABLE IF EXISTS {$options}" ); 66 $wpdb->query( "DROP TABLE IF EXISTS {$sitemeta}" ); 48 67 } 49 68 … … 54 73 function test_populate_options( $options, $expected ) { 55 74 global $wpdb; 56 57 remove_all_filters( 'option_admin_email' );58 remove_all_filters( 'pre_option_admin_email' );59 remove_all_filters( 'default_option_admin_email' );60 75 61 76 $orig_options = $wpdb->options; … … 93 108 array( 94 109 array( 95 'posts_per_rss' => 7,96 'rss_use_excerpt' => 1,110 'posts_per_rss' => 7, 111 'rss_use_excerpt' => 1, 97 112 ), 98 113 array( … … 130 145 array( 131 146 array( 132 'rss_0123456789abcdef0123456789abcdef' => '1',147 'rss_0123456789abcdef0123456789abcdef' => '1', 133 148 'rss_0123456789abcdef0123456789abcdef_ts' => '1', 134 149 ), 135 150 array( 136 151 // These options would be obsolete magpie cache data and should never exist. 137 'rss_0123456789abcdef0123456789abcdef' => false,152 'rss_0123456789abcdef0123456789abcdef' => false, 138 153 'rss_0123456789abcdef0123456789abcdef_ts' => false, 139 154 ), … … 141 156 ); 142 157 } 158 159 /** 160 * @ticket 44895 161 * @dataProvider data_populate_network_meta 162 */ 163 function test_populate_network_meta( $meta, $expected ) { 164 global $wpdb; 165 166 $orig_sitemeta = $wpdb->sitemeta; 167 $wpdb->sitemeta = self::$sitemeta; 168 169 populate_network_meta( 42, $meta ); 170 171 $results = array(); 172 foreach ( $expected as $meta_key => $value ) { 173 if ( is_multisite() ) { 174 $results[ $meta_key ] = get_network_option( 42, $meta_key ); 175 } else { 176 $results[ $meta_key ] = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $meta_key, 42 ) ); 177 } 178 } 179 180 $wpdb->query( "TRUNCATE TABLE {$wpdb->sitemeta}" ); 181 182 $wpdb->sitemeta = $orig_sitemeta; 183 184 $this->assertEquals( $expected, $results ); 185 } 186 187 public function data_populate_network_meta() { 188 return array( 189 array( 190 array(), 191 array( 192 // Random meta to check. 193 'registration' => 'none', 194 'blog_upload_space' => 100, 195 'fileupload_maxk' => 1500, 196 ), 197 ), 198 array( 199 array( 200 'site_name' => 'My Great Network', 201 'WPLANG' => 'fr_FR', 202 ), 203 array( 204 // Random meta to check. 205 'site_name' => 'My Great Network', 206 'registration' => 'none', 207 'blog_upload_space' => 100, 208 'fileupload_maxk' => 1500, 209 'WPLANG' => 'fr_FR', 210 ), 211 ), 212 array( 213 array( 214 'custom_meta' => '1', 215 ), 216 array( 217 // Random meta to check. 218 'custom_meta' => '1', 219 'registration' => 'none', 220 'blog_upload_space' => 100, 221 'fileupload_maxk' => 1500, 222 ), 223 ), 224 ); 225 } 143 226 }
Note: See TracChangeset
for help on using the changeset viewer.