Skip to content

Commit

Permalink
WooCommerce connector test added.
Browse files Browse the repository at this point in the history
  • Loading branch information
kidunot89 committed Feb 10, 2021
1 parent 21696dc commit bf53c45
Show file tree
Hide file tree
Showing 5 changed files with 332 additions and 48 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"wpackagist-plugin/advanced-custom-fields": "5.8.12",
"wpackagist-plugin/easy-digital-downloads": "^2.9.23",
"wpackagist-plugin/user-switching": "^1.5.5",
"wpackagist-plugin/woocommerce": "^4.4",
"wpsh/local": "^0.2.3"
},
"config": {
Expand Down
113 changes: 69 additions & 44 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<php>
<const
name="WP_TEST_ACTIVATED_PLUGINS"
value="advanced-custom-fields/acf.php,easy-digital-downloads/easy-digital-downloads.php,user-switching/user-switching.php"
value="advanced-custom-fields/acf.php,easy-digital-downloads/easy-digital-downloads.php,user-switching/user-switching.php,woocommerce/woocommerce.php"
/>
</php>
<testsuites>
Expand Down
27 changes: 24 additions & 3 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @param array $active_plugins
* @return array
*/
function xwp_filter_active_plugins_for_phpunit( $active_plugins ) {
function wp_stream_filter_active_plugins_for_phpunit( $active_plugins ) {
$forced_active_plugins = array();
if ( defined( 'WP_TEST_ACTIVATED_PLUGINS' ) ) {
$forced_active_plugins = preg_split( '/\s*,\s*/', WP_TEST_ACTIVATED_PLUGINS );
Expand All @@ -36,8 +36,8 @@ function xwp_filter_active_plugins_for_phpunit( $active_plugins ) {
}
return $active_plugins;
}
tests_add_filter( 'site_option_active_sitewide_plugins', 'xwp_filter_active_plugins_for_phpunit' );
tests_add_filter( 'option_active_plugins', 'xwp_filter_active_plugins_for_phpunit' );
tests_add_filter( 'site_option_active_sitewide_plugins', 'wp_stream_filter_active_plugins_for_phpunit' );
tests_add_filter( 'option_active_plugins', 'wp_stream_filter_active_plugins_for_phpunit' );

tests_add_filter(
'muplugins_loaded',
Expand Down Expand Up @@ -79,6 +79,27 @@ function( $status = false, $args = array(), $url = '') {
);
}

function wp_stream_install_wc() {
WC_Install::install();

// Initialize the WC API extensions.
\Automattic\WooCommerce\Admin\Install::create_tables();
\Automattic\WooCommerce\Admin\Install::create_events();

// Reload capabilities after install, see https://core.trac.wordpress.org/ticket/28374.
if ( version_compare( $GLOBALS['wp_version'], '4.7', '<' ) ) {
$GLOBALS['wp_roles']->reinit();
} else {
$GLOBALS['wp_roles'] = null; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
wp_roles();
}

echo esc_html( 'Installing WooCommerce...' . PHP_EOL );
}

// install WC.
tests_add_filter( 'setup_theme', 'wp_stream_install_wc' );

// @see https://core.trac.wordpress.org/browser/trunk/tests/phpunit/includes/bootstrap.php
require $_tests_dir . '/includes/bootstrap.php';

Expand Down
Loading

0 comments on commit bf53c45

Please sign in to comment.