コード例 #1
0
// 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');
        $doctrine->query('TRUNCATE table rt_shop_category_version');
コード例 #2
0
$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());
$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');
コード例 #3
0
$t->is($cm->getSubTotal(), 470, 'SubTotal:    ' . format_currency($cm->getSubTotal(), sfConfig::get('app_rt_currency', 'USD')));
$t->comment('-----------------------------------------------------------------------------');
// Promotion
$t->is($cm->getPromotionReduction(), 47.0, 'Promotion: -' . format_currency($cm->getPromotionReduction(), 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(), 433.0, 'PreTotal:   ' . format_currency($cm->getPreTotalCharge(), sfConfig::get('app_rt_currency', 'USD')));
$t->comment('-----------------------------------------------------------------------------');
// Voucher
$cm->setVoucherCode($voucher1->getCode());
$t->is($cm->getVoucherReduction(), 10, 'Voucher:    -' . format_currency($cm->getVoucherReduction(), sfConfig::get('app_rt_currency', 'USD')) . ' (#' . $cm->getVoucherCode() . ')');
$t->comment('=============================================================================');
// Total
$t->is($cm->getTotalCharge(), 423.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('=============================================================================');
/**
 * rtShopComplexOrder1TestTools Class
 */
class rtShopComplexOrder1TestTools
{
    /**
     * 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');