@@ -92,6 +92,11 @@ class FeatureContext implements SnippetAcceptingContext {
92
92
*/
93
93
private static $ db_type = 'mysql ' ;
94
94
95
+ /**
96
+ * Name of mysql binary to use (mysql or mariadb). Default to mysql
97
+ */
98
+ private static $ mysql_binary = 'mysql ' ;
99
+
95
100
/**
96
101
* Array of background process ids started by the current scenario. Used to terminate them at the end of the scenario.
97
102
*/
@@ -552,6 +557,7 @@ public static function prepare( BeforeSuiteScope $scope ) {
552
557
self ::log_run_times_before_suite ( $ scope );
553
558
}
554
559
self ::$ behat_run_dir = getcwd ();
560
+ self ::$ mysql_binary = Utils \get_mysql_binary_path ();
555
561
556
562
$ result = Process::create ( 'wp cli info ' , null , self ::get_process_env_variables () )->run_check ();
557
563
echo "{$ result ->stdout }\n" ;
@@ -603,6 +609,12 @@ public function beforeScenario( BeforeScenarioScope $scope ) {
603
609
self ::get_behat_internal_variables ()
604
610
);
605
611
612
+ $ mysql_binary = Utils \get_mysql_binary_path ();
613
+ $ sql_dump_command = Utils \get_sql_dump_command ();
614
+
615
+ $ this ->variables ['MYSQL_BINARY ' ] = $ mysql_binary ;
616
+ $ this ->variables ['SQL_DUMP_COMMAND ' ] = $ sql_dump_command ;
617
+
606
618
// Used in the names of the RUN_DIR and SUITE_CACHE_DIR directories.
607
619
self ::$ temp_dir_infix = null ;
608
620
$ file = self ::get_event_file ( $ scope , $ line );
@@ -980,15 +992,15 @@ public function create_db() {
980
992
}
981
993
982
994
$ dbname = self ::$ db_settings ['dbname ' ];
983
- self ::run_sql ( ' mysql --no-defaults ' , [ 'execute ' => "CREATE DATABASE IF NOT EXISTS $ dbname " ] );
995
+ self ::run_sql ( self :: $ mysql_binary . ' --no-defaults ' , [ 'execute ' => "CREATE DATABASE IF NOT EXISTS $ dbname " ] );
984
996
}
985
997
986
998
public function drop_db () {
987
999
if ( 'sqlite ' === self ::$ db_type ) {
988
1000
return ;
989
1001
}
990
1002
$ dbname = self ::$ db_settings ['dbname ' ];
991
- self ::run_sql ( ' mysql --no-defaults ' , [ 'execute ' => "DROP DATABASE IF EXISTS $ dbname " ] );
1003
+ self ::run_sql ( self :: $ mysql_binary . ' --no-defaults ' , [ 'execute ' => "DROP DATABASE IF EXISTS $ dbname " ] );
992
1004
}
993
1005
994
1006
public function proc ( $ command , $ assoc_args = [], $ path = '' ) {
@@ -1149,7 +1161,7 @@ public function install_wp( $subdir = '' ) {
1149
1161
// Disable WP Cron by default to avoid bogus HTTP requests in CLI context.
1150
1162
$ config_extra_php = "if ( ! defined( 'DISABLE_WP_CRON' ) ) { define( 'DISABLE_WP_CRON', true ); } \n" ;
1151
1163
1152
- if ( 'mysql ' = == self ::$ db_type ) {
1164
+ if ( 'sqlite ' ! == self ::$ db_type ) {
1153
1165
$ this ->create_db ();
1154
1166
}
1155
1167
$ this ->create_run_dir ();
@@ -1179,7 +1191,7 @@ public function install_wp( $subdir = '' ) {
1179
1191
if ( 'sqlite ' === self ::$ db_type ) {
1180
1192
copy ( "{$ install_cache_path }.sqlite " , "$ run_dir/wp-content/database/.ht.sqlite " );
1181
1193
} else {
1182
- self ::run_sql ( ' mysql --no-defaults ' , [ 'execute ' => "source {$ install_cache_path }.sql " ], true /*add_database*/ );
1194
+ self ::run_sql ( self :: $ mysql_binary . ' --no-defaults ' , [ 'execute ' => "source {$ install_cache_path }.sql " ], true /*add_database*/ );
1183
1195
}
1184
1196
} else {
1185
1197
$ this ->proc ( 'wp core install ' , $ install_args , $ subdir )->run_check ();
@@ -1189,8 +1201,9 @@ public function install_wp( $subdir = '' ) {
1189
1201
1190
1202
self ::dir_diff_copy ( $ run_dir , self ::$ cache_dir , $ install_cache_path );
1191
1203
1192
- if ( 'mysql ' === self ::$ db_type ) {
1193
- $ mysqldump_binary = Utils \force_env_on_nix_systems ( 'mysqldump ' );
1204
+ if ( 'sqlite ' !== self ::$ db_type ) {
1205
+ $ mysqldump_binary = Utils \get_sql_dump_command ();
1206
+ $ mysqldump_binary = Utils \force_env_on_nix_systems ( $ mysqldump_binary );
1194
1207
$ support_column_statistics = exec ( "{$ mysqldump_binary } --help | grep 'column-statistics' " );
1195
1208
$ command = "{$ mysqldump_binary } --no-defaults --no-tablespaces " ;
1196
1209
if ( $ support_column_statistics ) {
0 commit comments