2020-05-01 17:17:08 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class WC_Tests_WC_Helper.
|
|
|
|
*/
|
2020-05-15 04:04:11 +00:00
|
|
|
class WC_Helper_Test extends \WC_Unit_Test_Case {
|
2020-05-01 17:17:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test that woo plugins are loaded correctly even if incorrect cache is intially set.
|
|
|
|
*/
|
|
|
|
public function test_get_local_woo_plugins_without_woo_header_cache() {
|
|
|
|
$woocommerce_key = 'sample-woo-plugin.php';
|
|
|
|
|
|
|
|
remove_filter( 'extra_plugin_headers', 'wc_enable_wc_plugin_headers' );
|
|
|
|
wp_clean_plugins_cache( false );
|
|
|
|
get_plugins();
|
|
|
|
|
2020-05-01 18:57:17 +00:00
|
|
|
if ( file_exists( WP_PLUGIN_DIR . '/sample-woo-plugin.php' ) ) {
|
|
|
|
unlink( WP_PLUGIN_DIR . '/sample-woo-plugin.php' );
|
|
|
|
}
|
2020-05-05 13:49:37 +00:00
|
|
|
copy( \WC_Unit_Tests_Bootstrap::instance()->tests_dir . '/data/sample-woo-plugin.php', WP_PLUGIN_DIR . '/sample-woo-plugin.php' );
|
2020-05-01 18:57:17 +00:00
|
|
|
|
2020-05-01 17:17:08 +00:00
|
|
|
add_filter( 'extra_plugin_headers', 'wc_enable_wc_plugin_headers' );
|
|
|
|
|
2020-05-05 13:49:37 +00:00
|
|
|
$woo_plugins = \WC_Helper::get_local_woo_plugins();
|
2020-05-01 17:17:08 +00:00
|
|
|
|
|
|
|
// Restore previous state.
|
|
|
|
wp_clean_plugins_cache( false );
|
|
|
|
|
|
|
|
$this->assertArrayHasKey( $woocommerce_key, $woo_plugins );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|