t('Check removing of products'), 'description' => t('Check removing of products from the cart and make sure they are being removed.'), 'group' => t('e-Commerce'), ); } function setUp() { parent::setUp('ec_product', 'ec_anon', 'ec_checkout', 'ec_cart', 'ec_receipt', 'ec_store', 'ec_common', 'ec_receipt_test_payment', 'ec_customer', 'ctools', 'rules', 'views'); variable_set('ec_default_currency', 'USD'); } function testRemoveProductFromCart() { $account = $this->drupalCreateUser(); $this->drupalLogin($account); $product = array( 'type' => 'product', 'ptype' => 'generic', 'price' => '20.00', ); $node1 = $this->drupalCreateNode($product); $node2 = $this->drupalCreateNode($product); $this->drupalGet('cart/' . $node1->nid . '/+1'); $this->drupalGet('cart/' . $node2->nid . '/+1'); $this->drupalGet('cart/view'); $this->assertText($node1->title, 'Product 1 exists in cart'); $this->assertText($node2->title, 'Product 2 exists in cart'); $this->clickLink('Remove'); $this->assertText('Your item has been removed.', 'Product removed message'); $this->assertNoText($node1->title, 'Product 1 does not exists in cart'); $this->assertText($node2->title, 'Product 2 exists in cart'); } } class ecCartCheckQuantity extends DrupalWebTestCase { function getInfo() { return array( 'name' => t('Multiple item quantities'), 'description' => t('Check that totals are being calculated correctly when there is multiple items.'), 'group' => t('e-Commerce'), ); } function setUp() { parent::setUp('ec_product', 'ec_anon', 'ec_checkout', 'ec_cart', 'ec_receipt', 'ec_store', 'ec_common', 'ec_charge', 'ec_receipt_test_payment', 'ec_customer', 'ctools', 'rules', 'views'); variable_set('ec_default_currency', 'USD'); } function testMultipleQty() { $account = $this->drupalCreateUser(); $this->drupalLogin($account); $product = array( 'type' => 'product', 'ptype' => 'generic', 'price' => '20.00', ); $node1 = $this->drupalCreateNode($product); $node2 = $this->drupalCreateNode($product); $this->drupalGet('cart/' . $node1->nid . '/+1'); $this->drupalGet('cart/' . $node2->nid . '/+1'); $this->drupalGet('cart/view'); $this->assertText($node1->title, 'Product 1 exists in cart'); $this->assertText($node2->title, 'Product 2 exists in cart'); $params = array( 'products[' . $node1->nid . '][qty]' => rand(2, 15), 'products[' . $node2->nid . '][qty]' => rand(2, 15), ); $this->DrupalPost(NULL, $params, t('Update Cart')); $key = 0; foreach ($params as $qty) { $key++; $price = format_currency(ec_product_get_final_price(${'node' . $key}, 'ec_cart') * $qty); $this->assertText($price, t('Check final price for node@i (&price)', array('@i' => $key, '&price' => $price))); } } } class ecCartLoginKeepCart extends DrupalWebTestCase { function getInfo() { return array( 'name' => t('Cart Login'), 'description' => t('Check that when a customer logs into the system the current cart is retained.'), 'group' => t('e-Commerce'), ); } function setUp() { parent::setUp('ec_product', 'ec_anon', 'ec_checkout', 'ec_cart', 'ec_receipt', 'ec_store', 'ec_common', 'ec_charge', 'ec_receipt_test_payment', 'ec_customer', 'ctools', 'rules', 'views'); variable_set('ec_default_currency', 'USD'); } function testCartLogin() { $account = $this->drupalCreateUser(); $product = array( 'type' => 'product', 'ptype' => 'generic', 'price' => '20.00', ); $node1 = $this->drupalCreateNode($product); $this->drupalGet('cart/' . $node1->nid . '/+1'); $this->drupalGet('cart/view'); $this->assertText($node1->title, 'Product exists in cart'); $this->drupalLogin($account); $this->drupalGet('cart/view'); $this->assertText($node1->title, 'Product still exists in cart after login'); } } class ecCartCheckUpdate extends DrupalWebTestCase { function getInfo() { return array( 'name' => t('Check cart is updated (Anonymous w/caching)'), 'description' => t('Check that when adding products to the cart they are then viewable.'), 'group' => t('e-Commerce'), ); } function setUp() { parent::setUp('ec_product', 'ec_anon', 'ec_checkout', 'ec_cart', 'ec_receipt', 'ec_store', 'ec_common', 'ec_receipt_test_payment', 'ec_customer', 'ctools', 'rules', 'views'); variable_set('ec_default_currency', 'USD'); variable_set('cache', 1); } function testRemoveProductFromCart() { $product = array( 'type' => 'product', 'ptype' => 'generic', 'price' => '20.00', ); $node1 = $this->drupalCreateNode($product); $node2 = $this->drupalCreateNode($product); $this->drupalGet('cart/'. $node1->nid . '/+1'); $this->drupalGet('cart/view'); $this->assertText($node1->title, 'Product 1 exists in cart'); $this->drupalGet('cart/'. $node2->nid . '/+1'); $this->drupalGet('cart/view'); $this->assertText($node1->title, 'Product 1 exists in cart'); $this->assertText($node2->title, 'Product 2 exists in cart'); } }