Update test_save_default_attributes to make use of propper attributes before checking defaults

This commit is contained in:
Gerhard Potgieter 2018-06-13 15:49:38 +02:00
parent 812586742b
commit ab769eb8a7
1 changed files with 55 additions and 1 deletions

View File

@ -356,8 +356,61 @@ class WC_Tests_Product_Data_Store extends WC_Unit_Test_Case {
// Create a variable product with sold individually. // Create a variable product with sold individually.
$product = new WC_Product_Variable(); $product = new WC_Product_Variable();
$options = array( '1', '0', 'true', 'false' );
$attribute_1 = new WC_Product_Attribute();
$attribute_1->set_name( 'sample-attribute-0' );
$attribute_1->set_visible( true );
$attribute_1->set_variation( true );
$attribute_1->set_options( $options );
$attribute_2 = new WC_Product_Attribute();
$attribute_2->set_name( 'sample-attribute-1' );
$attribute_2->set_visible( true );
$attribute_2->set_variation( true );
$attribute_2->set_options( $options );
$attribute_3 = new WC_Product_Attribute();
$attribute_3->set_name( 'sample-attribute-2' );
$attribute_3->set_visible( true );
$attribute_3->set_variation( true );
$attribute_3->set_options( $options );
$attribute_4 = new WC_Product_Attribute();
$attribute_4->set_name( 'sample-attribute-3' );
$attribute_4->set_visible( true );
$attribute_4->set_variation( true );
$attribute_4->set_options( $options );
$attribute_5 = new WC_Product_Attribute();
$attribute_5->set_name( 'sample-attribute-4' );
$attribute_5->set_visible( true );
$attribute_5->set_variation( true );
$attribute_5->set_options( $options );
$attribute_6 = new WC_Product_Attribute();
$attribute_6->set_name( 'sample-attribute-5' );
$attribute_6->set_visible( true );
$attribute_6->set_variation( true );
$attribute_6->set_options( $options );
$attribute_7 = new WC_Product_Attribute();
$attribute_7->set_name( 'sample-attribute-6' );
$attribute_7->set_visible( true );
$attribute_7->set_variation( true );
$attribute_7->set_options( $options );
$attribute_8 = new WC_Product_Attribute();
$attribute_8->set_name( 'sample-attribute-7' );
$attribute_8->set_visible( true );
$attribute_8->set_variation( true );
$attribute_8->set_options( $options );
$attribute_9 = new WC_Product_Attribute();
$attribute_9->set_name( 'sample-attribute-8' );
$attribute_9->set_visible( true );
$attribute_9->set_variation( true );
$attribute_9->set_options( $options );
$attribute_10 = new WC_Product_Attribute();
$attribute_10->set_name( 'sample-attribute-9' );
$attribute_10->set_visible( true );
$attribute_10->set_variation( true );
$attribute_10->set_options( $options );
$product->set_attributes( array( $attribute_1, $attribute_2, $attribute_3, $attribute_4, $attribute_5, $attribute_6, $attribute_7, $attribute_8, $attribute_9, $attribute_10 ) );
$product->save(); $product->save();
$product_id = $product->get_id();
// Save with a set of FALSE equivalents and some values we expect to come through as true. We should see // Save with a set of FALSE equivalents and some values we expect to come through as true. We should see
// string types with a value of '0' making it through filtration. // string types with a value of '0' making it through filtration.
@ -376,6 +429,7 @@ class WC_Tests_Product_Data_Store extends WC_Unit_Test_Case {
'sample-attribute-9' => $test_object, 'sample-attribute-9' => $test_object,
)); ));
$product->save(); $product->save();
$product_id = $product->get_id();
// Revive the product from the database and analyze results // Revive the product from the database and analyze results
$product = wc_get_product( $product_id ); $product = wc_get_product( $product_id );