コード例 #1
0
    $t->is($charge, $compare_charge[$i], $message);
    $i++;
}
$t->comment('*****************************************************************************');
// ItemsCharge
$t->is($cm->getItemsCharge(), 140, 'ItemsCharge: ' . format_currency($cm->getItemsCharge(), sfConfig::get('app_rt_currency', 'USD')));
// SubTotal
$t->is($cm->getSubTotal(), 140, 'SubTotal:    ' . format_currency($cm->getSubTotal(), sfConfig::get('app_rt_currency', 'USD')));
$t->comment('-----------------------------------------------------------------------------');
// Tax
$t->is($cm->getTaxCharge(), 14.0, 'Tax:          ' . format_currency($cm->getTaxCharge(), sfConfig::get('app_rt_currency', 'USD')));
// 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(), 164.0, 'PreTotal:    ' . format_currency($cm->getPreTotalCharge(), sfConfig::get('app_rt_currency', 'USD')));
$t->comment('=============================================================================');
// Total
$t->is($cm->getTotalCharge(), 164.0, 'Total:       ' . format_currency($cm->getTotalCharge(), sfConfig::get('app_rt_currency', 'USD')));
$t->comment('=============================================================================');
$t->comment('');
$t->diag('***************************************');
$t->diag('*** Voucher check');
$t->diag('***************************************');
$t->comment('');
$t->comment('--- BasertShopOrderActions::executeCheckVoucher() // dollarOff ----------------------------------------');
$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());
コード例 #2
0
$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
     */
    public static function clean()
    {
        $doctrine = Doctrine_Manager::getInstance()->getCurrentConnection()->getDbh();
        $doctrine->query('TRUNCATE table rt_address');
        $doctrine->query('TRUNCATE table rt_shop_attribute');
        $doctrine->query('TRUNCATE table rt_shop_category');