You are here

function UbercartCartSettingsTestCase::testMinimumSubtotal in Ubercart 6.2

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

File

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

Class

UbercartCartSettingsTestCase
Tests the cart settings page.

Code

function testMinimumSubtotal() {
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalGet('admin/store/settings/cart/edit');
  $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 the minimum price.
  $product_below_limit = $this
    ->createProduct(array(
    'sell_price' => $minimum_subtotal - 1,
  ));
  $product_above_limit = $this
    ->createProduct(array(
    'sell_price' => $minimum_subtotal + 1,
  ));
  $this
    ->drupalLogout();

  // Check to see 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.');
}