/** * @return rtShopPromotion */ public function getPromotion() { if (is_null($this->_promotion)) { $this->_promotion = rtShopPromotionToolkit::getBest($this->getSubTotal()); } return $this->_promotion; }
} $t->diag('Get best promotion offer'); $order_total = 130; $promotions = rtShopPromotionToolkit::getBest($order_total, date("Y-m-d H:i:s")); $t->is(get_class($promotions), 'rtShopPromotionCart', '::getBest() Returns a rtShopPromotion object correctly.'); $t->is($promotions->getId(), $i8->getId(), '::getBest() Best offer found.'); $t->diag('Apply best promotion offer'); $promotion_total = rtShopPromotionToolkit::applyPromotion($order_total, date("Y-m-d H:i:s")); $t->is($promotion_total, 30, '::applyPromotion() Applied best promotion correctly and returned new total.'); $t->diag('Get next best promotion offer'); $promotions = rtShopPromotionToolkit::getNextBest(130, date("Y-m-d H:i:s")); $t->is(get_class($promotions), 'rtShopPromotionCart', '::getNextBest() Returns a rtShopPromotion object correctly.'); $t->is($promotions->getId(), $i11->getId(), '::getNextBest() Next best offer found.'); $t->diag('Get distance to next best promotion offer'); $order_total = 130; $promotions = rtShopPromotionToolkit::getDistanceToNextBest($order_total, date("Y-m-d H:i:s")); $t->is($promotions, $i11->getTotalFrom() - $order_total, '::getDistanceToNextBest() Distance to next best offer found.'); // Clean up $i3->delete(); $i4->delete(); $i5->delete(); $i6->delete(); $i7->delete(); $i8->delete(); $i9->delete(); $i10->delete(); $i11->delete(); $i12->delete(); unset($i3, $i4, $i5, $i6, $i7, $i8, $i9, $i10, $i11, $i12); unset($promotions); $t->diag('**************************');