コード例 #1
0
$t->is($voucher->getReductionValue(), 20, '::getReductionValue() New reduction value is correct.');
$t->diag('Voucher type: Single, Reduction_type: dollarOff and reduction_value = order total');
$order_total = 60;
$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.');
$t->is($voucher->getMode(), 'Single', '::getMode() Voucher type is Single.');
$t->is($voucher->getReductionType(), 'dollarOff', '::getReductionType() Voucher reduction_type is dollarOff.');
$t->is($voucher->getReductionValue() >= $order_total, True, '::getReductionValue() Voucher value is greater/equal to order total.');
$voucher->adjustReductionValueBy($order_total);
$t->is($voucher->getReductionValue(), 0, '::getReductionValue() New reduction value ZERO is correct.');
$t->diag('Voucher type: Single, Reduction_type: percentageOff');
$order_total = 180;
$voucher = rtShopVoucherToolkit::getApplicable($code5, $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(), $i7->getId(), '::getApplicable() Found applicable voucher.');
$t->is($voucher->getMode(), 'Single', '::getMode() Voucher type is Single.');
$t->is($voucher->getReductionType(), 'percentageOff', '::getReductionType() Voucher reduction_type is percentageOff.');
$voucher->adjustReductionValueBy($order_total);
$t->is($voucher->getReductionValue(), 12, '::getReductionValue() Untouched reduction_value is correct.');
$t->diag('Voucher type: Group, Reduction_type: dollarOff');
$order_total = 180;
$voucher = rtShopVoucherToolkit::getApplicable($code1, $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(), $i3->getId(), '::getApplicable() Found applicable voucher.');
$t->is($voucher->getMode(), 'Group', '::getMode() Voucher type is Group.');
$t->is($voucher->getReductionType(), 'dollarOff', '::getReductionType() Voucher reduction_type is dollarOff.');
$voucher->adjustReductionValueBy($order_total);
$t->is($voucher->getReductionValue(), 10, '::getReductionValue() Untouched reduction_value is correct.');
$t->diag('Voucher type: Group, Reduction_type: percentageOff');
$order_total = 130;