public function UcCouponTestCase::applyCoupons in Ubercart Discount Coupons 7.3
2 calls to UcCouponTestCase::applyCoupons()
File
- tests/
uc_coupon.test, line 47 - Ubercart Discount Coupon Tests.
Class
- UcCouponTestCase
- SimpleTests for Ubercart Discount Coupons
Code
public function applyCoupons($coupons, $products = array(), $total = NULL) {
foreach ($products as $product) {
$this
->drupalPost('node/' . $product->nid, array(), t('Add to cart'));
$this
->assertRaw($product->title, 'Product appears on cart page');
}
foreach ($coupons as $coupon) {
$this
->drupalPost('cart', array(
'code' => $coupon->code,
), t('Apply to order'));
if ($total !== FALSE) {
$this
->assertRaw('Coupon ' . $coupon->code, 'Applied coupon code appears on cart page.');
}
else {
$this
->assertNoRaw('Coupon ' . $coupon->code, 'Invalid coupon code does not appear on cart page.');
}
}
if ($total === FALSE) {
$this
->assertNoRaw(uc_currency_format($total), 'Invalid discount was not applied to total.');
}
elseif (!is_null($total)) {
$this
->assertRaw(uc_currency_format($total), 'Discounted total is correct on cart page.');
}
}