You are here

public function MerciBaseTestCase::assertProductCreated in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3

Asserts that a product has been created.

Parameters

$product: A full loaded commerce_product object.

$user: User that access the admin pages. Optional, if not informed, the check is done with the store admin.

File

merci_core/tests/merci_base.test, line 634
Defines abstract base test class for the Merci module tests.

Class

MerciBaseTestCase
Abstract class for Merci testing. All Merci tests should extend this class.

Code

public function assertProductCreated($product, $user = NULL) {

  // Check if the product is not empty and reload it from database.
  $this
    ->assertFalse(empty($product), t('Product object is not empty'));
  $product = commerce_product_load($product->product_id);
  $this
    ->assertFalse(empty($product), t('Product object is correctly loaded from database'));

  // Access to the admin page for the product and check if the product is there.
  if (empty($user)) {
    $user = $this
      ->createMerciAdmin();
  }
  $this
    ->drupalLogin($user);
  $this
    ->drupalGet('admin/commerce/products/' . $product->product_id);
  $this
    ->assertFieldById('edit-sku', $product->sku, t('When editing the product in the administration interface, the SKU is informed correctly'));
  $this
    ->assertFieldById('edit-title', $product->title, t('When editing the product in the administration interface, the Title is informed correctly'));
}