23
23
* @param array $active_plugins
24
24
* @return array
25
25
*/
26
- function xwp_filter_active_plugins_for_phpunit ( $ active_plugins ) {
26
+ function wp_stream_filter_active_plugins_for_phpunit ( $ active_plugins ) {
27
27
$ forced_active_plugins = array ();
28
28
if ( defined ( 'WP_TEST_ACTIVATED_PLUGINS ' ) ) {
29
29
$ forced_active_plugins = preg_split ( '/\s*,\s*/ ' , WP_TEST_ACTIVATED_PLUGINS );
@@ -36,8 +36,8 @@ function xwp_filter_active_plugins_for_phpunit( $active_plugins ) {
36
36
}
37
37
return $ active_plugins ;
38
38
}
39
- tests_add_filter ( 'site_option_active_sitewide_plugins ' , 'xwp_filter_active_plugins_for_phpunit ' );
40
- tests_add_filter ( 'option_active_plugins ' , 'xwp_filter_active_plugins_for_phpunit ' );
39
+ tests_add_filter ( 'site_option_active_sitewide_plugins ' , 'wp_stream_filter_active_plugins_for_phpunit ' );
40
+ tests_add_filter ( 'option_active_plugins ' , 'wp_stream_filter_active_plugins_for_phpunit ' );
41
41
42
42
tests_add_filter (
43
43
'muplugins_loaded ' ,
@@ -79,6 +79,27 @@ function( $status = false, $args = array(), $url = '') {
79
79
);
80
80
}
81
81
82
+ function wp_stream_install_wc () {
83
+ WC_Install::install ();
84
+
85
+ // Initialize the WC API extensions.
86
+ \Automattic \WooCommerce \Admin \Install::create_tables ();
87
+ \Automattic \WooCommerce \Admin \Install::create_events ();
88
+
89
+ // Reload capabilities after install, see https://core.trac.wordpress.org/ticket/28374.
90
+ if ( version_compare ( $ GLOBALS ['wp_version ' ], '4.7 ' , '< ' ) ) {
91
+ $ GLOBALS ['wp_roles ' ]->reinit ();
92
+ } else {
93
+ $ GLOBALS ['wp_roles ' ] = null ; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
94
+ wp_roles ();
95
+ }
96
+
97
+ echo esc_html ( 'Installing WooCommerce... ' . PHP_EOL );
98
+ }
99
+
100
+ // install WC.
101
+ tests_add_filter ( 'setup_theme ' , 'wp_stream_install_wc ' );
102
+
82
103
// @see https://core.trac.wordpress.org/browser/trunk/tests/phpunit/includes/bootstrap.php
83
104
require $ _tests_dir . '/includes/bootstrap.php ' ;
84
105
0 commit comments