WordPress.org

Make WordPress Core

Changeset 945 in tests


Ignore:
Timestamp:
08/01/12 22:23:41 (3 years ago)
Author:
nacin
Message:

Stop dropping the entire database when running the test suite as it is no longer
necessary to do such heavy-handed cleaning.

When the test suite runs the install script, it will drop all of its own tables.
So, single site plus multisite global tables for whichever prefix is configured.

Change the sample prefix to wptests_ so someone does not accidentally clear out
a wp_ install, and can run them side-by-side.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/install.php

    r925 r945  
    3636    return; 
    3737 
    38 $wpdb->query( 'SET storage_engine = INNODB;' ); 
    39 $wpdb->query( 'DROP DATABASE IF EXISTS '.DB_NAME.";" ); 
    40 $wpdb->query( 'CREATE DATABASE '.DB_NAME.";" ); 
     38$wpdb->query( 'SET storage_engine = INNODB' ); 
    4139$wpdb->select( DB_NAME, $wpdb->dbh ); 
    4240 
    4341echo "Installing…" . PHP_EOL; 
     42 
     43foreach ( $wpdb->tables() as $table => $prefixed_table ) { 
     44    $wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" ); 
     45} 
     46 
     47foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) { 
     48    $wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" ); 
     49 
     50    // We need to create references to ms global tables. 
     51    if ( $multisite ) 
     52        $wpdb->$table = $prefixed_table; 
     53} 
     54 
    4455wp_install( WP_TESTS_TITLE, 'admin', WP_TESTS_EMAIL, true, null, 'password' ); 
    4556 
     
    4859 
    4960    define( 'WP_INSTALLING_NETWORK', true ); 
    50  
    51     // We need to create references to ms global tables. 
    52     foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) 
    53         $wpdb->$table = $prefixed_table; 
    5461 
    5562    $title = WP_TESTS_TITLE . ' Network'; 
  • trunk/wp-tests-config-sample.php

    r890 r945  
    1919 
    2020// WARNING WARNING WARNING! 
    21 // wp-test will DROP ALL TABLES in the database named below. 
     21// These tests will DROP ALL TABLES in the database with the prefix named below. 
    2222// DO NOT use a production database or one that is shared with something else. 
    2323 
     
    3636 
    3737define ( 'WPLANG', '' ); 
    38 $table_prefix  = 'wp_';   // Only numbers, letters, and underscores please! 
     38$table_prefix  = 'wptests_';   // Only numbers, letters, and underscores please! 
Note: See TracChangeset for help on using the changeset viewer.