You are here

public function CommerceAutoSkuTest::testCommerceAutoSKUAdvanced in Commerce AutoSKU 7

Test the "advanced" features.

File

./commerce_autosku.test, line 137
Contains simpletests for commerce_autosku

Class

CommerceAutoSkuTest
@file Contains simpletests for commerce_autosku

Code

public function testCommerceAutoSKUAdvanced() {

  //Check we're not modifying anything we shouldn't
  $this
    ->drupalGet('admin/commerce/products/add/product');
  $this
    ->assertField('sku', t('SKU field was shown (unmodified).'));
  $edit = array(
    'product_type[autosku_status]' => TRUE,
    'product_type[autosku][pattern]' => '[commerce-product:title]',
    'product_type[autosku][advanced][update_existing]' => TRUE,
    'product_type[autosku][advanced][case]' => 'uppercase',
  );
  $this
    ->productTypeSubmit($edit);

  //Should be hidden by default
  $this
    ->drupalGet('admin/commerce/products/add/product');
  $this
    ->assertNoField('sku', t('SKU field was hidden (default).'));
  $edit += array(
    'product_type[autosku][advanced][hide_sku]' => FALSE,
  );
  $this
    ->productTypeSubmit($edit);

  //But we should allow it to be shown.
  $this
    ->drupalGet('admin/commerce/products/add/product');
  $this
    ->assertField('sku', t('SKU field was shown (hide sku = false).'));

  //Onto the uppercase/lowercase tests.
  $product_edit = array(
    'title' => 'SimpleTest',
    'commerce_price[' . LANGUAGE_NONE . '][0][amount]' => 500,
  );
  $this
    ->drupalPost('admin/commerce/products/add', $product_edit, 'Save product');
  $product = $this
    ->commerceProductLoadWithReset(1);
  $this
    ->assertIdentical('SIMPLETEST', $product->sku, t('SKU was uppercased.'));
  $edit['product_type[autosku][advanced][case]'] = 'lowercase';
  $this
    ->productTypeSubmit($edit);
  $this
    ->drupalPost('admin/commerce/products/1/edit', $product_edit, 'Save product');
  $product = $this
    ->commerceProductLoadWithReset(1);
  $this
    ->assertIdentical('simpletest', $product->sku, t('SKU was lowercased.'));
}