43 lines
1.5 KiB
PHP
43 lines
1.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Tests for WC_Product_Variable.
|
|
*/
|
|
class WC_Product_Variable_Test extends \WC_Unit_Test_Case {
|
|
/**
|
|
* @testdox 'get_available_variations' returns the variations as arrays if no parameters is passed.
|
|
*/
|
|
public function test_get_available_variations_returns_array_when_no_parameter_is_passed() {
|
|
$product = WC_Helper_Product::create_variation_product();
|
|
|
|
$variations = $product->get_available_variations();
|
|
|
|
$this->assertTrue( is_array( $variations[0] ) );
|
|
$this->assertEquals( 'DUMMY SKU VARIABLE SMALL', $variations[0]['sku'] );
|
|
}
|
|
|
|
/**
|
|
* @testdox 'get_available_variations' returns the variations as arrays if the parameter passed is 'array'.
|
|
*/
|
|
public function test_get_available_variations_returns_array_when_array_parameter_is_passed() {
|
|
$product = WC_Helper_Product::create_variation_product();
|
|
|
|
$variations = $product->get_available_variations( 'array' );
|
|
|
|
$this->assertTrue( is_array( $variations[0] ) );
|
|
$this->assertEquals( 'DUMMY SKU VARIABLE SMALL', $variations[0]['sku'] );
|
|
}
|
|
|
|
/**
|
|
* @testdox 'get_available_variations' returns the variations as objects if the parameter passed is 'objects'.
|
|
*/
|
|
public function test_get_available_variations_returns_object_when_objects_parameter_is_passed() {
|
|
$product = WC_Helper_Product::create_variation_product();
|
|
|
|
$variations = $product->get_available_variations( 'objects' );
|
|
|
|
$this->assertInstanceOf( WC_Product_Variation::class, $variations[0] );
|
|
$this->assertEquals( 'DUMMY SKU VARIABLE SMALL', $variations[0]->get_sku() );
|
|
}
|
|
}
|