Remove transaction tests
This commit is contained in:
parent
778ccf0606
commit
6fd40d7e37
|
@ -123,6 +123,12 @@ class WC_Tests_Product_Functions extends WC_Unit_Test_Case {
|
|||
$this->assertGreaterThan( 0, $products->max_num_pages );
|
||||
$this->assertNotEmpty( $products->products );
|
||||
|
||||
$product->delete( true );
|
||||
$product_2->delete( true );
|
||||
$external->delete( true );
|
||||
$external_2->delete( true );
|
||||
$grouped->delete( true );
|
||||
$draft->delete( true );
|
||||
$variation->delete( true );
|
||||
}
|
||||
|
||||
|
@ -153,6 +159,9 @@ class WC_Tests_Product_Functions extends WC_Unit_Test_Case {
|
|||
|
||||
$products = wc_get_products( array( 'return' => 'ids', 'weight' => 15 ) );
|
||||
$this->assertEquals( array( $product_2->get_id() ), $products );
|
||||
|
||||
$product_1->delete( true );
|
||||
$product_2->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -181,6 +190,9 @@ class WC_Tests_Product_Functions extends WC_Unit_Test_Case {
|
|||
$products = wc_get_products( array( 'return' => 'ids', 'price' => 12.5 ) );
|
||||
sort( $products );
|
||||
$this->assertEquals( array( $product_1->get_id(), $product_2->get_id() ), $products );
|
||||
|
||||
$product_1->delete( true );
|
||||
$product_2->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -202,6 +214,10 @@ class WC_Tests_Product_Functions extends WC_Unit_Test_Case {
|
|||
|
||||
$products = wc_get_products( array( 'return' => 'ids', 'total_sales' => 4 ) );
|
||||
$this->assertEquals( array( $product_1->get_id() ), $products );
|
||||
|
||||
$product_1->delete( true );
|
||||
$product_2->delete( true );
|
||||
$product_3->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -257,6 +273,9 @@ class WC_Tests_Product_Functions extends WC_Unit_Test_Case {
|
|||
$this->assertEquals( array( $product_1->get_id() ), $products );
|
||||
$products = wc_get_products( array( 'return' => 'ids', 'reviews_allowed' => false ) );
|
||||
$this->assertEquals( array( $product_2->get_id() ), $products );
|
||||
|
||||
$product_1->delete( true );
|
||||
$product_2->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -284,6 +303,10 @@ class WC_Tests_Product_Functions extends WC_Unit_Test_Case {
|
|||
$products = wc_get_products( array( 'return' => 'ids', 'visibility' => 'search' ) );
|
||||
sort( $products );
|
||||
$this->assertEquals( array( $product_1->get_id(), $product_3->get_id() ), $products );
|
||||
|
||||
$product_1->delete( true );
|
||||
$product_2->delete( true );
|
||||
$product_3->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -311,6 +334,9 @@ class WC_Tests_Product_Functions extends WC_Unit_Test_Case {
|
|||
|
||||
$products = wc_get_products( array( 'return' => 'ids', 'stock_status' => 'outofstock' ) );
|
||||
$this->assertEquals( array( $product_2->get_id() ), $products );
|
||||
|
||||
$product_1->delete( true );
|
||||
$product_2->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -336,6 +362,9 @@ class WC_Tests_Product_Functions extends WC_Unit_Test_Case {
|
|||
|
||||
$products = wc_get_products( array( 'return' => 'ids', 'tax_class' => 'reduced-rate' ) );
|
||||
$this->assertEquals( array( $product_1->get_id() ), $products );
|
||||
|
||||
$product_1->delete( true );
|
||||
$product_2->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -359,6 +388,9 @@ class WC_Tests_Product_Functions extends WC_Unit_Test_Case {
|
|||
$this->assertEquals( array( $product_1->get_id() ), $products );
|
||||
$products = wc_get_products( array( 'return' => 'ids', 'shipping_class' => 'standard' ) );
|
||||
$this->assertEquals( array( $product_2->get_id() ), $products );
|
||||
|
||||
$product_1->delete( true );
|
||||
$product_2->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -388,6 +420,9 @@ class WC_Tests_Product_Functions extends WC_Unit_Test_Case {
|
|||
$this->assertEquals( array( $product_1->get_id() ), $products );
|
||||
$products = wc_get_products( array( 'return' => 'ids', 'download_expiry' => -1 ) );
|
||||
$this->assertEquals( array( $product_2->get_id() ), $products );
|
||||
|
||||
$product_1->delete( true );
|
||||
$product_2->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -415,6 +450,9 @@ class WC_Tests_Product_Functions extends WC_Unit_Test_Case {
|
|||
$this->assertEquals( array( $product_1->get_id() ), $products );
|
||||
$products = wc_get_products( array( 'return' => 'ids', 'review_count' => 1 ) );
|
||||
$this->assertEquals( array( $product_2->get_id() ), $products );
|
||||
|
||||
$product_1->delete( true );
|
||||
$product_2->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -654,6 +692,11 @@ class WC_Tests_Product_Functions extends WC_Unit_Test_Case {
|
|||
update_post_meta( $product_4_id, '_sku', 'another-custom-sku' );
|
||||
wc_product_force_unique_sku( $product_4_id );
|
||||
$this->assertEquals( get_post_meta( $product_4_id, '_sku', true ), 'another-custom-sku-2' );
|
||||
|
||||
$product_1->delete( true );
|
||||
$product_2->delete( true );
|
||||
$product_3->delete( true );
|
||||
$product_4->delete( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -588,61 +588,4 @@ class WC_Tests_Core_Functions extends WC_Unit_Test_Case {
|
|||
public function test_wc_rand_hash() {
|
||||
$this->assertNotEquals( wc_rand_hash(), wc_rand_hash() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test wc_transaction_query function.
|
||||
*/
|
||||
public function test_wc_transaction_query() {
|
||||
global $wpdb;
|
||||
|
||||
$wpdb->insert(
|
||||
$wpdb->prefix . 'options',
|
||||
array(
|
||||
'option_name' => 'transaction_test',
|
||||
'option_value' => '1',
|
||||
),
|
||||
array(
|
||||
'%s',
|
||||
'%s',
|
||||
)
|
||||
);
|
||||
wc_transaction_query( 'start' );
|
||||
$this->assertTrue( WC_USE_TRANSACTIONS );
|
||||
$wpdb->update(
|
||||
$wpdb->prefix . 'options',
|
||||
array(
|
||||
'option_value' => '0',
|
||||
),
|
||||
array(
|
||||
'option_name' => 'transaction_test',
|
||||
)
|
||||
);
|
||||
$col = $wpdb->get_col( "SElECT option_value FROM {$wpdb->prefix}options WHERE option_name = 'transaction_test'" );
|
||||
$this->assertEquals( '0', $col[0] );
|
||||
|
||||
wc_transaction_query( 'rollback' );
|
||||
$col = $wpdb->get_col( "SElECT option_value FROM {$wpdb->prefix}options WHERE option_name = 'transaction_test'" );
|
||||
$this->assertEquals( '1', $col[0] );
|
||||
|
||||
wc_transaction_query( 'start' );
|
||||
$wpdb->update(
|
||||
$wpdb->prefix . 'options',
|
||||
array(
|
||||
'option_value' => '0',
|
||||
),
|
||||
array(
|
||||
'option_name' => 'transaction_test',
|
||||
)
|
||||
);
|
||||
wc_transaction_query( 'commit' );
|
||||
$col = $wpdb->get_col( "SElECT option_value FROM {$wpdb->prefix}options WHERE option_name = 'transaction_test'" );
|
||||
$this->assertEquals( '0', $col[0] );
|
||||
|
||||
$wpdb->delete(
|
||||
$wpdb->prefix . 'options',
|
||||
array(
|
||||
'option_name' => 'transaction_test',
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue