コード例 #1
0
$t->is($cm->getSubTotal(), 160, 'SubTotal:    ' . format_currency($cm->getSubTotal(), sfConfig::get('app_rt_currency', 'USD')));
$t->comment('-----------------------------------------------------------------------------');
// Shipping
$t->is($cm->getShippingCharge(), 10, 'Shipping:    ' . format_currency($cm->getShippingCharge(), sfConfig::get('app_rt_currency', 'USD')));
$t->comment('-----------------------------------------------------------------------------');
// Pre total
$t->is($cm->getPreTotalCharge(), 170, 'PreTotal:    ' . format_currency($cm->getPreTotalCharge(), sfConfig::get('app_rt_currency', 'USD')));
$t->comment('-----------------------------------------------------------------------------');
// Voucher
$cm->setVoucherCode($voucher1->getCode());
$t->is($cm->getVoucherReduction(), 200, 'Voucher:    -' . format_currency($cm->getVoucherReduction(), sfConfig::get('app_rt_currency', 'USD')) . ' (#' . $cm->getVoucherCode() . ')');
$t->comment('=============================================================================');
// Total
$t->is($cm->getTotalCharge(), 0, 'Total (includes $' . format_currency($cm->getTaxComponent(), sfConfig::get('app_rt_currency', 'USD')) . ' tax): ' . format_currency($cm->getTotalCharge(), sfConfig::get('app_rt_currency', 'USD')));
$t->comment('=============================================================================');
$cm->adjustVoucherDetails($cm->getPreTotalCharge());
$t->is($cm->getVoucher()->getReductionValue(), 30, '>>> Voucher leftover after reduction value: ' . format_currency($cm->getVoucher()->getReductionValue(), sfConfig::get('app_rt_currency', 'USD')) . ' <<<');
$t->diag('');
$t->diag('/////////////////////////////////////////////////////////////////////////////');
$t->diag('2. Voucher: 10%, non-stackable');
$t->diag('/////////////////////////////////////////////////////////////////////////////');
// Clean order and reset cart manager
unset($cm);
rtShopComplexOrder3TestTools::cleanOrder();
// Add voucher
$voucher1 = $tools->createVoucher('Voucher 10%', 10, 'percentageOff', false);
// Create cart manager instance
try {
    $cm = new rtShopCartManager();
} catch (Exception $e) {
    throw new sfException('Cart manager instance could not be created! Please check.');