You are here

public function UcCouponTestCase::testCoupon in Ubercart Discount Coupons 7.3

File

tests/uc_coupon.test, line 122
Ubercart Discount Coupon Tests.

Class

UcCouponTestCase
SimpleTests for Ubercart Discount Coupons

Code

public function testCoupon() {
  $coupon = $this
    ->createCoupon(array(
    'discount' => '100',
  ));
  $product = $this
    ->createProduct(array(
    'sell_price' => '150',
  ));
  $total = $product->sell_price - $coupon->value;
  $this
    ->applyCoupons(array(
    $coupon,
  ), array(
    $product,
  ), $total);
  $order = $this
    ->checkout(array(
    $coupon,
  ), $total);

  // Try again to make sure the default usage limit works.
  uc_order_update_status($order->order_id, 'payment_received');
  $this
    ->applyCoupons(array(
    $coupon,
  ), array(
    $product,
  ), FALSE);

  // Clear the usage limit and try again.
  $coupon->max_uses = 0;
  uc_coupon_save($coupon);
  $this
    ->applyCoupons(array(
    $coupon,
  ), array(), $total);
}