From f4e169f21e2c4bee3c17c0160ac2b1b4cc21cff5 Mon Sep 17 00:00:00 2001 From: vedanshujain Date: Sat, 2 May 2020 00:27:17 +0530 Subject: [PATCH] Moved test specific logic from bootstrap to test file --- tests/legacy/bootstrap.php | 9 --------- .../php/includes/admin/helper/class-tests-wc-helper.php | 5 +++++ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/legacy/bootstrap.php b/tests/legacy/bootstrap.php index f841d0660de..c0a91df0ec3 100644 --- a/tests/legacy/bootstrap.php +++ b/tests/legacy/bootstrap.php @@ -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'; diff --git a/tests/php/includes/admin/helper/class-tests-wc-helper.php b/tests/php/includes/admin/helper/class-tests-wc-helper.php index 2ebc01b581b..8778c48773f 100644 --- a/tests/php/includes/admin/helper/class-tests-wc-helper.php +++ b/tests/php/includes/admin/helper/class-tests-wc-helper.php @@ -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();