public function CommerceBaseTestCase::assertProductCreated in Commerce Core 7
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.
1 call to CommerceBaseTestCase::assertProductCreated()
- CommerceProductUIAdminTest::testCommerceProductUIAddProduct in modules/
product/ tests/ commerce_product_ui.test - Test the add product process.
File
- tests/
commerce_base.test, line 711 - Defines abstract base test class for the Commerce module tests.
Class
- CommerceBaseTestCase
- Abstract class for Commerce testing. All Commerce 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
->createStoreAdmin();
}
$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'));
}