You are here

function UbercartCartCheckoutTestCase::testCartMerge in Ubercart 6.2

Same name and namespace in other branches
  1. 7.3 uc_cart/tests/uc_cart.test \UbercartCartCheckoutTestCase::testCartMerge()

File

uc_cart/uc_cart.test, line 158
Shopping cart and checkout tests.

Class

UbercartCartCheckoutTestCase
Tests the cart and checkout functionality.

Code

function testCartMerge() {

  // Add an item to the cart as an anonymous user.
  $this
    ->drupalLogin($this->customer);
  $this
    ->drupalPost('node/' . $this->product->nid, array(), t('Add to cart'));
  $this
    ->assertText($this->product->title . ' added to your shopping cart.');
  $this
    ->drupalLogout();

  // Add an item to the cart as an anonymous user.
  $this
    ->drupalPost('node/' . $this->product->nid, array(), t('Add to cart'));
  $this
    ->assertText($this->product->title . ' added to your shopping cart.');

  // Log in and check the items are merged.
  $this
    ->drupalLogin($this->customer);
  $this
    ->drupalGet('cart');
  $this
    ->assertText($this->product->title, t('The product remains in the cart after logging in.'));
  $this
    ->assertFieldByName('items[0][qty]', 2, t('The product quantity is 2.'));
}