From f6bb6bfeddea5fb1577b6f0e90d6d786d63ad7d2 Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Thu, 12 Nov 2020 15:31:30 -0500 Subject: [PATCH] woocommmerce connector test updated. --- connectors/class-connector-woocommerce.php | 23 ++++--------------- .../test-class-connector-woocommerce.php | 17 ++++---------- 2 files changed, 9 insertions(+), 31 deletions(-) diff --git a/connectors/class-connector-woocommerce.php b/connectors/class-connector-woocommerce.php index 75fcbbd5a..7fe14c10c 100644 --- a/connectors/class-connector-woocommerce.php +++ b/connectors/class-connector-woocommerce.php @@ -412,7 +412,7 @@ public function callback_transition_post_status( $new, $old, $post ) { $action = 'updated'; } - $order = new \WC_Order( $post->ID ); + $order = \wc_get_order( $post->ID ); $order_title = esc_html__( 'Order number', 'stream' ) . ' ' . esc_html( $order->get_order_number() ); $order_type_name = esc_html__( 'order', 'stream' ); @@ -453,7 +453,7 @@ public function callback_deleted_post( $post_id ) { return; } - $order = new \WC_Order( $post->ID ); + $order = \wc_get_order( $post->ID ); $order_title = esc_html__( 'Order number', 'stream' ) . ' ' . esc_html( $order->get_order_number() ); $order_type_name = esc_html__( 'order', 'stream' ); @@ -505,7 +505,7 @@ public function callback_woocommerce_order_status_changed( $order_id, $old, $new $old_status_name = $old_status->name; } - $order = new \WC_Order( $order_id ); + $order = \wc_get_order( $order_id ); $order_title = sprintf( /* translators: %d: Order number */ __( 'Order number %d', 'stream' ), @@ -660,27 +660,14 @@ public function callback_woocommerce_tax_rate_updated( $tax_rate_id, $tax_rate ) * @param int $tax_rate_id Tax Rate ID. */ public function callback_woocommerce_tax_rate_deleted( $tax_rate_id ) { - global $wpdb; - - $tax_rate_name = $wpdb->get_var( - $wpdb->prepare( - "SELECT tax_rate_name FROM {$wpdb->prefix}woocommerce_tax_rates - WHERE tax_rate_id = %s - ", - $tax_rate_id - ) - ); - $this->log( /* translators: %4$s: a tax rate name (e.g. "GST") */ _x( - '"%s" tax rate deleted', + 'Tax rate identified by ID:"%s" deleted', 'Tax rate name', 'stream' ), - array( - 'tax_rate_name' => $tax_rate_name, - ), + compact( 'tax_rate_id' ), $tax_rate_id, 'tax', 'deleted' diff --git a/tests/tests/connectors/test-class-connector-woocommerce.php b/tests/tests/connectors/test-class-connector-woocommerce.php index 22b66fa79..662b6928b 100644 --- a/tests/tests/connectors/test-class-connector-woocommerce.php +++ b/tests/tests/connectors/test-class-connector-woocommerce.php @@ -461,15 +461,8 @@ public function test_callback_woocommerce_attribute_deleted() { public function test_callback_woocommerce_tax_rate_added() { // Create tax rate array for later use. $tax_rate = array( - 'tax_rate_country' => 'USA', - 'tax_rate_state' => 'Pennsylvania', 'tax_rate' => '10', 'tax_rate_name' => 'test tax rate', - 'tax_rate_priority' => 1, - 'tax_rate_compound' => 1, - 'tax_rate_shipping' => 1, - 'tax_rate_order' => 0, - 'tax_rate_class' => '', ); // Expected log calls @@ -478,7 +471,7 @@ public function test_callback_woocommerce_tax_rate_added() { ->with( $this->equalTo( '"%4$s" tax rate created' ), $this->equalTo( $tax_rate ), - $this->notEqualTo( '' ), + $this->greaterThan( 0 ), $this->equalTo( 'tax' ), $this->equalTo( 'created' ) ); @@ -546,10 +539,8 @@ public function test_callback_woocommerce_tax_rate_deleted() { $this->mock->expects( $this->once() ) ->method( 'log' ) ->with( - $this->equalTo( '"%s" tax rate deleted' ), - $this->equalTo( - array( 'tax_rate_name' => 'test tax rate' ) - ), + $this->equalTo( 'Tax rate identified by ID:"%s" deleted' ), + $this->equalTo( compact( 'tax_rate_id' ) ), $this->equalTo( $tax_rate_id ), $this->equalTo( 'tax' ), $this->equalTo( 'deleted' ) @@ -563,6 +554,6 @@ public function test_callback_woocommerce_tax_rate_deleted() { } public function test_callback_updated_option() { - + $this->markTestSkipped( 'This test needs to be written.' ); } }