You are here

function CommercePriceTableTest::setUp in Commerce Price Table 7

Implementation of setUp().

Overrides DrupalWebTestCase::setUp

File

tests/commerce_price_table.test, line 56
Functional tests for the commerce price table module.

Class

CommercePriceTableTest
Test price table features.

Code

function setUp() {
  $modules = parent::setUpHelper('all', array(
    'commerce_price_table',
  ));
  parent::setUp($modules);

  // Create a site admin + store admin user and login.
  $this->site_admin = $this
    ->createUserWithPermissionHelper(array(
    'site admin',
    'store admin',
  ));
  $this
    ->drupalLogin($this->site_admin);

  // Also create a store customer.
  $this->store_customer = $this
    ->createStoreCustomer();

  // Create a dummy product display content type.
  $this
    ->createDummyProductDisplayContentType();

  // Create dummy product display nodes (and their corresponding product
  //  entities).
  $sku = 'PROD-01';
  $product_name = 'Product One';
  $this->product = $this
    ->createDummyProduct($sku, $product_name);
  $this->product_node = $this
    ->createDummyProductNode(array(
    $this->product->product_id,
  ), $product_name);

  // Access to the manage fields screen.
  $this
    ->drupalGet('admin/commerce/products/types/product/fields');

  // Add a new price table field
  $edit = array(
    'fields[_add_new_field][label]' => 'Price table',
    'fields[_add_new_field][field_name]' => 'field_price_table',
    'fields[_add_new_field][type]' => 'commerce_price_table',
    'fields[_add_new_field][widget_type]' => 'commerce_price_table_multiple',
  );
  $this
    ->drupalPost(NULL, $edit, t('Save'));

  // Save the field settings, which are empty.
  $this
    ->drupalPost(NULL, array(), t('Save field settings'));

  // Set unlimited values.
  $this
    ->drupalPost(NULL, array(
    'field[cardinality]' => '-1',
  ), t('Save settings'));

  // Clear field's cache.
  field_cache_clear();

  // Get the field information just saved.
  $this->field_name = 'field_price_table';
  $this->field = field_info_field($this->field_name);
  $this->field_instance = field_info_instance('commerce_product', $this->field_name, 'product');
}