unset($i1); try { $i1 = new rtShopPromotionCart(); $i1->save(); $t->fail('->save() rtShopPromotionCart allows empty saves'); $i1->delete(); } catch (Exception $e) { $t->pass('->save() rtShopPromotionCart throws an Exception!'); } // Clean up unset($i1); try { $i1 = new rtShopVoucher(); $i1->save(); $t->fail('->save() rtShopVoucher allows empty saves'); $i1->delete(); } catch (Exception $e) { $t->pass('->save() rtShopVoucher throws an Exception!'); } // Clean up unset($i1); try { $i1 = new rtShopStock(); $i1->save(); $t->pass('->save() rtShopStock allows empty saves'); $i1->delete(); } catch (Exception $e) { $t->fail('->save() rtShopStock throws an Exception!'); } // Clean up unset($i1);
$t->is($voucher->getId(), $i4->getId(), '::getApplicable() Found applicable voucher.'); $t->is($voucher->getMode(), 'Group', '::getMode() Voucher type is Group.'); $t->is($voucher->getReductionType(), 'percentageOff', '::getReductionType() Voucher reduction_type is percentageOff.'); $voucher->adjustReductionValueBy($order_total); $t->is($voucher->getReductionValue(), 15, '::getReductionValue() Untouched reduction_value is correct.'); $t->diag('Apply voucher to order total'); $order_total = 100; $voucher_total = rtShopVoucherToolkit::applyVoucher($code4, $order_total, date("Y-m-d H:i:s")); $t->is($voucher_total, 40, '::applyVoucher() Applied voucher correctly and returned new total.'); // Clean up $i3->delete(); $i4->delete(); $i5->delete(); $i6->delete(); $i7->delete(); $i8->delete(); unset($voucher); unset($i3, $i4, $i5, $i6, $i7, $i8); /** * rtShopVoucherToolkit Class */ class rtShopVoucherTestTools { /** * Make sure table is cleaned before testing */ public static function clean() { $doctrine = Doctrine_Manager::getInstance()->getCurrentConnection()->getDbh(); $doctrine->query('TRUNCATE table rt_shop_promotion'); unset($doctrine);