WordPress.org

Make WordPress Core

Changeset 839 in tests


Ignore:
Timestamp:
07/01/12 22:10:46 (2 years ago)
Author:
nacin
Message:

Fix multisite installation and initialization. The factory should be used instead of any default blogs. see #100.

Location:
trunk
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/install.php

    r760 r839  
    2727 
    2828$wpdb->suppress_errors(); 
    29 $wpdb->hide_errors(); 
    3029$installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" ); 
     30$wpdb->suppress_errors( false ); 
    3131 
    32 if ( $installed && file_exists( WP_TESTS_VERSION_FILE ) ) { 
    33     $installed_version_hash = file_get_contents( WP_TESTS_VERSION_FILE ); 
    34     if ( $installed_version_hash == test_version_check_hash() ) { 
     32$hash = get_option( 'db_version' ) . ' ' . sha1( file_get_contents( $config_file_path ) ); 
     33 
     34if ( $installed && file_exists( WP_TESTS_VERSION_FILE ) && file_get_contents( WP_TESTS_VERSION_FILE ) == $hash ) 
    3535        return; 
    36     } 
    37 } 
     36 
    3837$wpdb->query( 'SET storage_engine = INNODB;' ); 
    3938$wpdb->query( 'DROP DATABASE IF EXISTS '.DB_NAME.";" ); 
     
    4241 
    4342echo "Installing…" . PHP_EOL; 
    44 wp_install( WP_TESTS_TITLE, 'admin', WP_TESTS_EMAIL, true, '', 'a' ); 
     43wp_install( WP_TESTS_TITLE, 'admin', WP_TESTS_EMAIL, true, null, 'password' ); 
    4544 
    46 if ( defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE ) { 
    47     echo "Installing network…" .PHP_EOL; 
     45if ( defined( 'WP_TESTS_MULTISITE' ) && WP_TESTS_MULTISITE ) { 
     46    echo "Installing network…" . PHP_EOL; 
    4847 
    4948    define( 'WP_INSTALLING_NETWORK', true ); 
    50     //wp_set_wpdb_vars(); 
    51     // We need to create references to ms global tables to enable Network. 
     49 
     50    // We need to create references to ms global tables. 
    5251    foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) 
    5352        $wpdb->$table = $prefixed_table; 
     53 
     54    $title = WP_TESTS_TITLE . ' Network'; 
     55    $subdomain_install = false; 
     56 
    5457    install_network(); 
    55     $result = populate_network(1, WP_TESTS_DOMAIN, WP_TESTS_EMAIL, WP_TESTS_NETWORK_TITLE, '/', WP_TESTS_SUBDOMAIN_INSTALL); 
    56  
    57     system( WP_PHP_BINARY . ' ' . escapeshellarg( dirname( __FILE__ ) . '/ms-install.php' ) . ' ' . escapeshellarg( $config_file_path ) ); 
    58  
     58    populate_network( 1, WP_TESTS_DOMAIN, WP_TESTS_EMAIL, $title, '/', $subdomain_install ); 
    5959} 
    6060 
    61 file_put_contents( WP_TESTS_VERSION_FILE, test_version_check_hash() ); 
     61file_put_contents( WP_TESTS_VERSION_FILE, $hash ); 
  • trunk/bootstrap.php

    r833 r839  
    3131system( WP_PHP_BINARY . ' ' . escapeshellarg( dirname( __FILE__ ) . '/bin/install.php' ) . ' ' . escapeshellarg( $config_file_path ) ); 
    3232 
     33if ( defined( 'WP_TESTS_MULTISITE' ) && WP_TESTS_MULTISITE ) { 
     34    define( 'MULTISITE', true ); 
     35    define( 'SUBDOMAIN_INSTALL', false ); 
     36    define( 'DOMAIN_CURRENT_SITE', WP_TESTS_DOMAIN ); 
     37    define( 'PATH_CURRENT_SITE', '/' ); 
     38    define( 'SITE_ID_CURRENT_SITE', 1 ); 
     39    define( 'BLOG_ID_CURRENT_SITE', 1 ); 
     40    $GLOBALS['base'] = '/'; 
     41} 
     42 
    3343require dirname( __FILE__ ) . '/wp-testlib/functions.php'; 
    3444 
  • trunk/wp-testlib/functions.php

    r807 r839  
    11<?php 
    2 /** 
    3  * Generate a hash to be used when comparing installed version against 
    4  * codebase and current configuration 
    5  * @return string $hash sha1 hash 
    6  **/ 
    7 function test_version_check_hash() { 
    8     $hash = ''; 
    9     $db_version = get_option( 'db_version' ); 
    10     if ( defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE ) { 
    11         $version = $db_version; 
    12         if( defined( 'WP_TESTS_BLOGS' ) ) { 
    13             $version .= WP_TESTS_BLOGS; 
    14         } 
    15         if( defined( 'WP_TESTS_SUBDOMAIN_INSTALL' ) ) { 
    16             $version .= WP_TESTS_SUBDOMAIN_INSTALL; 
    17         } 
    18         if( defined( 'WP_TESTS_DOMAIN' ) ) { 
    19             $version .= WP_TESTS_DOMAIN; 
    20         } 
    21  
    22     } else { 
    23         $version = $db_version; 
    24     } 
    25  
    26     return sha1($version); 
    27 } 
    282 
    293// For adding hooks before loading WP 
Note: See TracChangeset for help on using the changeset viewer.