$i6->setCount(1);
    $i6->save();
    $i7 = new rtShopVoucher();
    $i7->setTitle('Voucher');
    $i7->setCode($code5);
    $i7->setDateFrom(date('Y-m-d H:i:s', strtotime(sprintf("-%s months", 3))));
    $i7->setDateTo(date('Y-m-d H:i:s', strtotime(sprintf("+%s months", 1))));
    $i7->setTotalFrom(150);
    $i7->setTotalTo(250);
    $i7->setReductionType('percentageOff');
    $i7->setReductionValue(12);
    $i7->setMode('Single');
    $i7->setCount(1);
    $i7->save();
    $i8 = new rtShopVoucher();
    $i8->setTitle('Voucher');
    $i8->setCode($code6);
    $i8->setDateFrom(date('Y-m-d H:i:s', strtotime(sprintf("-%s months", 3))));
    $i8->setDateTo(date('Y-m-d H:i:s', strtotime(sprintf("+%s months", 1))));
    $i8->setTotalFrom(250);
    $i8->setTotalTo(400);
    $i8->setReductionType('percentageOff');
    $i8->setReductionValue(12);
    $i8->setMode('Single');
    $i8->setCount(0);
    $i8->save();
    $t->pass('->save() on a rtShopVoucher object works');
} catch (Exception $e) {
    $t->fail('->save() on a rtShopVoucher failed!');
}
$t->diag('Get applicable voucher based on count, total and date');
 /**
  * Create voucher
  *
  * @param string $title
  * @param number $value
  * @param string $type
  * @param float $total_from
  * @param float $total_to
  * @param datetime $date_from
  * @param datetime $date_to
  * @param string $mode
  * @param integer $count
  * @param boolean $stackable
  * @return integer
  */
 public function createVoucher($title, $value = 10, $type = 'percentageOff', $total_from = NULL, $total_to = NULL, $date_from = NULL, $date_to = NULL, $mode = 'Single', $count = 1, $stackable = true)
 {
     $voucher = new rtShopVoucher();
     $voucher->setTitle($title);
     $voucher->setDateFrom($date_from);
     $voucher->setDateTo($date_to);
     $voucher->setTotalFrom($total_from);
     $voucher->setTotalTo($total_to);
     $voucher->setReductionType($type);
     $voucher->setReductionValue($value);
     $voucher->setMode($mode);
     $voucher->setCount($count);
     $voucher->setStackable($stackable);
     $voucher->save();
     return $voucher;
 }
 /**
  * Add data to rtShopVoucher object
  *
  * @param  rtShopVoucher $rt_shop_voucher
  * @param  string $comment Voucher comment
  * @param  string $title
  * @return rtShopVoucher
  */
 private function mergeData(rtShopVoucher $rt_shop_voucher, $comment = '', $title = null)
 {
     $voucher = $this->getSessionVoucherArray();
     $title = is_null($title) ? 'Gift Voucher' : $title;
     $rt_shop_voucher->setTitle($title);
     $rt_shop_voucher->setDateTo(date('Y-m-d H:i:s', strtotime(sprintf("+%s days", sfConfig::get('app_rt_shop_gift_voucher_valid_for', 365)))));
     $rt_shop_voucher->setReductionType('dollarOff');
     $rt_shop_voucher->setReductionValue($voucher['reduction_value']);
     $rt_shop_voucher->setMode('Single');
     $rt_shop_voucher->setCount(1);
     $rt_shop_voucher->setStackable(false);
     $rt_shop_voucher->setComment($this->getSessionVoucherAsString() . chr(13) . chr(13) . $comment);
     return $rt_shop_voucher;
 }