73eee04d38
Most of our unit tests that involve permalinks expect non-pretty permalinks; this is the default setting for WP. However, when the test suite installs multisite, `populate_network()` is run before WP recogizes itself as multisite, which leads to pretty permalinks being set. This breaks a number of unit tests in ways that are difficult to trace. git-svn-id: https://develop.svn.wordpress.org/trunk@30267 602fd350-edb4-49c9-b593-d223f7449a82
61 lines
1.7 KiB
PHP
61 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* Installs WordPress for the purpose of the unit-tests
|
|
*
|
|
* @todo Reuse the init/load code in init.php
|
|
*/
|
|
error_reporting( E_ALL & ~E_DEPRECATED & ~E_STRICT );
|
|
|
|
$config_file_path = $argv[1];
|
|
$multisite = ! empty( $argv[2] );
|
|
|
|
define( 'WP_INSTALLING', true );
|
|
require_once $config_file_path;
|
|
require_once dirname( __FILE__ ) . '/functions.php';
|
|
|
|
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
|
|
$_SERVER['HTTP_HOST'] = WP_TESTS_DOMAIN;
|
|
$PHP_SELF = $GLOBALS['PHP_SELF'] = $_SERVER['PHP_SELF'] = '/index.php';
|
|
|
|
require_once ABSPATH . '/wp-settings.php';
|
|
|
|
require_once ABSPATH . '/wp-admin/includes/upgrade.php';
|
|
require_once ABSPATH . '/wp-includes/wp-db.php';
|
|
|
|
// Override the PHPMailer
|
|
global $phpmailer;
|
|
require_once( dirname( __FILE__ ) . '/mock-mailer.php' );
|
|
$phpmailer = new MockPHPMailer();
|
|
|
|
$wpdb->query( 'SET storage_engine = INNODB' );
|
|
$wpdb->select( DB_NAME, $wpdb->dbh );
|
|
|
|
echo "Installing..." . PHP_EOL;
|
|
|
|
foreach ( $wpdb->tables() as $table => $prefixed_table ) {
|
|
$wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" );
|
|
}
|
|
|
|
foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) {
|
|
$wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" );
|
|
|
|
// We need to create references to ms global tables.
|
|
if ( $multisite )
|
|
$wpdb->$table = $prefixed_table;
|
|
}
|
|
|
|
wp_install( WP_TESTS_TITLE, 'admin', WP_TESTS_EMAIL, true, null, 'password' );
|
|
|
|
if ( $multisite ) {
|
|
echo "Installing network..." . PHP_EOL;
|
|
|
|
define( 'WP_INSTALLING_NETWORK', true );
|
|
|
|
$title = WP_TESTS_TITLE . ' Network';
|
|
$subdomain_install = false;
|
|
|
|
install_network();
|
|
populate_network( 1, WP_TESTS_DOMAIN, WP_TESTS_EMAIL, $title, '/', $subdomain_install );
|
|
$wp_rewrite->set_permalink_structure( '' );
|
|
}
|