// Voucher $cm->setVoucherCode($voucher4->getCode()); $t->is($cm->getVoucherCode(), $voucher4->getCode(), '::getVoucherCode() returns correct voucher code'); $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 {
$stock2tovar1->save(); $stock2tovar2 = new rtShopStockToVariation(); $stock2tovar2->setStockId($stock2->getId()); $stock2tovar2->setVariationId($var2->getId()); $stock2tovar2->save(); } catch (Exception $e) { throw new sfException('Stocks could not be added to variations! Please check.'); } // Create cart manager instance try { $cm = new rtShopCartManager(); } catch (Exception $e) { throw new sfException('Cart manager instance could not be created! Please check.'); } // Add stocks to cart manager $cm->addToCart($stock1, 2); $cm->addToCart($stock2, 2); // Create voucher $voucher1 = $tools->createVoucher('Voucher $100.00 // Valid if total >= $150', 100, 'dollarOff', 150); $voucher2 = $tools->createVoucher('Voucher $100.00 // Valid if total >= $100', 100, 'dollarOff', 100); $voucher3 = $tools->createVoucher('Voucher 10.00% // Valid if total >= $150', 10, 'percentageOff', 150); $voucher4 = $tools->createVoucher('Voucher 10.00% // Valid if total >= $100', 10, 'percentageOff', 100); $t->comment(''); $t->diag('***************************************'); $t->diag('*** Voucher #1 details'); $t->diag('***************************************'); $t->diag('Code: ' . $voucher1->getCode()); $t->diag(sprintf('Stackable: %s', $voucher1->getStackable() ? 'Yes' : 'No')); $t->diag('Reduction type: ' . $voucher1->getReductionType()); $t->diag('Reduction value: ' . $voucher1->getReductionValue()); $t->diag('Count: ' . $voucher1->getCount());
$productpromo2 = $tools->createProductPromotion($stock4->getRtShopProduct()->getId(), 'Promotion 10% - ' . $stock4->getRtShopProduct()->getTitle(), 10, 'percentageOff', false); $productpromo3 = $tools->createProductPromotion($stock5->getRtShopProduct()->getId(), 'Promotion 10% - ' . $stock5->getRtShopProduct()->getTitle(), 10, 'percentageOff', true); $productpromo4 = $tools->createProductPromotion($stock6->getRtShopProduct()->getId(), 'Promotion 10% - ' . $stock6->getRtShopProduct()->getTitle(), 10, 'percentageOff', false); $productpromo5 = $tools->createProductPromotion($stock7->getRtShopProduct()->getId(), 'Promotion 10% - ' . $stock7->getRtShopProduct()->getTitle(), 10, 'percentageOff', false); // Add cart promotion $cartpromo1 = $tools->createCartPromotion('Cart Promotion 10%', 10, 400, 600); // Add voucher $voucher1 = $tools->createVoucher('Voucher $10', 10, 'dollarOff', 400, 600); // Create cart manager instance try { $cm = new rtShopCartManager(); } catch (Exception $e) { throw new sfException('Cart manager instance could not be created! Please check.'); } // Add stocks to cart manager $cm->addToCart($stock1, 2); $cm->addToCart($stock2, 2); $cm->addToCart($stock3, 2); $cm->addToCart($stock4, 2); $cm->addToCart($stock5, 2); $cm->addToCart($stock6, 2); $cm->addToCart($stock7, 2); // Add addresses to order $tools->addAddressForOrder($cm->getOrder()->getId()); $tools->addAddressForOrder($cm->getOrder()->getId(), 'shipping'); // Loop through stocks in order $t->comment(''); $t->comment('*****************************************************************************'); $stock_info = $cm->getOrder()->getStockInfoArray(); $i = 0; $compare_charge = array(40, 30, 36, 36, 27, 30, 36);