$t->diag('*** Case #1.0: Voucher #1: Non-applicable voucher'); $check_voucher_array1 = $cm->getCheckVoucherArray($voucher1->getCode()); $t->is($check_voucher_array1['error'], true, '->checkVoucher() has no applicable rtShopVoucher.'); $t->diag('*** Case #1.1: Voucher #2: Applicable voucher'); $check_voucher_array2 = $cm->getCheckVoucherArray($voucher2->getCode()); $t->is($check_voucher_array2['error'], false, '->checkVoucher() has applicable rtShopVoucher where code #' . $voucher2->getCode()); $t->comment('--- BasertShopOrderActions::executeCheckVoucher() // percentageOff ------------------------------------'); $t->diag('*** Case #1.2: Voucher #3: Non-applicable voucher'); $check_voucher_array3 = $cm->getCheckVoucherArray($voucher3->getCode()); $t->is($check_voucher_array3['error'], true, '->checkVoucher() has no applicable rtShopVoucher.'); $t->diag('*** Case #1.3: Voucher #4: Applicable voucher'); $check_voucher_array4 = $cm->getCheckVoucherArray($voucher4->getCode()); $t->is($check_voucher_array4['error'], false, '->checkVoucher() has applicable rtShopVoucher where code #' . $voucher4->getCode()); $t->comment('--- rtShopCartManager::getVoucherReduction() // dollarOff ---------------------------------------------'); $t->diag('*** Case #2.0: Voucher #1: Non-applicable voucher'); $cm->setVoucherCode($voucher1->getCode()); $t->is($cm->getVoucherReduction(), 0, '->getVoucherReduction() is returning correct voucher reduction value of ' . $numberFormat->format($cm->getVoucherReduction(), 'c', sfConfig::get('app_rt_currency', 'USD')) . ')'); $t->diag('*** Case #2.1: Voucher #2: Applicable voucher'); $cm->setVoucherCode($voucher2->getCode()); $t->is($cm->getVoucherReduction(), 100, '->getVoucherReduction() is returning correct voucher reduction value of ' . $numberFormat->format($cm->getVoucherReduction(), 'c', sfConfig::get('app_rt_currency', 'USD')) . ')'); $t->comment('--- rtShopCartManager::getVoucherReduction() // percentageOff -----------------------------------------'); $t->diag('*** Case #2.2: Voucher #3: Non-applicable voucher'); $cm->setVoucherCode($voucher3->getCode()); $t->is($cm->getVoucherReduction(), 0, '->getVoucherReduction() is returning correct voucher reduction value of ' . $numberFormat->format($cm->getVoucherReduction(), 'c', sfConfig::get('app_rt_currency', 'USD')) . ')'); $t->diag('*** Case #2.3: Voucher #4: Applicable voucher'); $cm->setVoucherCode($voucher4->getCode()); $t->is($cm->getVoucherReduction(), 14, '->getVoucherReduction() is returning correct voucher reduction value of ' . $numberFormat->format($cm->getVoucherReduction(), 'c', sfConfig::get('app_rt_currency', 'USD')) . ')'); /** * rtShopVoucherRangeTestTools Class */ class rtShopVoucherRangeTestTools
$t->is($cm->getVoucherReduction(), 0.0, '::getVoucherReduction() returns 0.0 for no voucher applied'); //// Totals $t->is($cm->getItemsCharge(), 280, '::getItemsCharge() returns the correct value'); $t->is($cm->getSubTotal(), 280, '::getSubTotal() returns the correct value'); $t->is($cm->getPreTotalCharge(), 300, '::getPreTotalCharge() returns the correct value'); $t->is($cm->getTotalCharge(), 300, '::getTotalCharge() returns the correct value'); $t->diag('4.7.3 Use valid voucher *****************************************************'); // Clean order and reset cart manager unset($cm); rtShopOrderTestTools::cleanOrder(); $cm = new rtShopCartManager(); // Add stocks to cart manager $cm->addToCart($stock1, 1); $cm->addToCart($stock2, 1); // Voucher $cm->setVoucherCode($voucher2->getCode()); $t->is($cm->getVoucherCode(), $voucher2->getCode(), '::getVoucherCode() returns correct voucher code'); $t->is($cm->getVoucherReduction(), 10, '::getVoucherReduction() returns correct voucher reduction'); //// Totals $t->is($cm->getItemsCharge(), 280, '::getItemsCharge() returns the correct value'); $t->is($cm->getSubTotal(), 280, '::getSubTotal() returns the correct value'); $t->is($cm->getPreTotalCharge(), 300, '::getPreTotalCharge() returns the correct value'); $t->is($cm->getTotalCharge(), 290, '::getTotalCharge() returns the correct value'); /** * rtShopOrderTestTools Class */ class rtShopOrderTestTools { /** * Make sure table is cleaned before testing */