Unit test for #16653

This commit is contained in:
Mike Jolley 2017-08-31 11:42:19 +01:00
parent a2d0069e2f
commit 1e9e6c461f
2 changed files with 24 additions and 1 deletions

View File

@ -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 );

View File

@ -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 );
}
}