* 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 if [ $1 == 'before' ]; then
cd "$WP_CORE_DIR/wp-content/plugins/woocommerce-admin/" cd "$WP_CORE_DIR/wp-content/plugins/woocommerce-admin/"
npm run build:feature-config
if [[ ${RUN_PHPCS} == 1 ]]; then if [[ ${RUN_PHPCS} == 1 ]]; then
composer install composer install
else else
npm run build:feature-config
composer install --no-dev composer install --no-dev
fi fi

View File

@ -7,8 +7,6 @@
* @package WC_Admin\Functions * @package WC_Admin\Functions
*/ */
defined( 'ABSPATH' ) || exit;
use \Automattic\WooCommerce\Admin\Loader; 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( $this->user, $download_report['user_id'] );
$this->assertEquals( '1.2.3.4', $download_report['ip_address'] ); $this->assertEquals( '1.2.3.4', $download_report['ip_address'] );
$this->assertEquals( 'help.png', $download_report['file_name'] ); $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'] );
} }
/** /**

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'; 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`. * Use the `development` features for testing.
* This matches how we mock the flags in jest.
*/ */
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. $config = json_decode( file_get_contents( dirname( dirname( __FILE__ ) ) . '/config/development.json' ) ); // @codingStandardsIgnoreLine.
$flags = array(); $flags = array();
foreach ( $config->features as $feature => $bool ) { foreach ( $config->features as $feature => $bool ) {
@ -122,3 +121,4 @@ function wc_admin_get_feature_config() {
} }
return $flags; return $flags;
} }
tests_add_filter( 'wc_admin_get_feature_config', 'wc_admin_add_development_features' );