Ejemplo n.º 1
0
$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
     */
    public static function clean()
    {
$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
{
// ItemsCharge
$t->is($cm->getItemsCharge(), 470, 'ItemsCharge: ' . format_currency($cm->getItemsCharge(), sfConfig::get('app_rt_currency', 'USD')));
// SubTotal
$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();