You are here

public function UbercartCartCheckoutTestCase::testMaximumQuantityRule in Ubercart 7.3

Tests Rule integration for uc_cart_maximum_product_qty reaction rule.

File

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

Class

UbercartCartCheckoutTestCase
Tests the cart and checkout functionality.

Code

public function testMaximumQuantityRule() {

  // Enable the example maximum quantity rule.
  $rule = rules_config_load('uc_cart_maximum_product_qty');
  $rule->active = TRUE;
  $rule
    ->save();

  // Try to add more items than allowed to the cart.
  $this
    ->drupalPost('node/' . $this->product->nid, array(), t('Add to cart'));
  $this
    ->drupalPost('cart', array(
    'items[0][qty]' => 11,
  ), t('Update cart'));

  // Test the restriction was applied.
  $this
    ->assertText('You are only allowed to order a maximum of 10 of ' . $this->product->title . '.');
  $this
    ->assertFieldByName('items[0][qty]', 10);
}