* Fix vendor scripts and test bootstrapping

* Escape the downloaded file URL in tests

* Generate feature config file for tests

* Run feature config generation before and after script tests
This commit is contained in:
Joshua T Flowers 2019-09-25 14:20:15 -04:00 committed by Darren Ethier
parent 1d8d0df790
commit c70c7bfd68
4 changed files with 6 additions and 8 deletions

View File

@ -3,10 +3,10 @@
if [ $1 == 'before' ]; then
cd "$WP_CORE_DIR/wp-content/plugins/woocommerce-admin/"
npm run build:feature-config
if [[ ${RUN_PHPCS} == 1 ]]; then
composer install
else
npm run build:feature-config
composer install --no-dev
fi

View File

@ -7,8 +7,6 @@
* @package WC_Admin\Functions
*/
defined( 'ABSPATH' ) || exit;
use \Automattic\WooCommerce\Admin\Loader;
/**

View File

@ -92,7 +92,7 @@ class WC_Tests_API_Reports_Downloads extends WC_REST_Unit_Test_Case {
$this->assertEquals( $this->user, $download_report['user_id'] );
$this->assertEquals( '1.2.3.4', $download_report['ip_address'] );
$this->assertEquals( 'help.png', $download_report['file_name'] );
$this->assertEquals( plugin_dir_url( __FILE__ ) . 'assets/images/help.png', $download_report['file_path'] );
$this->assertEquals( esc_url( plugin_dir_url( __FILE__ ) . 'assets/images/help.png' ), $download_report['file_path'] );
}
/**
@ -170,7 +170,7 @@ class WC_Tests_API_Reports_Downloads extends WC_REST_Unit_Test_Case {
$id = $object->save();
WC_Helper_Queue::run_all_pending();
return array(
'time' => $time,
'product_1' => $product_1,

View File

@ -111,10 +111,9 @@ require_once dirname( __FILE__ ) . '/framework/helpers/class-wc-test-action-queu
require_once dirname( __FILE__ ) . '/framework/helpers/class-wc-helper-queue.php';
/**
* Set the environment and feature flags to 'develop' when running tests, instead of what is set in the generated `config/feature-flags.php`.
* This matches how we mock the flags in jest.
* Use the `development` features for testing.
*/
function wc_admin_get_feature_config() {
function wc_admin_add_development_features() {
$config = json_decode( file_get_contents( dirname( dirname( __FILE__ ) ) . '/config/development.json' ) ); // @codingStandardsIgnoreLine.
$flags = array();
foreach ( $config->features as $feature => $bool ) {
@ -122,3 +121,4 @@ function wc_admin_get_feature_config() {
}
return $flags;
}
tests_add_filter( 'wc_admin_get_feature_config', 'wc_admin_add_development_features' );