コード例 #1
0
$stock2->save();
$cm = new rtShopCartManager();
$t->is($cm->getTaxMode(), sfConfig::get('app_rt_shop_tax_mode'), '::getTaxMode() returns the same tax mode as sfConfig::app_rt_shop_tax_mode');
$t->is($cm->getTaxRate(), sfConfig::get('app_rt_shop_tax_rate'), '::getTaxRate() returns the same tax rate as sfConfig::app_rt_shop_tax_rate');
// Add stocks to cart manager
$cm->addToCart($stock1, 1);
$cm->addToCart($stock2, 1);
// Check items in cart
$t->is($cm->getItemsInCart(), 2, '::getItemsInCart() returns the correct number of items in cart');
$t->is($cm->getItemsQuantityInCart(), 2, '::getItemsQuantityInCart() returns the correct items quantity in cart');
$t->isa_ok($cm->getOrder(), 'rtShopOrder', '->class() rtShopOrder was created successfully');
//In inclusive mode, exclusive mode should return 0
$t->is($cm->getTaxCharge(), 0, '::getTaxCharge() returns the correct value');
// Taxes
$tax_component = $cm->getTotalCharge() * 10 / ($cm->getTaxRate() + 100);
$t->is($cm->getTaxComponent(), $tax_component, '::getTaxComponent() returns the correct value');
// Totals
$t->is($cm->getItemsCharge(), 300, '::getItemsCharge() returns the correct value');
$t->is($cm->getSubTotal(), 300, '::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('-----------------------------------------------------------------------------');
$t->diag('4.4 Two products + taxes + domestic/international shipping');
$t->diag('-----------------------------------------------------------------------------');
$t->diag('4.4.1 Tax mode: Exclusive (international shipping) **************************');
sfConfig::set('app_rt_shop_tax_rate', 10);
sfConfig::set('app_rt_shop_tax_mode', 'exclusive');
sfConfig::set('app_rt_shop_shipping_charges', array('default' => 20, 'AU' => 10));
$shipping_charges = sfConfig::get('app_rt_shop_shipping_charges');
$t->is($shipping_charges['default'], 20, 'sfConfig::app_rt_shop_shipping_charges returns correct default shipping charge');
$t->is($shipping_charges['AU'], 10, 'sfConfig::app_rt_shop_shipping_charges returns correct AU shipping charge');
コード例 #2
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');