Fix failing WP nightly test (#34743)
* Fix failing by initializing properties. 1. wc_core_dir was earlier being initialized in by WC_Admin bootstrap file, after the monorepo merge, this is no longer needed and can be replaced by WC_ABSPATH directly. (Since WooCommerce core is not being mounted in a different folder). 2. $user was usually unintialized, but it still worked since when passing null it will autoset to 1. This is modified to either not handle this explicitly, and/or not pass any value when default is fine. * Add changelog.
This commit is contained in:
parent
8af6b7bff0
commit
b9f1f57e43
|
@ -0,0 +1,5 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
Comment: Only unit tests are slightly modified to accommodate undefined props for $user and $wc_core_dir.
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ class WC_Tests_Paypal_Gateway_Request extends WC_Unit_Test_Case {
|
|||
// Create products.
|
||||
$this->create_products( $product_count );
|
||||
|
||||
$this->order = WC_Helper_Order::create_order( $this->user );
|
||||
$this->order = WC_Helper_Order::create_order();
|
||||
$this->add_products_to_order( $this->order, $product_prices );
|
||||
|
||||
// Set payment method to Paypal.
|
||||
|
|
|
@ -53,7 +53,7 @@ class WC_Admin_Tests_API_Data extends WC_REST_Unit_Test_Case {
|
|||
WC_Helper_Reports::reset_stats_dbs();
|
||||
|
||||
$prod_download = new WC_Product_Download();
|
||||
$prod_download->set_file( plugin_dir_url( $this->wc_core_dir ) . 'woocommerce/assets/images/help.png' );
|
||||
$prod_download->set_file( plugin_dir_url( WC_ABSPATH ) . 'woocommerce/assets/images/help.png' );
|
||||
$prod_download->set_id( '1' );
|
||||
|
||||
$product = new WC_Product_Simple();
|
||||
|
|
|
@ -49,7 +49,7 @@ class WC_Admin_Tests_API_Reports_Downloads_Stats extends WC_REST_Unit_Test_Case
|
|||
|
||||
// Populate all of the data.
|
||||
$prod_download = new WC_Product_Download();
|
||||
$prod_download->set_file( plugin_dir_url( $this->wc_core_dir ) . 'woocommerce/assets/images/help.png' );
|
||||
$prod_download->set_file( plugin_dir_url( WC_ABSPATH ) . 'woocommerce/assets/images/help.png' );
|
||||
$prod_download->set_id( '1' );
|
||||
|
||||
$product = new WC_Product_Simple();
|
||||
|
@ -136,7 +136,7 @@ class WC_Admin_Tests_API_Reports_Downloads_Stats extends WC_REST_Unit_Test_Case
|
|||
|
||||
// First set of data.
|
||||
$prod_download = new WC_Product_Download();
|
||||
$prod_download->set_file( plugin_dir_url( $this->wc_core_dir ) . 'woocommerce/assets/images/help.png' );
|
||||
$prod_download->set_file( plugin_dir_url( WC_ABSPATH ) . 'woocommerce/assets/images/help.png' );
|
||||
$prod_download->set_id( '2' );
|
||||
|
||||
$product = new WC_Product_Simple();
|
||||
|
@ -231,7 +231,7 @@ class WC_Admin_Tests_API_Reports_Downloads_Stats extends WC_REST_Unit_Test_Case
|
|||
|
||||
// Populate all of the data.
|
||||
$prod_download = new WC_Product_Download();
|
||||
$prod_download->set_file( plugin_dir_url( $this->wc_core_dir ) . 'woocommerce/assets/images/help.png' );
|
||||
$prod_download->set_file( plugin_dir_url( WC_ABSPATH ) . 'woocommerce/assets/images/help.png' );
|
||||
$prod_download->set_id( '3' );
|
||||
|
||||
$product = new WC_Product_Simple();
|
||||
|
|
|
@ -106,7 +106,7 @@ class WC_Admin_Tests_API_Reports_Downloads extends WC_REST_Unit_Test_Case {
|
|||
|
||||
// First set of data.
|
||||
$prod_download = new WC_Product_Download();
|
||||
$prod_download->set_file( plugin_dir_url( $this->wc_core_dir ) . 'woocommerce/assets/images/help.png' );
|
||||
$prod_download->set_file( plugin_dir_url( WC_ABSPATH ) . 'woocommerce/assets/images/help.png' );
|
||||
$prod_download->set_id( '2' );
|
||||
|
||||
$product = new WC_Product_Simple();
|
||||
|
@ -138,7 +138,7 @@ class WC_Admin_Tests_API_Reports_Downloads extends WC_REST_Unit_Test_Case {
|
|||
|
||||
// Second set of data.
|
||||
$prod_download = new WC_Product_Download();
|
||||
$prod_download->set_file( plugin_dir_url( $this->wc_core_dir ) . 'woocommerce/assets/images/help.png' );
|
||||
$prod_download->set_file( plugin_dir_url( WC_ABSPATH ) . 'woocommerce/assets/images/help.png' );
|
||||
$prod_download->set_id( '3' );
|
||||
|
||||
$product = new WC_Product_Simple();
|
||||
|
|
|
@ -56,7 +56,7 @@ class WC_Admin_Tests_API_Reports_Performance_Indicators extends WC_REST_Unit_Tes
|
|||
|
||||
// Populate all of the data. We'll create an order and a download.
|
||||
$prod_download = new WC_Product_Download();
|
||||
$prod_download->set_file( plugin_dir_url( $this->wc_core_dir ) . 'woocommerce/assets/images/help.png' );
|
||||
$prod_download->set_file( plugin_dir_url( WC_ABSPATH ) . 'woocommerce/assets/images/help.png' );
|
||||
$prod_download->set_id( '1' );
|
||||
|
||||
$product = new WC_Product_Simple();
|
||||
|
|
|
@ -21,6 +21,11 @@ class WC_Admin_Tests_PaymentGatewaySuggestions_Init extends WC_Unit_Test_Case {
|
|||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->user = $this->factory->user->create(
|
||||
array(
|
||||
'role' => 'administrator',
|
||||
)
|
||||
);
|
||||
delete_option( 'woocommerce_show_marketplace_suggestions' );
|
||||
add_filter(
|
||||
'transient_woocommerce_admin_' . PaymentGatewaySuggestionsDataSourcePoller::ID . '_specs',
|
||||
|
|
Loading…
Reference in New Issue