add coupon tests

This commit is contained in:
Etienne Roudeix
2013-12-19 15:37:15 +01:00
parent 5773922314
commit 8c121dd455
6 changed files with 51 additions and 159 deletions

View File

@@ -73,7 +73,7 @@ class Order extends BaseAction implements EventSubscriberInterface
{
$order = $event->getOrder();
$order->setPostage($event->getPostage());
$order->setDeliveryModuleId($event->getDeliveryModule());
$event->setOrder($order);
}

View File

@@ -110,12 +110,6 @@ abstract class OrderCoupon implements ActiveRecordInterface
*/
protected $expiration_date;
/**
* The value for the max_usage field.
* @var int
*/
protected $max_usage;
/**
* The value for the is_cumulative field.
* @var boolean
@@ -531,17 +525,6 @@ abstract class OrderCoupon implements ActiveRecordInterface
}
}
/**
* Get the [max_usage] column value.
*
* @return int
*/
public function getMaxUsage()
{
return $this->max_usage;
}
/**
* Get the [is_cumulative] column value.
*
@@ -819,27 +802,6 @@ abstract class OrderCoupon implements ActiveRecordInterface
return $this;
} // setExpirationDate()
/**
* Set the value of [max_usage] column.
*
* @param int $v new value
* @return \Thelia\Model\OrderCoupon The current object (for fluent API support)
*/
public function setMaxUsage($v)
{
if ($v !== null) {
$v = (int) $v;
}
if ($this->max_usage !== $v) {
$this->max_usage = $v;
$this->modifiedColumns[] = OrderCouponTableMap::MAX_USAGE;
}
return $this;
} // setMaxUsage()
/**
* Sets the value of the [is_cumulative] column.
* Non-boolean arguments are converted using the following rules:
@@ -1057,28 +1019,25 @@ abstract class OrderCoupon implements ActiveRecordInterface
}
$this->expiration_date = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderCouponTableMap::translateFieldName('MaxUsage', TableMap::TYPE_PHPNAME, $indexType)];
$this->max_usage = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderCouponTableMap::translateFieldName('IsCumulative', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderCouponTableMap::translateFieldName('IsCumulative', TableMap::TYPE_PHPNAME, $indexType)];
$this->is_cumulative = (null !== $col) ? (boolean) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : OrderCouponTableMap::translateFieldName('IsRemovingPostage', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderCouponTableMap::translateFieldName('IsRemovingPostage', TableMap::TYPE_PHPNAME, $indexType)];
$this->is_removing_postage = (null !== $col) ? (boolean) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : OrderCouponTableMap::translateFieldName('IsAvailableOnSpecialOffers', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : OrderCouponTableMap::translateFieldName('IsAvailableOnSpecialOffers', TableMap::TYPE_PHPNAME, $indexType)];
$this->is_available_on_special_offers = (null !== $col) ? (boolean) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : OrderCouponTableMap::translateFieldName('SerializedConditions', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : OrderCouponTableMap::translateFieldName('SerializedConditions', TableMap::TYPE_PHPNAME, $indexType)];
$this->serialized_conditions = (null !== $col) ? (string) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : OrderCouponTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : OrderCouponTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : OrderCouponTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : OrderCouponTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
@@ -1091,7 +1050,7 @@ abstract class OrderCoupon implements ActiveRecordInterface
$this->ensureConsistency();
}
return $startcol + 16; // 16 = OrderCouponTableMap::NUM_HYDRATE_COLUMNS.
return $startcol + 15; // 15 = OrderCouponTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\OrderCoupon object", 0, $e);
@@ -1354,9 +1313,6 @@ abstract class OrderCoupon implements ActiveRecordInterface
if ($this->isColumnModified(OrderCouponTableMap::EXPIRATION_DATE)) {
$modifiedColumns[':p' . $index++] = '`EXPIRATION_DATE`';
}
if ($this->isColumnModified(OrderCouponTableMap::MAX_USAGE)) {
$modifiedColumns[':p' . $index++] = '`MAX_USAGE`';
}
if ($this->isColumnModified(OrderCouponTableMap::IS_CUMULATIVE)) {
$modifiedColumns[':p' . $index++] = '`IS_CUMULATIVE`';
}
@@ -1413,9 +1369,6 @@ abstract class OrderCoupon implements ActiveRecordInterface
case '`EXPIRATION_DATE`':
$stmt->bindValue($identifier, $this->expiration_date ? $this->expiration_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case '`MAX_USAGE`':
$stmt->bindValue($identifier, $this->max_usage, PDO::PARAM_INT);
break;
case '`IS_CUMULATIVE`':
$stmt->bindValue($identifier, (int) $this->is_cumulative, PDO::PARAM_INT);
break;
@@ -1524,24 +1477,21 @@ abstract class OrderCoupon implements ActiveRecordInterface
return $this->getExpirationDate();
break;
case 9:
return $this->getMaxUsage();
break;
case 10:
return $this->getIsCumulative();
break;
case 11:
case 10:
return $this->getIsRemovingPostage();
break;
case 12:
case 11:
return $this->getIsAvailableOnSpecialOffers();
break;
case 13:
case 12:
return $this->getSerializedConditions();
break;
case 14:
case 13:
return $this->getCreatedAt();
break;
case 15:
case 14:
return $this->getUpdatedAt();
break;
default:
@@ -1582,13 +1532,12 @@ abstract class OrderCoupon implements ActiveRecordInterface
$keys[6] => $this->getShortDescription(),
$keys[7] => $this->getDescription(),
$keys[8] => $this->getExpirationDate(),
$keys[9] => $this->getMaxUsage(),
$keys[10] => $this->getIsCumulative(),
$keys[11] => $this->getIsRemovingPostage(),
$keys[12] => $this->getIsAvailableOnSpecialOffers(),
$keys[13] => $this->getSerializedConditions(),
$keys[14] => $this->getCreatedAt(),
$keys[15] => $this->getUpdatedAt(),
$keys[9] => $this->getIsCumulative(),
$keys[10] => $this->getIsRemovingPostage(),
$keys[11] => $this->getIsAvailableOnSpecialOffers(),
$keys[12] => $this->getSerializedConditions(),
$keys[13] => $this->getCreatedAt(),
$keys[14] => $this->getUpdatedAt(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
@@ -1661,24 +1610,21 @@ abstract class OrderCoupon implements ActiveRecordInterface
$this->setExpirationDate($value);
break;
case 9:
$this->setMaxUsage($value);
break;
case 10:
$this->setIsCumulative($value);
break;
case 11:
case 10:
$this->setIsRemovingPostage($value);
break;
case 12:
case 11:
$this->setIsAvailableOnSpecialOffers($value);
break;
case 13:
case 12:
$this->setSerializedConditions($value);
break;
case 14:
case 13:
$this->setCreatedAt($value);
break;
case 15:
case 14:
$this->setUpdatedAt($value);
break;
} // switch()
@@ -1714,13 +1660,12 @@ abstract class OrderCoupon implements ActiveRecordInterface
if (array_key_exists($keys[6], $arr)) $this->setShortDescription($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setDescription($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setExpirationDate($arr[$keys[8]]);
if (array_key_exists($keys[9], $arr)) $this->setMaxUsage($arr[$keys[9]]);
if (array_key_exists($keys[10], $arr)) $this->setIsCumulative($arr[$keys[10]]);
if (array_key_exists($keys[11], $arr)) $this->setIsRemovingPostage($arr[$keys[11]]);
if (array_key_exists($keys[12], $arr)) $this->setIsAvailableOnSpecialOffers($arr[$keys[12]]);
if (array_key_exists($keys[13], $arr)) $this->setSerializedConditions($arr[$keys[13]]);
if (array_key_exists($keys[14], $arr)) $this->setCreatedAt($arr[$keys[14]]);
if (array_key_exists($keys[15], $arr)) $this->setUpdatedAt($arr[$keys[15]]);
if (array_key_exists($keys[9], $arr)) $this->setIsCumulative($arr[$keys[9]]);
if (array_key_exists($keys[10], $arr)) $this->setIsRemovingPostage($arr[$keys[10]]);
if (array_key_exists($keys[11], $arr)) $this->setIsAvailableOnSpecialOffers($arr[$keys[11]]);
if (array_key_exists($keys[12], $arr)) $this->setSerializedConditions($arr[$keys[12]]);
if (array_key_exists($keys[13], $arr)) $this->setCreatedAt($arr[$keys[13]]);
if (array_key_exists($keys[14], $arr)) $this->setUpdatedAt($arr[$keys[14]]);
}
/**
@@ -1741,7 +1686,6 @@ abstract class OrderCoupon implements ActiveRecordInterface
if ($this->isColumnModified(OrderCouponTableMap::SHORT_DESCRIPTION)) $criteria->add(OrderCouponTableMap::SHORT_DESCRIPTION, $this->short_description);
if ($this->isColumnModified(OrderCouponTableMap::DESCRIPTION)) $criteria->add(OrderCouponTableMap::DESCRIPTION, $this->description);
if ($this->isColumnModified(OrderCouponTableMap::EXPIRATION_DATE)) $criteria->add(OrderCouponTableMap::EXPIRATION_DATE, $this->expiration_date);
if ($this->isColumnModified(OrderCouponTableMap::MAX_USAGE)) $criteria->add(OrderCouponTableMap::MAX_USAGE, $this->max_usage);
if ($this->isColumnModified(OrderCouponTableMap::IS_CUMULATIVE)) $criteria->add(OrderCouponTableMap::IS_CUMULATIVE, $this->is_cumulative);
if ($this->isColumnModified(OrderCouponTableMap::IS_REMOVING_POSTAGE)) $criteria->add(OrderCouponTableMap::IS_REMOVING_POSTAGE, $this->is_removing_postage);
if ($this->isColumnModified(OrderCouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS)) $criteria->add(OrderCouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, $this->is_available_on_special_offers);
@@ -1819,7 +1763,6 @@ abstract class OrderCoupon implements ActiveRecordInterface
$copyObj->setShortDescription($this->getShortDescription());
$copyObj->setDescription($this->getDescription());
$copyObj->setExpirationDate($this->getExpirationDate());
$copyObj->setMaxUsage($this->getMaxUsage());
$copyObj->setIsCumulative($this->getIsCumulative());
$copyObj->setIsRemovingPostage($this->getIsRemovingPostage());
$copyObj->setIsAvailableOnSpecialOffers($this->getIsAvailableOnSpecialOffers());
@@ -1919,7 +1862,6 @@ abstract class OrderCoupon implements ActiveRecordInterface
$this->short_description = null;
$this->description = null;
$this->expiration_date = null;
$this->max_usage = null;
$this->is_cumulative = null;
$this->is_removing_postage = null;
$this->is_available_on_special_offers = null;

View File

@@ -30,7 +30,6 @@ use Thelia\Model\Map\OrderCouponTableMap;
* @method ChildOrderCouponQuery orderByShortDescription($order = Criteria::ASC) Order by the short_description column
* @method ChildOrderCouponQuery orderByDescription($order = Criteria::ASC) Order by the description column
* @method ChildOrderCouponQuery orderByExpirationDate($order = Criteria::ASC) Order by the expiration_date column
* @method ChildOrderCouponQuery orderByMaxUsage($order = Criteria::ASC) Order by the max_usage column
* @method ChildOrderCouponQuery orderByIsCumulative($order = Criteria::ASC) Order by the is_cumulative column
* @method ChildOrderCouponQuery orderByIsRemovingPostage($order = Criteria::ASC) Order by the is_removing_postage column
* @method ChildOrderCouponQuery orderByIsAvailableOnSpecialOffers($order = Criteria::ASC) Order by the is_available_on_special_offers column
@@ -47,7 +46,6 @@ use Thelia\Model\Map\OrderCouponTableMap;
* @method ChildOrderCouponQuery groupByShortDescription() Group by the short_description column
* @method ChildOrderCouponQuery groupByDescription() Group by the description column
* @method ChildOrderCouponQuery groupByExpirationDate() Group by the expiration_date column
* @method ChildOrderCouponQuery groupByMaxUsage() Group by the max_usage column
* @method ChildOrderCouponQuery groupByIsCumulative() Group by the is_cumulative column
* @method ChildOrderCouponQuery groupByIsRemovingPostage() Group by the is_removing_postage column
* @method ChildOrderCouponQuery groupByIsAvailableOnSpecialOffers() Group by the is_available_on_special_offers column
@@ -75,7 +73,6 @@ use Thelia\Model\Map\OrderCouponTableMap;
* @method ChildOrderCoupon findOneByShortDescription(string $short_description) Return the first ChildOrderCoupon filtered by the short_description column
* @method ChildOrderCoupon findOneByDescription(string $description) Return the first ChildOrderCoupon filtered by the description column
* @method ChildOrderCoupon findOneByExpirationDate(string $expiration_date) Return the first ChildOrderCoupon filtered by the expiration_date column
* @method ChildOrderCoupon findOneByMaxUsage(int $max_usage) Return the first ChildOrderCoupon filtered by the max_usage column
* @method ChildOrderCoupon findOneByIsCumulative(boolean $is_cumulative) Return the first ChildOrderCoupon filtered by the is_cumulative column
* @method ChildOrderCoupon findOneByIsRemovingPostage(boolean $is_removing_postage) Return the first ChildOrderCoupon filtered by the is_removing_postage column
* @method ChildOrderCoupon findOneByIsAvailableOnSpecialOffers(boolean $is_available_on_special_offers) Return the first ChildOrderCoupon filtered by the is_available_on_special_offers column
@@ -92,7 +89,6 @@ use Thelia\Model\Map\OrderCouponTableMap;
* @method array findByShortDescription(string $short_description) Return ChildOrderCoupon objects filtered by the short_description column
* @method array findByDescription(string $description) Return ChildOrderCoupon objects filtered by the description column
* @method array findByExpirationDate(string $expiration_date) Return ChildOrderCoupon objects filtered by the expiration_date column
* @method array findByMaxUsage(int $max_usage) Return ChildOrderCoupon objects filtered by the max_usage column
* @method array findByIsCumulative(boolean $is_cumulative) Return ChildOrderCoupon objects filtered by the is_cumulative column
* @method array findByIsRemovingPostage(boolean $is_removing_postage) Return ChildOrderCoupon objects filtered by the is_removing_postage column
* @method array findByIsAvailableOnSpecialOffers(boolean $is_available_on_special_offers) Return ChildOrderCoupon objects filtered by the is_available_on_special_offers column
@@ -187,7 +183,7 @@ abstract class OrderCouponQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT `ID`, `ORDER_ID`, `CODE`, `TYPE`, `AMOUNT`, `TITLE`, `SHORT_DESCRIPTION`, `DESCRIPTION`, `EXPIRATION_DATE`, `MAX_USAGE`, `IS_CUMULATIVE`, `IS_REMOVING_POSTAGE`, `IS_AVAILABLE_ON_SPECIAL_OFFERS`, `SERIALIZED_CONDITIONS`, `CREATED_AT`, `UPDATED_AT` FROM `order_coupon` WHERE `ID` = :p0';
$sql = 'SELECT `ID`, `ORDER_ID`, `CODE`, `TYPE`, `AMOUNT`, `TITLE`, `SHORT_DESCRIPTION`, `DESCRIPTION`, `EXPIRATION_DATE`, `IS_CUMULATIVE`, `IS_REMOVING_POSTAGE`, `IS_AVAILABLE_ON_SPECIAL_OFFERS`, `SERIALIZED_CONDITIONS`, `CREATED_AT`, `UPDATED_AT` FROM `order_coupon` WHERE `ID` = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -589,47 +585,6 @@ abstract class OrderCouponQuery extends ModelCriteria
return $this->addUsingAlias(OrderCouponTableMap::EXPIRATION_DATE, $expirationDate, $comparison);
}
/**
* Filter the query on the max_usage column
*
* Example usage:
* <code>
* $query->filterByMaxUsage(1234); // WHERE max_usage = 1234
* $query->filterByMaxUsage(array(12, 34)); // WHERE max_usage IN (12, 34)
* $query->filterByMaxUsage(array('min' => 12)); // WHERE max_usage > 12
* </code>
*
* @param mixed $maxUsage The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildOrderCouponQuery The current query, for fluid interface
*/
public function filterByMaxUsage($maxUsage = null, $comparison = null)
{
if (is_array($maxUsage)) {
$useMinMax = false;
if (isset($maxUsage['min'])) {
$this->addUsingAlias(OrderCouponTableMap::MAX_USAGE, $maxUsage['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($maxUsage['max'])) {
$this->addUsingAlias(OrderCouponTableMap::MAX_USAGE, $maxUsage['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(OrderCouponTableMap::MAX_USAGE, $maxUsage, $comparison);
}
/**
* Filter the query on the is_cumulative column
*

View File

@@ -57,7 +57,7 @@ class OrderCouponTableMap extends TableMap
/**
* The total number of columns
*/
const NUM_COLUMNS = 16;
const NUM_COLUMNS = 15;
/**
* The number of lazy-loaded columns
@@ -67,7 +67,7 @@ class OrderCouponTableMap extends TableMap
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 16;
const NUM_HYDRATE_COLUMNS = 15;
/**
* the column name for the ID field
@@ -114,11 +114,6 @@ class OrderCouponTableMap extends TableMap
*/
const EXPIRATION_DATE = 'order_coupon.EXPIRATION_DATE';
/**
* the column name for the MAX_USAGE field
*/
const MAX_USAGE = 'order_coupon.MAX_USAGE';
/**
* the column name for the IS_CUMULATIVE field
*/
@@ -161,12 +156,12 @@ class OrderCouponTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'OrderId', 'Code', 'Type', 'Amount', 'Title', 'ShortDescription', 'Description', 'ExpirationDate', 'MaxUsage', 'IsCumulative', 'IsRemovingPostage', 'IsAvailableOnSpecialOffers', 'SerializedConditions', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'code', 'type', 'amount', 'title', 'shortDescription', 'description', 'expirationDate', 'maxUsage', 'isCumulative', 'isRemovingPostage', 'isAvailableOnSpecialOffers', 'serializedConditions', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(OrderCouponTableMap::ID, OrderCouponTableMap::ORDER_ID, OrderCouponTableMap::CODE, OrderCouponTableMap::TYPE, OrderCouponTableMap::AMOUNT, OrderCouponTableMap::TITLE, OrderCouponTableMap::SHORT_DESCRIPTION, OrderCouponTableMap::DESCRIPTION, OrderCouponTableMap::EXPIRATION_DATE, OrderCouponTableMap::MAX_USAGE, OrderCouponTableMap::IS_CUMULATIVE, OrderCouponTableMap::IS_REMOVING_POSTAGE, OrderCouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, OrderCouponTableMap::SERIALIZED_CONDITIONS, OrderCouponTableMap::CREATED_AT, OrderCouponTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'CODE', 'TYPE', 'AMOUNT', 'TITLE', 'SHORT_DESCRIPTION', 'DESCRIPTION', 'EXPIRATION_DATE', 'MAX_USAGE', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'SERIALIZED_CONDITIONS', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'order_id', 'code', 'type', 'amount', 'title', 'short_description', 'description', 'expiration_date', 'max_usage', 'is_cumulative', 'is_removing_postage', 'is_available_on_special_offers', 'serialized_conditions', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
self::TYPE_PHPNAME => array('Id', 'OrderId', 'Code', 'Type', 'Amount', 'Title', 'ShortDescription', 'Description', 'ExpirationDate', 'IsCumulative', 'IsRemovingPostage', 'IsAvailableOnSpecialOffers', 'SerializedConditions', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'code', 'type', 'amount', 'title', 'shortDescription', 'description', 'expirationDate', 'isCumulative', 'isRemovingPostage', 'isAvailableOnSpecialOffers', 'serializedConditions', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(OrderCouponTableMap::ID, OrderCouponTableMap::ORDER_ID, OrderCouponTableMap::CODE, OrderCouponTableMap::TYPE, OrderCouponTableMap::AMOUNT, OrderCouponTableMap::TITLE, OrderCouponTableMap::SHORT_DESCRIPTION, OrderCouponTableMap::DESCRIPTION, OrderCouponTableMap::EXPIRATION_DATE, OrderCouponTableMap::IS_CUMULATIVE, OrderCouponTableMap::IS_REMOVING_POSTAGE, OrderCouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, OrderCouponTableMap::SERIALIZED_CONDITIONS, OrderCouponTableMap::CREATED_AT, OrderCouponTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'CODE', 'TYPE', 'AMOUNT', 'TITLE', 'SHORT_DESCRIPTION', 'DESCRIPTION', 'EXPIRATION_DATE', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'SERIALIZED_CONDITIONS', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'order_id', 'code', 'type', 'amount', 'title', 'short_description', 'description', 'expiration_date', 'is_cumulative', 'is_removing_postage', 'is_available_on_special_offers', 'serialized_conditions', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, )
);
/**
@@ -176,12 +171,12 @@ class OrderCouponTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'Code' => 2, 'Type' => 3, 'Amount' => 4, 'Title' => 5, 'ShortDescription' => 6, 'Description' => 7, 'ExpirationDate' => 8, 'MaxUsage' => 9, 'IsCumulative' => 10, 'IsRemovingPostage' => 11, 'IsAvailableOnSpecialOffers' => 12, 'SerializedConditions' => 13, 'CreatedAt' => 14, 'UpdatedAt' => 15, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'code' => 2, 'type' => 3, 'amount' => 4, 'title' => 5, 'shortDescription' => 6, 'description' => 7, 'expirationDate' => 8, 'maxUsage' => 9, 'isCumulative' => 10, 'isRemovingPostage' => 11, 'isAvailableOnSpecialOffers' => 12, 'serializedConditions' => 13, 'createdAt' => 14, 'updatedAt' => 15, ),
self::TYPE_COLNAME => array(OrderCouponTableMap::ID => 0, OrderCouponTableMap::ORDER_ID => 1, OrderCouponTableMap::CODE => 2, OrderCouponTableMap::TYPE => 3, OrderCouponTableMap::AMOUNT => 4, OrderCouponTableMap::TITLE => 5, OrderCouponTableMap::SHORT_DESCRIPTION => 6, OrderCouponTableMap::DESCRIPTION => 7, OrderCouponTableMap::EXPIRATION_DATE => 8, OrderCouponTableMap::MAX_USAGE => 9, OrderCouponTableMap::IS_CUMULATIVE => 10, OrderCouponTableMap::IS_REMOVING_POSTAGE => 11, OrderCouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 12, OrderCouponTableMap::SERIALIZED_CONDITIONS => 13, OrderCouponTableMap::CREATED_AT => 14, OrderCouponTableMap::UPDATED_AT => 15, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'CODE' => 2, 'TYPE' => 3, 'AMOUNT' => 4, 'TITLE' => 5, 'SHORT_DESCRIPTION' => 6, 'DESCRIPTION' => 7, 'EXPIRATION_DATE' => 8, 'MAX_USAGE' => 9, 'IS_CUMULATIVE' => 10, 'IS_REMOVING_POSTAGE' => 11, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 12, 'SERIALIZED_CONDITIONS' => 13, 'CREATED_AT' => 14, 'UPDATED_AT' => 15, ),
self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'code' => 2, 'type' => 3, 'amount' => 4, 'title' => 5, 'short_description' => 6, 'description' => 7, 'expiration_date' => 8, 'max_usage' => 9, 'is_cumulative' => 10, 'is_removing_postage' => 11, 'is_available_on_special_offers' => 12, 'serialized_conditions' => 13, 'created_at' => 14, 'updated_at' => 15, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'Code' => 2, 'Type' => 3, 'Amount' => 4, 'Title' => 5, 'ShortDescription' => 6, 'Description' => 7, 'ExpirationDate' => 8, 'IsCumulative' => 9, 'IsRemovingPostage' => 10, 'IsAvailableOnSpecialOffers' => 11, 'SerializedConditions' => 12, 'CreatedAt' => 13, 'UpdatedAt' => 14, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'code' => 2, 'type' => 3, 'amount' => 4, 'title' => 5, 'shortDescription' => 6, 'description' => 7, 'expirationDate' => 8, 'isCumulative' => 9, 'isRemovingPostage' => 10, 'isAvailableOnSpecialOffers' => 11, 'serializedConditions' => 12, 'createdAt' => 13, 'updatedAt' => 14, ),
self::TYPE_COLNAME => array(OrderCouponTableMap::ID => 0, OrderCouponTableMap::ORDER_ID => 1, OrderCouponTableMap::CODE => 2, OrderCouponTableMap::TYPE => 3, OrderCouponTableMap::AMOUNT => 4, OrderCouponTableMap::TITLE => 5, OrderCouponTableMap::SHORT_DESCRIPTION => 6, OrderCouponTableMap::DESCRIPTION => 7, OrderCouponTableMap::EXPIRATION_DATE => 8, OrderCouponTableMap::IS_CUMULATIVE => 9, OrderCouponTableMap::IS_REMOVING_POSTAGE => 10, OrderCouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 11, OrderCouponTableMap::SERIALIZED_CONDITIONS => 12, OrderCouponTableMap::CREATED_AT => 13, OrderCouponTableMap::UPDATED_AT => 14, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'CODE' => 2, 'TYPE' => 3, 'AMOUNT' => 4, 'TITLE' => 5, 'SHORT_DESCRIPTION' => 6, 'DESCRIPTION' => 7, 'EXPIRATION_DATE' => 8, 'IS_CUMULATIVE' => 9, 'IS_REMOVING_POSTAGE' => 10, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 11, 'SERIALIZED_CONDITIONS' => 12, 'CREATED_AT' => 13, 'UPDATED_AT' => 14, ),
self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'code' => 2, 'type' => 3, 'amount' => 4, 'title' => 5, 'short_description' => 6, 'description' => 7, 'expiration_date' => 8, 'is_cumulative' => 9, 'is_removing_postage' => 10, 'is_available_on_special_offers' => 11, 'serialized_conditions' => 12, 'created_at' => 13, 'updated_at' => 14, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, )
);
/**
@@ -209,7 +204,6 @@ class OrderCouponTableMap extends TableMap
$this->addColumn('SHORT_DESCRIPTION', 'ShortDescription', 'LONGVARCHAR', true, null, null);
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', true, null, null);
$this->addColumn('EXPIRATION_DATE', 'ExpirationDate', 'TIMESTAMP', true, null, null);
$this->addColumn('MAX_USAGE', 'MaxUsage', 'INTEGER', true, null, null);
$this->addColumn('IS_CUMULATIVE', 'IsCumulative', 'BOOLEAN', true, 1, null);
$this->addColumn('IS_REMOVING_POSTAGE', 'IsRemovingPostage', 'BOOLEAN', true, 1, null);
$this->addColumn('IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IsAvailableOnSpecialOffers', 'BOOLEAN', true, 1, null);
@@ -386,7 +380,6 @@ class OrderCouponTableMap extends TableMap
$criteria->addSelectColumn(OrderCouponTableMap::SHORT_DESCRIPTION);
$criteria->addSelectColumn(OrderCouponTableMap::DESCRIPTION);
$criteria->addSelectColumn(OrderCouponTableMap::EXPIRATION_DATE);
$criteria->addSelectColumn(OrderCouponTableMap::MAX_USAGE);
$criteria->addSelectColumn(OrderCouponTableMap::IS_CUMULATIVE);
$criteria->addSelectColumn(OrderCouponTableMap::IS_REMOVING_POSTAGE);
$criteria->addSelectColumn(OrderCouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS);
@@ -403,7 +396,6 @@ class OrderCouponTableMap extends TableMap
$criteria->addSelectColumn($alias . '.SHORT_DESCRIPTION');
$criteria->addSelectColumn($alias . '.DESCRIPTION');
$criteria->addSelectColumn($alias . '.EXPIRATION_DATE');
$criteria->addSelectColumn($alias . '.MAX_USAGE');
$criteria->addSelectColumn($alias . '.IS_CUMULATIVE');
$criteria->addSelectColumn($alias . '.IS_REMOVING_POSTAGE');
$criteria->addSelectColumn($alias . '.IS_AVAILABLE_ON_SPECIAL_OFFERS');

View File

@@ -156,7 +156,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
$couponFactory = new CouponFactory($stubContainer);
$model1 = $this->generateCouponModel($stubFacade, $conditionFactory);
$model1->setAmount(21.00);
$model1->setCode('XMAS')->setIsRemovingPostage(false)->setAmount(21.00);
$coupon1 = $couponFactory->buildCouponFromModel($model1);
$model2 = $this->generateCouponModel($stubFacade, $conditionFactory);
@@ -174,12 +174,16 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
->will($this->returnValue(122.53));
$couponManager = new CouponManager($stubContainer);
$couponManager->addAvailableCoupon($coupon1);
$couponManager->addAvailableCoupon($coupon2);
$actual = $couponManager->getDiscount();
$expected = 50.80;
$expected = 21 + 21.50;
$this->assertEquals($expected, $actual);
$this->assertTrue($couponManager->isCouponRemovingPostage());
}
/**

View File

@@ -1616,7 +1616,6 @@ CREATE TABLE `order_coupon`
`short_description` TEXT NOT NULL,
`description` LONGTEXT NOT NULL,
`expiration_date` DATETIME NOT NULL,
`max_usage` INTEGER NOT NULL,
`is_cumulative` TINYINT(1) NOT NULL,
`is_removing_postage` TINYINT(1) NOT NULL,
`is_available_on_special_offers` TINYINT(1) NOT NULL,