public function UbercartCartSettingsTestCase::testMinimumSubtotal in Ubercart 7.3
Same name and namespace in other branches
- 6.2 uc_cart/uc_cart.test \UbercartCartSettingsTestCase::testMinimumSubtotal()
Tests minimum subtotal for checkout.
File
- uc_cart/
tests/ uc_cart.test, line 670 - Shopping cart and checkout tests.
Class
- UbercartCartSettingsTestCase
- Tests the cart settings page.
Code
public function testMinimumSubtotal() {
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('admin/store/settings/cart');
$this
->assertField('uc_minimum_subtotal', t('Minimum order subtotal field exists'));
$minimum_subtotal = mt_rand(2, 9999);
$this
->drupalPost(NULL, array(
'uc_minimum_subtotal' => $minimum_subtotal,
), t('Save configuration'));
// Create two products, one below the minimum price and one above.
$product_below_limit = $this
->createProduct(array(
'sell_price' => $minimum_subtotal - 1,
));
$product_above_limit = $this
->createProduct(array(
'sell_price' => $minimum_subtotal + 1,
));
$this
->drupalLogout();
// Checks if the lower priced product triggers the minimum price logic.
$this
->drupalPost('node/' . $product_below_limit->nid, array(), t('Add to cart'));
$this
->drupalPost('cart', array(), t('Checkout'));
$this
->assertRaw('The minimum order subtotal for checkout is', t('Prevented checkout below the minimum order total.'));
// Add another product to the cart, and verify that we land on
// the checkout page.
$this
->drupalPost('node/' . $product_above_limit->nid, array(), t('Add to cart'));
$this
->drupalPost('cart', array(), t('Checkout'));
$this
->assertText('Enter your billing address and information here.');
}