added more product functions tests
This commit is contained in:
parent
830fba3e41
commit
99c35e83eb
|
@ -62,4 +62,53 @@ class WC_Tests_Product_Functions extends WC_Unit_Test_Case {
|
|||
|
||||
$this->_delete_product();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test wc_get_product_types()
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public function test_wc_get_product_types() {
|
||||
$product_types = (array) apply_filters( 'product_type_selector', array(
|
||||
'simple' => __( 'Simple product', 'woocommerce' ),
|
||||
'grouped' => __( 'Grouped product', 'woocommerce' ),
|
||||
'external' => __( 'External/Affiliate product', 'woocommerce' ),
|
||||
'variable' => __( 'Variable product', 'woocommerce' )
|
||||
) );
|
||||
|
||||
$this->assertEquals( $product_types, wc_get_product_types() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test wc_product_has_unique_sku()
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public function test_wc_product_has_unique_sku() {
|
||||
$product_1 = WC_Helper_Product::create_simple_product();
|
||||
|
||||
$this->assertEquals( true, wc_product_has_unique_sku( $product_1->id, $product_1->sku ) );
|
||||
|
||||
$product_2 = WC_Helper_Product::create_simple_product();
|
||||
$this->assertEquals( false, wc_product_has_unique_sku( $product_2->id, $product_2->sku ) );
|
||||
|
||||
WC_Helper_Product::delete_product( $product_1->id );
|
||||
|
||||
$this->assertEquals( true, wc_product_has_unique_sku( $product_2->id, $product_2->sku ) );
|
||||
|
||||
WC_Helper_Product::delete_product( $product_2->id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test wc_get_product_id_by_sku()
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public function test_wc_get_product_id_by_sku() {
|
||||
$this->_get_product();
|
||||
|
||||
$this->assertEquals( $this->_product->id, wc_get_product_id_by_sku( $this->_product->sku ) );
|
||||
|
||||
$this->_delete_product();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue