setAccessible( true ); $inner_container = $inner_container_property->getValue( wc_get_container() ); $inner_container->replace( LegacyProxy::class, MockableLegacyProxy::class ); $inner_container->reset_all_resolved(); $GLOBALS['wc_container'] = $inner_container; } function wc_load_core() { define( 'WC_TAX_ROUNDING_MODE', 'auto' ); define( 'WC_USE_TRANSACTIONS', false ); echo esc_html( 'Loading WooCommerce plugin' . PHP_EOL ); require_once wc_dir() . '/woocommerce.php'; } function wc_install_core() { // Clean existing install first. define( 'WP_UNINSTALL_PLUGIN', true ); define( 'WC_REMOVE_ALL_DATA', true ); include wc_dir() . '/uninstall.php'; $GLOBALS['wp_roles'] = null; // WPCS: override ok. wp_roles(); echo esc_html( 'Installing WooCommerce Blocks...' . PHP_EOL ); \Automattic\WooCommerce\Blocks\Package::container()->get( \Automattic\WooCommerce\Blocks\Installer::class )->maybe_create_tables(); } /** * Manually load the plugin being tested. */ tests_add_filter( 'muplugins_loaded', function() { define( 'JETPACK_AUTOLOAD_DEV', true ); wc_load_core(); // install blocks plugin wc_blocks_install(); } ); tests_add_filter( 'setup_theme', 'wc_install_core' ); // Start up the WP testing environment. require $_tests_dir . '/includes/bootstrap.php'; wc_test_includes(); wc_blocks_initialize_dependency_injection();