function CommerceBackofficeProductWebTestCase::createProductDisplay in Commerce Backoffice 7
Create a new product display.
Parameters
$variation_type: The machine name of the product type.
1 call to CommerceBackofficeProductWebTestCase::createProductDisplay()
- CommerceBackofficeProductTestCase::testProductDisplay in ./
commerce_backoffice_product.test - Create, display a product display var the user interface.
File
- ./
commerce_backoffice_product.test, line 51
Class
- CommerceBackofficeProductWebTestCase
- Provides common helper methods for Commerce backoffice product module tests.
Code
function createProductDisplay($variation_type) {
$title = $this
->randomName();
$sku = $this
->randomName();
$price = mt_rand(1, 100);
$edit = array(
'title' => $title,
'field_product[und][form][sku]' => $sku,
'field_product[und][form][commerce_price][und][0][amount]' => $price,
);
$this
->drupalPost('node/add/' . $variation_type, $edit, t('Save'));
$node = $this
->drupalGetNodeByTitle($title);
$wrapper = entity_metadata_wrapper('node', $node);
$this
->assertEqual($wrapper->field_product[0]->sku
->value(), $sku, 'Sku saved.');
$this
->assertEqual($wrapper->field_product[0]->commerce_price->amount
->value(), $price * 100);
return $node;
}