public function UbercartCartCheckoutTestCase::testCartMerge in Ubercart 7.3
Same name and namespace in other branches
- 6.2 uc_cart/uc_cart.test \UbercartCartCheckoutTestCase::testCartMerge()
Tests that anonymous cart is merged into authenticated cart upon login.
File
- uc_cart/
tests/ uc_cart.test, line 172 - Shopping cart and checkout tests.
Class
- UbercartCartCheckoutTestCase
- Tests the cart and checkout functionality.
Code
public 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.'));
}