/**
  * Create product promotion and connect to product
  *
  * @param integer $product_id
  * @param string $title
  * @param number $value
  * @param datetime $date_from
  * @param datetime $date_to
  * @param string $type
  * @param integer $count
  * @param boolean $stackable
  * @return integer
  */
 public function createProductPromotion($product_id, $title = 'Test Promotion', $value = 10, $type = 'percentageOff', $stackable = true, $date_from = NULL, $date_to = NULL, $count = 1)
 {
     // Create promotion
     $promotion = new rtShopPromotionProduct();
     $promotion->setTitle($title);
     $promotion->setDateFrom($date_from);
     $promotion->setDateTo($date_to);
     $promotion->setReductionType($type);
     $promotion->setReductionValue($value);
     $promotion->setCount($count);
     $promotion->setStackable($stackable);
     $promotion->save();
     // Connect promotion to product
     $promo_product = new rtShopProductToPromotion();
     $promo_product->setProductId($product_id);
     $promo_product->setPromotionId($promotion->getId());
     $promo_product->save();
     return $promotion->getId();
 }
$t->diag('**************************');
// Add vouchers data
try {
    rtShopPromotionTestTools::clean();
    // Add 3 vouchers
    $i3 = new rtShopPromotionProduct();
    $i3->setTitle('Voucher');
    $i3->setDateFrom(date('Y-m-d H:i:s', strtotime(sprintf("-%s months", 3))));
    $i3->setDateTo(date('Y-m-d H:i:s', strtotime(sprintf("+%s months", 1))));
    $i3->setQuantityTo(20);
    $i3->setReductionType('dollarOff');
    $i3->setReductionValue(10);
    $i3->setMode('Group');
    $i3->setCount(100);
    $i3->save();
    $i4 = new rtShopPromotionProduct();
    $i4->setTitle('Voucher');
    $i4->setCode($code2);
    $i4->setDateFrom(date('Y-m-d H:i:s', strtotime(sprintf("-%s months", 3))));
    $i4->setDateTo(date('Y-m-d H:i:s', strtotime(sprintf("+%s months", 1))));
    $i4->setQuantityFrom(10);
    $i4->setQuantityTo(30);
    $i4->setReductionType('percentageOff');
    $i4->setReductionValue(15);
    $i4->setMode('Single');
    $i4->setCount(1);
    $i4->save();
    $t->pass('->save() on a rtShopPromotionProduct object works');
} catch (Exception $e) {
    $t->fail('->save() on a rtShopPromotionProduct failed!');
}