public function CommerceAutoSkuTest::testCommerceAutoSKUUpdates in Commerce AutoSKU 7
File
- ./
commerce_autosku.test, line 102 - Contains simpletests for commerce_autosku
Class
- CommerceAutoSkuTest
- @file Contains simpletests for commerce_autosku
Code
public function testCommerceAutoSKUUpdates() {
$edit = array(
'product_type[autosku_status]' => TRUE,
'product_type[autosku][pattern]' => '[commerce-product:product-id]',
'product_type[autosku][advanced][update_existing]' => FALSE,
'product_type[autosku][advanced][hide_sku]' => FALSE,
);
$this
->productTypeSubmit($edit);
//Create a new product and check that the product_id token is correctly replaced:
$product_edit = array(
'title' => 'SimpleTest',
'commerce_price[' . LANGUAGE_NONE . '][0][amount]' => 500,
);
$this
->drupalPost('admin/commerce/products/add/product', $product_edit, 'Save product');
$product = $this
->commerceProductLoadWithReset(1);
$this
->assertEqual('1', $product->sku, t('Generated SKU from Product ID'));
//Now create a new product whose SKU we will change:
$edit['product_type[autosku][pattern]'] = '[commerce-product:title]';
$this
->productTypeSubmit($edit);
$original_title = 'SimpleTest';
$product_edit = array(
'title' => $original_title,
'commerce_price[' . LANGUAGE_NONE . '][0][amount]' => 500,
);
$this
->drupalPost('admin/commerce/products/add/product', $product_edit, 'Save product');
$product = $this
->commerceProductLoadWithReset(2);
$this
->assertIdentical($original_title, $product->sku, t('SKU was initially set to product title.'));
$product_edit['title'] = 'SimpleTest_2';
$this
->drupalPost('admin/commerce/products/2/edit', $product_edit, 'Save product');
$product = $this
->commerceProductLoadWithReset(2);
$this
->assertIdentical('SimpleTest_2', $product->title, t('Changed Title.'));
$this
->assertIdentical($original_title, $product->sku, t('SKU was unchanged.'));
}