Unit test for #16653
This commit is contained in:
parent
a2d0069e2f
commit
1e9e6c461f
|
@ -64,7 +64,7 @@ class WC_Product_Variable extends WC_Product {
|
|||
* Get an array of all sale and regular prices from all variations. This is used for example when displaying the price range at variable product level or seeing if the variable product is on sale.
|
||||
*
|
||||
* @param bool $include_taxes Should taxes be included in the prices.
|
||||
* @return array() Array of RAW prices, regular prices, and sale prices with keys set to variation ID.
|
||||
* @return array Array of RAW prices, regular prices, and sale prices with keys set to variation ID.
|
||||
*/
|
||||
public function get_variation_prices( $include_taxes = false ) {
|
||||
$prices = $this->data_store->read_price_data( $this, $include_taxes );
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class WC_Tests_Product_Variable.
|
||||
*
|
||||
* @package WooCommerce\Tests\Product
|
||||
*/
|
||||
class WC_Tests_Product_Variable extends WC_Unit_Test_Case {
|
||||
|
||||
/**
|
||||
* Test test_create_empty_variable().
|
||||
*/
|
||||
public function test_create_empty_variable() {
|
||||
$product = new WC_Product_Variable();
|
||||
$product_id = $product->save();
|
||||
$prices = $product->get_variation_prices();
|
||||
|
||||
$this->assertArrayHasKey( 'regular_price', $prices );
|
||||
$this->assertArrayHasKey( 'sale_price', $prices );
|
||||
$this->assertArrayHasKey( 'price', $prices );
|
||||
$this->assertTrue( $product_id > 0 );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue