You are here

public function CommerceProductUIAdminTest::testCommerceProductUIDeleteProductLineItem in Commerce Core 7

Test trying to delete a product associated with a Line Item.

File

modules/product/tests/commerce_product_ui.test, line 314
Functional tests for the commerce product ui module.

Class

CommerceProductUIAdminTest
Test the product and product type CRUD.

Code

public function testCommerceProductUIDeleteProductLineItem() {

  // Create dummy product.
  $product = $this
    ->createDummyProduct('PROD-01', 'Product One');

  // Associate the product in an order.
  $order = $this
    ->createDummyOrder($this->store_customer->uid, array(
    $product->product_id => 1,
  ));

  // Login with store admin.
  $this
    ->drupalLogin($this->store_admin);

  // Access to the edit product page.
  $this
    ->drupalGet('admin/commerce/products/' . $product->product_id . '/delete');
  $this
    ->pass('Assertions for trying to delete a product associated to a line item:');
  $this
    ->assertText(t('This product is referenced by a line item on Order @order_num and therefore cannot be deleted. Disable it instead.', array(
    '@order_num' => $order->order_id,
  )), t('Product delete restriction message is displayed correctly'));
  $this
    ->assertFieldByXPath('//input[@id="edit-submit" and @disabled="disabled"]', NULL, t('Delete button is present and is disabled'));
}