From 13dfb8180fb9ee2541d0f6d09ff6b55a281951e2 Mon Sep 17 00:00:00 2001 From: vedanshujain Date: Fri, 1 May 2020 22:47:08 +0530 Subject: [PATCH] Add unit test and a sample Woo plugin file --- sample-woo-plugin.php | 6 ++++ tests/legacy/bootstrap.php | 9 +++++ tests/legacy/data/sample-woo-plugin.php | 6 ++++ .../admin/helper/class-tests-wc-helper.php | 33 +++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 sample-woo-plugin.php create mode 100644 tests/legacy/data/sample-woo-plugin.php create mode 100644 tests/php/includes/admin/helper/class-tests-wc-helper.php diff --git a/sample-woo-plugin.php b/sample-woo-plugin.php new file mode 100644 index 00000000000..2810783a3cf --- /dev/null +++ b/sample-woo-plugin.php @@ -0,0 +1,6 @@ +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/legacy/data/sample-woo-plugin.php b/tests/legacy/data/sample-woo-plugin.php new file mode 100644 index 00000000000..2810783a3cf --- /dev/null +++ b/tests/legacy/data/sample-woo-plugin.php @@ -0,0 +1,6 @@ +assertArrayHasKey( $woocommerce_key, $woo_plugins ); + } + +}