You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: bin/install-package-tests
+13-7Lines changed: 13 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,7 @@
4
4
# - WP_CLI_TEST_DBHOST is the host to use and can include a port, i.e "127.0.0.1:33060" (defaults to "localhost")
5
5
# - WP_CLI_TEST_DBROOTUSER is the user that has permission to administer databases and users (defaults to "root").
6
6
# - WP_CLI_TEST_DBROOTPASS is the password to use for the above user (defaults to an empty password).
7
+
# - WP_CLI_TEST_DBNAME is the database that the tests run under (defaults to "wp_cli_test").
7
8
# - WP_CLI_TEST_DBUSER is the user that the tests run under (defaults to "wp_cli_test").
8
9
# - WP_CLI_TEST_DBPASS is the password to use for the above user (defaults to "password1").
9
10
@@ -31,6 +32,11 @@ if [ -n "$WP_CLI_TEST_DBROOTPASS" ]; then
31
32
PASSWORD_STRING="-p$WP_CLI_TEST_DBROOTPASS"
32
33
fi
33
34
35
+
TEST_DB=wp_cli_test
36
+
if [ -n"$WP_CLI_TEST_DBNAME" ];then
37
+
TEST_DB="$WP_CLI_TEST_DBNAME"
38
+
fi
39
+
34
40
TEST_USER=wp_cli_test
35
41
if [ -n"$WP_CLI_TEST_DBUSER" ];then
36
42
TEST_USER="$WP_CLI_TEST_DBUSER"
@@ -44,18 +50,18 @@ fi
44
50
# Prepare the database for running the tests with a MySQL version 8.0 or higher.
45
51
install_mysql_db_8_0_plus() {
46
52
set -ex
47
-
mysql -e "CREATE DATABASE IF NOT EXISTS \`wp_cli_test\`;"$HOST_STRING -u"$USER""$PASSWORD_STRING"
48
-
mysql -e "CREATE USER IF NOT EXISTS \`wp_cli_test\`@'%' IDENTIFIED WITH mysql_native_password BY '$TEST_PASSWORD'"$HOST_STRING -u"$USER""$PASSWORD_STRING"
49
-
mysql -e "GRANT ALL PRIVILEGES ON \`wp_cli_test\`.* TO '$TEST_USER'@'%'"$HOST_STRING -u"$USER""$PASSWORD_STRING"
50
-
mysql -e "GRANT ALL PRIVILEGES ON \`wp_cli_test_scaffold\`.* TO '$TEST_USER'@'%'"$HOST_STRING -u"$USER""$PASSWORD_STRING"
53
+
mysql -e "CREATE DATABASE IF NOT EXISTS \`$TEST_DB\`;"$HOST_STRING -u"$USER""$PASSWORD_STRING"
54
+
mysql -e "CREATE USER IF NOT EXISTS \`$TEST_DB\`@'%' IDENTIFIED WITH mysql_native_password BY '$TEST_PASSWORD'"$HOST_STRING -u"$USER""$PASSWORD_STRING"
55
+
mysql -e "GRANT ALL PRIVILEGES ON \`$TEST_DB\`.* TO '$TEST_USER'@'%'"$HOST_STRING -u"$USER""$PASSWORD_STRING"
56
+
mysql -e "GRANT ALL PRIVILEGES ON \`$TEST_DB_scaffold\`.* TO '$TEST_USER'@'%'"$HOST_STRING -u"$USER""$PASSWORD_STRING"
51
57
}
52
58
53
59
# Prepare the database for running the tests with a MySQL version lower than 8.0.
54
60
install_mysql_db_lower_than_8_0() {
55
61
set -ex
56
-
mysql -e "CREATE DATABASE IF NOT EXISTS \`wp_cli_test\`;"$HOST_STRING -u"$USER""$PASSWORD_STRING"
57
-
mysql -e "GRANT ALL ON \`wp_cli_test\`.* TO '$TEST_USER'@'%' IDENTIFIED BY '$TEST_PASSWORD'"$HOST_STRING -u"$USER""$PASSWORD_STRING"
58
-
mysql -e "GRANT ALL ON \`wp_cli_test_scaffold\`.* TO '$TEST_USER'@'%' IDENTIFIED BY '$TEST_PASSWORD'"$HOST_STRING -u"$USER""$PASSWORD_STRING"
62
+
mysql -e "CREATE DATABASE IF NOT EXISTS \`$TEST_DB\`;"$HOST_STRING -u"$USER""$PASSWORD_STRING"
63
+
mysql -e "GRANT ALL ON \`$TEST_DB\`.* TO '$TEST_USER'@'%' IDENTIFIED BY '$TEST_PASSWORD'"$HOST_STRING -u"$USER""$PASSWORD_STRING"
64
+
mysql -e "GRANT ALL ON \`$TEST_DB_scaffold\`.* TO '$TEST_USER'@'%' IDENTIFIED BY '$TEST_PASSWORD'"$HOST_STRING -u"$USER""$PASSWORD_STRING"
Copy file name to clipboardExpand all lines: src/Context/FeatureContext.php
+47-42Lines changed: 47 additions & 42 deletions
Original file line number
Diff line number
Diff line change
@@ -51,24 +51,24 @@ class FeatureContext implements SnippetAcceptingContext {
51
51
/**
52
52
* The test database settings. All but `dbname` can be set via environment variables. The database is dropped at the start of each scenario and created on a "Given a WP installation" step.
53
53
*/
54
-
privatestatic$db_settings = array(
54
+
privatestatic$db_settings = [
55
55
'dbname' => 'wp_cli_test',
56
56
'dbuser' => 'wp_cli_test',
57
57
'dbpass' => 'password1',
58
58
'dbhost' => '127.0.0.1',
59
-
);
59
+
];
60
60
61
61
/**
62
62
* Array of background process ids started by the current scenario. Used to terminate them at the end of the scenario.
63
63
*/
64
-
private$running_procs = array();
64
+
private$running_procs = [];
65
65
66
66
/**
67
67
* Array of variables available as {VARIABLE_NAME}. Some are always set: CORE_CONFIG_SETTINGS, DB_USER, DB_PASSWORD, DB_HOST, SRC_DIR, CACHE_DIR, WP_VERSION-version-latest.
68
68
* Some are step-dependent: RUN_DIR, SUITE_CACHE_DIR, COMPOSER_LOCAL_REPOSITORY, PHAR_PATH. One is set on use: INVOKE_WP_CLI_WITH_PHP_ARGS-args.
69
69
* Scenarios can define their own variables using "Given save" steps. Variables are reset for each scenario.
70
70
*/
71
-
public$variables = array();
71
+
public$variables = [];
72
72
73
73
/**
74
74
* The current feature file and scenario line number as '<file>.<line>'. Used in RUN_DIR and SUITE_CACHE_DIR directory names. Set at the start of each scenario.
@@ -84,9 +84,9 @@ class FeatureContext implements SnippetAcceptingContext {
84
84
privatestatic$num_top_processes; // Number of processes/methods to output by longest run times. Set on `@BeforeSuite`.
85
85
privatestatic$num_top_scenarios; // Number of scenarios to output by longest run times. Set on `@BeforeSuite`.
86
86
87
-
privatestatic$scenario_run_times = array(); // Scenario run times (top `self::$num_top_scenarios` only).
87
+
privatestatic$scenario_run_times = []; // Scenario run times (top `self::$num_top_scenarios` only).
88
88
privatestatic$scenario_count = 0; // Scenario count, incremented on `@AfterScenario`.
89
-
privatestatic$proc_method_run_times = array(); // Array of run time info for proc methods, keyed by method name and arg, each a 2-element array containing run time and run count.
89
+
privatestatic$proc_method_run_times = []; // Array of run time info for proc methods, keyed by method name and arg, each a 2-element array containing run time and run count.
90
90
91
91
/**
92
92
* Get the path to the Composer vendor folder.
@@ -211,11 +211,11 @@ private static function get_process_env_variables() {
0 commit comments