Enable post data store before running post data store order tests.
This commit is contained in:
parent
ae7d827f22
commit
95f1418261
|
@ -14,6 +14,7 @@ use Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableControlle
|
|||
use Automattic\WooCommerce\Internal\DataStores\Orders\DataSynchronizer;
|
||||
use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore;
|
||||
use Automattic\WooCommerce\Internal\Features\FeaturesController;
|
||||
use Automattic\WooCommerce\Utilities\OrderUtil;
|
||||
use WC_Data_Store;
|
||||
use WC_Mock_Payment_Gateway;
|
||||
use WC_Order;
|
||||
|
@ -187,6 +188,8 @@ class OrderHelper {
|
|||
* @return int Order ID
|
||||
*/
|
||||
public static function create_complex_wp_post_order() {
|
||||
$current_cot_state = OrderUtil::custom_orders_table_usage_is_enabled();
|
||||
self::toggle_cot( false );
|
||||
update_option( 'woocommerce_prices_include_tax', 'yes' );
|
||||
update_option( 'woocommerce_calc_taxes', 'yes' );
|
||||
$uniq_cust_id = wp_generate_password( 10, false );
|
||||
|
@ -256,6 +259,8 @@ class OrderHelper {
|
|||
$order->save();
|
||||
$order->save_meta_data();
|
||||
|
||||
self::toggle_cot( $current_cot_state );
|
||||
|
||||
return $order->get_id();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,40 @@
|
|||
<?php
|
||||
|
||||
use Automattic\WooCommerce\RestApi\UnitTests\Helpers\OrderHelper;
|
||||
use Automattic\WooCommerce\Utilities\OrderUtil;
|
||||
|
||||
//phpcs:disable Squiz.Classes.ClassFileName.NoMatch, Squiz.Classes.ValidClassName.NotCamelCaps -- Legacy class name.
|
||||
/**
|
||||
* Class WC_Order_Data_Store_CPT_Test.
|
||||
*/
|
||||
class WC_Order_Data_Store_CPT_Test extends WC_Unit_Test_Case {
|
||||
/**
|
||||
* Store the COT state before the test.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $prev_cot_state;
|
||||
|
||||
/**
|
||||
* Store the COT state before the test.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->prev_cot_state = OrderUtil::custom_orders_table_usage_is_enabled();
|
||||
OrderHelper::toggle_cot( false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the COT state after the test.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function tearDown(): void {
|
||||
OrderHelper::toggle_cot( $this->prev_cot_state );
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that refund cache are invalidated correctly when refund is deleted.
|
||||
|
@ -131,7 +162,7 @@ class WC_Order_Data_Store_CPT_Test extends WC_Unit_Test_Case {
|
|||
* Legacy getters and setters for props migrated from data stores should be set/reset properly.
|
||||
*/
|
||||
public function test_legacy_getters_setters() {
|
||||
$order_id = \Automattic\WooCommerce\RestApi\UnitTests\Helpers\OrderHelper::create_complex_wp_post_order();
|
||||
$order_id = OrderHelper::create_complex_wp_post_order();
|
||||
$order = wc_get_order( $order_id );
|
||||
$bool_props = array(
|
||||
'_download_permissions_granted' => 'download_permissions_granted',
|
||||
|
|
Loading…
Reference in New Issue