$i8->setTotalTo(400); $i8->setReductionType('percentageOff'); $i8->setReductionValue(12); $i8->setMode('Single'); $i8->setCount(0); $i8->save(); $t->pass('->save() on a rtShopVoucher object works'); } catch (Exception $e) { $t->fail('->save() on a rtShopVoucher failed!'); } $t->diag('Get applicable voucher based on count, total and date'); $voucher = rtShopVoucherToolkit::getApplicable($code4, 130, date("Y-m-d H:i:s")); $t->is(get_class($voucher), 'rtShopVoucher', '::getApplicable() Returns a rtShopVoucher object correctly.'); $t->is($voucher->getId(), $i6->getId(), '::getApplicable() Found applicable voucher.'); $t->diag('Set count of single voucher from 1 to 0'); $t->is($voucher->getCount(), $i6->getCount(), '::getApplicable() Returned original count 1 is corect.'); $voucher->adjustCountBy(1); $t->is($voucher->getCount(), 0, '::getCount() Returned new count 0 is corect.'); $t->diag('Set count of group voucher from 10 to 9'); $voucher = rtShopVoucherToolkit::getApplicable($code2, 130, date("Y-m-d H:i:s")); $t->is($voucher->getCount(), $i4->getCount(), '::getCount() Returned original count 10 is corect.'); $voucher->adjustCountBy(1); $t->is($voucher->getCount(), 9, '::getCount() Returned new count 9 is corect.'); $t->diag('**********************************'); $t->diag('*** Voucher: Value adjustments ***'); $t->diag('**********************************'); $t->diag('Voucher type: Single, Reduction_type: dollarOff and reduction_value > order total'); $order_total = 40; $voucher = rtShopVoucherToolkit::getApplicable($code4, $order_total, date("Y-m-d H:i:s")); $t->is(get_class($voucher), 'rtShopVoucher', '::getApplicable() Returns a rtShopVoucher object correctly.'); $t->is($voucher->getId(), $i6->getId(), '::getApplicable() Found applicable voucher.');