You are here

public function CommerceCartTestCaseSimpleProduct::testCommerceCartAdd in Commerce Core 7

Test if the product has been correctly added to the cart.

File

modules/cart/tests/commerce_cart.test, line 90
Functional tests for the commerce cart module.

Class

CommerceCartTestCaseSimpleProduct
Test cart features for a product display that only has one product attached.

Code

public function testCommerceCartAdd() {

  // Ensure the add to cart message is displayed.
  $message = t('%title added to <a href="!cart-url">your cart</a>.', array(
    '%title' => $this->product_node->title,
    '!cart-url' => url('cart'),
  ));
  $this
    ->assertRaw($message, t('Product add to cart message displayed.'));

  // Go to cart url.
  $this
    ->drupalGet($this
    ->getCommerceUrl('cart'));

  // Test if the page resolves and there is something in the cart.
  $this
    ->assertResponse(200);
  $this
    ->assertNoText(t('Your shopping cart is empty.'), t('Cart is not empty'));
  $this
    ->assertText($this->product->title, t('Product was added to the cart'));
}