EcomDev/EcomDev_PHPUnit — pull request #127 by jonpday (2013-08-09 01:03:43+00:00)
Title: Bundle fixture loader

Very basic functionality to allow insertion of Bundle products. Assumes that the bundle uses a Fixed price_type and each Option uses Radio.

Sample yaml:
`
eav:
catalog_product:
- entity_id: 100
attribute_set_id: 4
type_id: bundle
sku: b1
name: "test bundle 1"
short_description: "test bundle 1"
description: "test bundle 1"
url_key: b1
bundle_options:
1: # option ID
- 1 #child product ID
- 90 #child product ID
2:
- 3 # child product id
- 4 # child product id
website_ids:
- us
category_ids:
- 2 # Default Category
price: 50.00
price_type: 1 # Fixed
tax_class_id: 2 # Taxable Goods
status: 1 # Enabled
visibility: 4 # Visible in Catalog & Search
`

Note that the selections are specified by product_id, so to prepare a buyRequest in the test, the following code is required:

` $bundleOptions = array(1=>array(1,90),2=>array(3,4)); //normally passed via dataProvider
$oBundleType = Mage::getModel('catalog/product')->load(100)->getTypeInstance();
/* @var $oBundleType Mage_Bundle_Model_Product_Type */
$cSelections = $oBundleType->getSelectionsCollection(array_keys($bundleOptions));
$bundleOptionBuyRequest = array();
//the provider and fixtures use product_id to identify a selection, but the buyRequest needs the selection_id
foreach($bundleOptions as $optionId => $selection){
$bundleOptionBuyRequest[$optionId] = $cSelections->getItemByColumnValue('product_id',$selection)->getSelectionId();
}
`