function CommerceBackofficeProductWebTestCase::createProductVariationType in Commerce Backoffice 7
Create a new product variation type with random name.
1 call to CommerceBackofficeProductWebTestCase::createProductVariationType()
- CommerceBackofficeProductTestCase::setUp in ./
commerce_backoffice_product.test - Sets up a Drupal site for running functional and integration tests.
File
- ./
commerce_backoffice_product.test, line 11
Class
- CommerceBackofficeProductWebTestCase
- Provides common helper methods for Commerce backoffice product module tests.
Code
function createProductVariationType() {
$name = $this
->randomName();
$type = strtolower($name);
$edit = array(
'product_type[name]' => $name,
'product_type[type]' => $type,
);
$this
->drupalPost('admin/commerce/config/product-variation-types/add', $edit, t('Save product variation type'));
commerce_product_types_reset();
$variation_type = commerce_product_type_load($type);
$this
->assertEqual($variation_type['type'], $type, 'Type saved.');
// Use the inline_entity_form widget
$instance = field_info_instance('node', 'field_product', $variation_type['type']);
$instance['widget'] = array(
'active' => 1,
'module' => 'inline_entity_form',
'settings' => array(
'fields' => array(),
'type_settings' => array(
'allow_existing' => 0,
'autogenerate_title' => 1,
'delete_references' => 1,
'match_operator' => 'CONTAINS',
'use_variation_language' => 1,
),
),
'type' => 'inline_entity_form',
);
field_update_instance($instance);
return $variation_type;
}