Moved test specific logic from bootstrap to test file

This commit is contained in:
vedanshujain 2020-05-02 00:27:17 +05:30
parent 28fd8850fa
commit f4e169f21e
2 changed files with 5 additions and 9 deletions

View File

@ -44,15 +44,6 @@ class WC_Unit_Tests_Bootstrap {
$this->plugin_dir = dirname( dirname( $this->tests_dir ) );
$this->wp_tests_dir = getenv( 'WP_TESTS_DIR' ) ? getenv( 'WP_TESTS_DIR' ) : sys_get_temp_dir() . '/wordpress-tests-lib';
if ( ! defined( 'WP_PLUGIN_DIR' ) ) {
define( 'WP_PLUGIN_DIR', $this->plugin_dir );
}
if ( file_exists( WP_PLUGIN_DIR . '/sample-woo-plugin.php' ) ) {
unlink( WP_PLUGIN_DIR . '/sample-woo-plugin.php' );
}
copy( __DIR__ . '/data/sample-woo-plugin.php', WP_PLUGIN_DIR . '/sample-woo-plugin.php' );
// load test function so tests_add_filter() is available.
require_once $this->wp_tests_dir . '/includes/functions.php';

View File

@ -20,6 +20,11 @@ class WC_Tests_WC_Helper extends WC_Unit_Test_Case {
wp_clean_plugins_cache( false );
get_plugins();
if ( file_exists( WP_PLUGIN_DIR . '/sample-woo-plugin.php' ) ) {
unlink( WP_PLUGIN_DIR . '/sample-woo-plugin.php' );
}
copy( WC_Unit_Tests_Bootstrap::instance()->tests_dir . '/data/sample-woo-plugin.php', WP_PLUGIN_DIR . '/sample-woo-plugin.php' );
add_filter( 'extra_plugin_headers', 'wc_enable_wc_plugin_headers' );
$woo_plugins = WC_Helper::get_local_woo_plugins();