From f5056d37e46d9735833240bda3fdc401c03e5e52 Mon Sep 17 00:00:00 2001 From: vedanshujain Date: Tue, 9 Mar 2021 18:20:24 +0530 Subject: [PATCH] Add expected deprecated call so that we can call setUp for this testcase. --- .../unit-tests/util/deprecated-hooks.php | 51 ++++++++++++------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/tests/legacy/unit-tests/util/deprecated-hooks.php b/tests/legacy/unit-tests/util/deprecated-hooks.php index 8867fe90bb3..50530a5080d 100644 --- a/tests/legacy/unit-tests/util/deprecated-hooks.php +++ b/tests/legacy/unit-tests/util/deprecated-hooks.php @@ -1,44 +1,58 @@ handlers = WC()->deprecated_hook_handlers; @@ -49,7 +63,7 @@ class WC_Tests_Deprecated_Hooks extends WC_Unit_Test_Case { * * @since 3.0 */ - function test_deprecated_hook_handlers_exist() { + public function test_deprecated_hook_handlers_exist() { $this->assertArrayHasKey( 'filters', $this->handlers ); $this->assertInstanceOf( 'WC_Deprecated_Filter_Hooks', $this->handlers['filters'] ); @@ -62,7 +76,7 @@ class WC_Tests_Deprecated_Hooks extends WC_Unit_Test_Case { * * @since 3.0 */ - function test_get_old_hooks() { + public function test_get_old_hooks() { $old_filters = $this->handlers['filters']->get_old_hooks( 'woocommerce_structured_data_order' ); $old_actions = $this->handlers['actions']->get_old_hooks( 'woocommerce_new_order_item' ); @@ -75,7 +89,7 @@ class WC_Tests_Deprecated_Hooks extends WC_Unit_Test_Case { * * @since 3.0 */ - function test_hook_in() { + public function test_hook_in() { $this->assertTrue( (bool) has_filter( 'woocommerce_structured_data_order', array( $this->handlers['filters'], 'maybe_handle_deprecated_hook' ) ) ); $this->assertTrue( (bool) has_action( 'woocommerce_new_order_item', array( $this->handlers['actions'], 'maybe_handle_deprecated_hook' ) ) ); } @@ -85,7 +99,7 @@ class WC_Tests_Deprecated_Hooks extends WC_Unit_Test_Case { * * @since 3.0 */ - function test_handle_deprecated_hook_filter() { + public function test_handle_deprecated_hook_filter() { $new_hook = 'wc_new_hook'; $old_hook = 'wc_old_hook'; $args = array( false ); @@ -102,7 +116,7 @@ class WC_Tests_Deprecated_Hooks extends WC_Unit_Test_Case { * * @since 3.0 */ - function test_handle_deprecated_hook_action() { + public function test_handle_deprecated_hook_action() { $new_hook = 'wc_new_hook'; $old_hook = 'wc_old_hook'; $test_value = false; @@ -120,7 +134,7 @@ class WC_Tests_Deprecated_Hooks extends WC_Unit_Test_Case { * * @since 3.0 */ - function test_filter_handler() { + public function test_filter_handler() { $test_width = 1; add_filter( 'woocommerce_product_width', array( $this, 'toggle_value' ) ); @@ -134,7 +148,7 @@ class WC_Tests_Deprecated_Hooks extends WC_Unit_Test_Case { * * @since 3.0 */ - function test_action_handler() { + public function test_action_handler() { $test_product = WC_Helper_Product::create_simple_product(); $test_order = WC_Helper_Order::create_order( 1, $test_product ); $test_order_id = $test_order->get_id(); @@ -142,6 +156,7 @@ class WC_Tests_Deprecated_Hooks extends WC_Unit_Test_Case { $test_item = reset( $test_items ); $test_item_id = $test_item->get_id(); + $this->setExpectedDeprecated( 'woocommerce_order_edit_product' ); add_action( 'woocommerce_order_edit_product', array( $this, 'set_meta' ), 10, 2 ); do_action( 'woocommerce_update_order_item', $test_item_id, $test_item, $test_order_id ); @@ -157,7 +172,7 @@ class WC_Tests_Deprecated_Hooks extends WC_Unit_Test_Case { * * @since 3.0 */ - function test_created_actions_deprecation() { + public function test_created_actions_deprecation() { add_filter( 'woocommerce_payment_token_created', '__return_true' ); add_filter( 'woocommerce_create_product_variation', '__return_true' );