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 Nov 12, 2020
1 parent 417666d commit 27137cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 27 deletions.
17 changes: 2 additions & 15 deletions connectors/class-connector-woocommerce.php
Original file line number Diff line number Diff line change
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
15 changes: 3 additions & 12 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 Down

0 comments on commit 27137cd

Please sign in to comment.