Skip to content

Commit bf53c45

Browse files
committed
WooCommerce connector test added.
1 parent 21696dc commit bf53c45

File tree

5 files changed

+332
-48
lines changed

5 files changed

+332
-48
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"wpackagist-plugin/advanced-custom-fields": "5.8.12",
2626
"wpackagist-plugin/easy-digital-downloads": "^2.9.23",
2727
"wpackagist-plugin/user-switching": "^1.5.5",
28+
"wpackagist-plugin/woocommerce": "^4.4",
2829
"wpsh/local": "^0.2.3"
2930
},
3031
"config": {

composer.lock

Lines changed: 69 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<php>
1111
<const
1212
name="WP_TEST_ACTIVATED_PLUGINS"
13-
value="advanced-custom-fields/acf.php,easy-digital-downloads/easy-digital-downloads.php,user-switching/user-switching.php"
13+
value="advanced-custom-fields/acf.php,easy-digital-downloads/easy-digital-downloads.php,user-switching/user-switching.php,woocommerce/woocommerce.php"
1414
/>
1515
</php>
1616
<testsuites>

tests/bootstrap.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* @param array $active_plugins
2424
* @return array
2525
*/
26-
function xwp_filter_active_plugins_for_phpunit( $active_plugins ) {
26+
function wp_stream_filter_active_plugins_for_phpunit( $active_plugins ) {
2727
$forced_active_plugins = array();
2828
if ( defined( 'WP_TEST_ACTIVATED_PLUGINS' ) ) {
2929
$forced_active_plugins = preg_split( '/\s*,\s*/', WP_TEST_ACTIVATED_PLUGINS );
@@ -36,8 +36,8 @@ function xwp_filter_active_plugins_for_phpunit( $active_plugins ) {
3636
}
3737
return $active_plugins;
3838
}
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' );
4141

4242
tests_add_filter(
4343
'muplugins_loaded',
@@ -79,6 +79,27 @@ function( $status = false, $args = array(), $url = '') {
7979
);
8080
}
8181

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+
82103
// @see https://core.trac.wordpress.org/browser/trunk/tests/phpunit/includes/bootstrap.php
83104
require $_tests_dir . '/includes/bootstrap.php';
84105

0 commit comments

Comments
 (0)