/**
  * 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;
 }
    $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');
$voucher = rtShopVoucherToolkit::getApplicable($code4, 130, date("Y-m-d H:i:s"));
$t->is(get_class($voucher), 'rtShopVoucher', '::getApplicable() Returns a rtShopVoucher object correctly.');