Skip to content

Commit

Permalink
woocommmerce connector test updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
kidunot89 committed Feb 10, 2021
1 parent 9d911a3 commit f6bb6bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 31 deletions.
23 changes: 5 additions & 18 deletions connectors/class-connector-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );

Expand Down Expand Up @@ -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' );

Expand Down Expand Up @@ -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' ),
Expand Down Expand Up @@ -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'
Expand Down
17 changes: 4 additions & 13 deletions tests/tests/connectors/test-class-connector-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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' )
);
Expand Down Expand Up @@ -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' )
Expand All @@ -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.' );
}
}

0 comments on commit f6bb6bf

Please sign in to comment.