forked from nb/wordpress-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.php
57 lines (44 loc) · 1.89 KB
/
install.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?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];
define( 'WP_INSTALLING', true );
require_once $config_file_path . '/unittests-config.php';
require_once $config_file_path . '/lib/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';
$wpdb->suppress_errors();
$wpdb->hide_errors();
$wpdb->query( 'SET storage_engine = INNODB;' );
$wpdb->query( 'DROP DATABASE IF EXISTS '.DB_NAME.";" );
$wpdb->query( 'CREATE DATABASE '.DB_NAME.";" );
$wpdb->select( DB_NAME, $wpdb->dbh );
echo "Installing WordPress...\n";
wp_install( WP_TESTS_TITLE, 'admin', WP_TESTS_EMAIL, true, '', 'a' );
if ( defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE ) {
echo "Installing network…\n";
define( 'WP_INSTALLING_NETWORK', true );
//wp_set_wpdb_vars();
// We need to create references to ms global tables to enable Network.
foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table )
$wpdb->$table = $prefixed_table;
install_network();
$result = populate_network(1, WP_TESTS_DOMAIN, WP_TESTS_EMAIL, WP_TESTS_NETWORK_TITLE, ABSPATH, WP_TESTS_SUBDOMAIN_INSTALL);
system( 'php '.escapeshellarg( dirname( __FILE__ ) . '/ms-install.php' ) . ' ' . escapeshellarg( $config_file_path ) );
if ( isset( $wp_test_ms_plugins ) && is_array( $wp_test_ms_plugins ) ) {
echo "Installing network plugins...\n";
wptest_install_plugins($wp_test_ms_plugins);
}
}
if ( isset( $wp_tests_plugins ) && is_array( $wp_tests_plugins ) ) {
echo "Installing site plugins...\n";
wptest_install_plugins($wp_tests_plugins);
}