You are here

public function CommerceWebformTestCase::addProductFieldToWebformNode in Commerce Webform 7.2

Add a product field to a webform node.

Parameters

$node:

$label:

$key:

array $product_types:

array $product_skus:

string $default_sku:

bool|FALSE $multiple:

bool|FALSE $choose_quantity:

1 call to CommerceWebformTestCase::addProductFieldToWebformNode()
CommerceWebformTestCase::testSingleProductNoQuantitiesCommerceWebform in tests/commerce_webform.test
Test the ability to create a webform and add a product to it.

File

tests/commerce_webform.test, line 105
Commerce Webform tests.

Class

CommerceWebformTestCase
Test Commerce Webform module's features.

Code

public function addProductFieldToWebformNode($node, $label, $key, array $product_types = array(), $product_skus = array(), $default_sku = '', $multiple = FALSE, $choose_quantity = FALSE, $listbox = FALSE) {
  $settings = array(
    'name' => $label,
    'form_key' => $key,
    'extra[description]' => 'This is a description',
    'extra[items]' => implode(',', $product_skus),
    'extra[multiple]' => $multiple,
    'extra[choose_quantity]' => $choose_quantity,
    'value' => $default_sku,
    'extra[aslist]' => $listbox,
  );
  $this
    ->drupalPost("node/{$node->nid}/webform/components/new/productfield", $settings, 'Save component', array(
    'query' => array(
      'name' => $label,
      'required' => 1,
      'pid' => 0,
      'weight' => 0,
    ),
  ));
}