Merge branch 'master' of github.com:thelia/thelia
@@ -25,14 +25,14 @@ namespace Thelia\Action;
|
|||||||
|
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Thelia\Condition\ConditionFactory;
|
use Thelia\Condition\ConditionFactory;
|
||||||
use Thelia\Condition\ConditionManagerInterface;
|
use Thelia\Condition\Implementation\ConditionInterface;
|
||||||
use Thelia\Core\Event\Coupon\CouponConsumeEvent;
|
use Thelia\Core\Event\Coupon\CouponConsumeEvent;
|
||||||
use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent;
|
use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent;
|
||||||
use Thelia\Core\Event\TheliaEvents;
|
use Thelia\Core\Event\TheliaEvents;
|
||||||
use Thelia\Core\HttpFoundation\Request;
|
use Thelia\Core\HttpFoundation\Request;
|
||||||
use Thelia\Coupon\CouponFactory;
|
use Thelia\Coupon\CouponFactory;
|
||||||
use Thelia\Coupon\CouponManager;
|
use Thelia\Coupon\CouponManager;
|
||||||
use Thelia\Coupon\ConditionCollection;
|
use Thelia\Condition\ConditionCollection;
|
||||||
use Thelia\Coupon\Type\CouponInterface;
|
use Thelia\Coupon\Type\CouponInterface;
|
||||||
use Thelia\Model\Coupon as CouponModel;
|
use Thelia\Model\Coupon as CouponModel;
|
||||||
use Thelia\Model\CouponQuery;
|
use Thelia\Model\CouponQuery;
|
||||||
@@ -94,6 +94,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
|||||||
public function consume(CouponConsumeEvent $event)
|
public function consume(CouponConsumeEvent $event)
|
||||||
{
|
{
|
||||||
$totalDiscount = 0;
|
$totalDiscount = 0;
|
||||||
|
$isValid = false;
|
||||||
|
|
||||||
/** @var CouponFactory $couponFactory */
|
/** @var CouponFactory $couponFactory */
|
||||||
$couponFactory = $this->container->get('thelia.coupon.factory');
|
$couponFactory = $this->container->get('thelia.coupon.factory');
|
||||||
@@ -104,40 +105,40 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
|||||||
/** @var CouponInterface $coupon */
|
/** @var CouponInterface $coupon */
|
||||||
$coupon = $couponFactory->buildCouponFromCode($event->getCode());
|
$coupon = $couponFactory->buildCouponFromCode($event->getCode());
|
||||||
|
|
||||||
$isValid = $coupon->isMatching();
|
if ($coupon) {
|
||||||
|
$isValid = $coupon->isMatching();
|
||||||
|
if ($isValid) {
|
||||||
|
/** @var Request $request */
|
||||||
|
$request = $this->container->get('request');
|
||||||
|
$consumedCoupons = $request->getSession()->getConsumedCoupons();
|
||||||
|
|
||||||
if ($isValid) {
|
if (!isset($consumedCoupons) || !$consumedCoupons) {
|
||||||
/** @var Request $request */
|
$consumedCoupons = array();
|
||||||
$request = $this->container->get('request');
|
}
|
||||||
$consumedCoupons = $request->getSession()->getConsumedCoupons();
|
|
||||||
|
|
||||||
if (!isset($consumedCoupons) || !$consumedCoupons) {
|
// Prevent accumulation of the same Coupon on a Checkout
|
||||||
$consumedCoupons = array();
|
$consumedCoupons[$event->getCode()] = $event->getCode();
|
||||||
|
|
||||||
|
$request->getSession()->setConsumedCoupons($consumedCoupons);
|
||||||
|
|
||||||
|
$totalDiscount = $couponManager->getDiscount();
|
||||||
|
// @todo insert false product in cart with the name of the coupon and the discount as negative price
|
||||||
|
|
||||||
|
// Decrement coupon quantity
|
||||||
|
// @todo move this part in after order event
|
||||||
|
$couponQuery = CouponQuery::create();
|
||||||
|
$couponModel = $couponQuery->findOneByCode($coupon->getCode());
|
||||||
|
$couponManager->decrementQuantity($couponModel);
|
||||||
|
|
||||||
|
$request
|
||||||
|
->getSession()
|
||||||
|
->getCart()
|
||||||
|
->setDiscount($totalDiscount)
|
||||||
|
->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent accumulation of the same Coupon on a Checkout
|
|
||||||
$consumedCoupons[$event->getCode()] = $event->getCode();
|
|
||||||
|
|
||||||
$request->getSession()->setConsumedCoupons($consumedCoupons);
|
|
||||||
|
|
||||||
$totalDiscount = $couponManager->getDiscount();
|
|
||||||
// @todo insert false product in cart with the name of the coupon and the discount as negative price
|
|
||||||
|
|
||||||
// Decrement coupon quantity
|
|
||||||
// @todo move this part in after order event
|
|
||||||
$couponQuery = CouponQuery::create();
|
|
||||||
$couponModel = $couponQuery->findOneByCode($coupon->getCode());
|
|
||||||
$couponManager->decrementeQuantity($couponModel);
|
|
||||||
|
|
||||||
$request
|
|
||||||
->getSession()
|
|
||||||
->getCart()
|
|
||||||
->setDiscount($totalDiscount)
|
|
||||||
->save()
|
|
||||||
;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$event->setIsValid($isValid);
|
$event->setIsValid($isValid);
|
||||||
$event->setDiscount($totalDiscount);
|
$event->setDiscount($totalDiscount);
|
||||||
}
|
}
|
||||||
@@ -154,7 +155,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
|||||||
$coupon->setDispatcher($this->getDispatcher());
|
$coupon->setDispatcher($this->getDispatcher());
|
||||||
|
|
||||||
// Set default condition if none found
|
// Set default condition if none found
|
||||||
/** @var ConditionManagerInterface $noConditionRule */
|
/** @var ConditionInterface $noConditionRule */
|
||||||
$noConditionRule = $this->container->get('thelia.condition.match_for_everyone');
|
$noConditionRule = $this->container->get('thelia.condition.match_for_everyone');
|
||||||
/** @var ConditionFactory $conditionFactory */
|
/** @var ConditionFactory $conditionFactory */
|
||||||
$conditionFactory = $this->container->get('thelia.condition.factory');
|
$conditionFactory = $this->container->get('thelia.condition.factory');
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ class Product extends BaseAction implements EventSubscriberInterface
|
|||||||
->save()
|
->save()
|
||||||
;
|
;
|
||||||
|
|
||||||
// Update the rewriten URL, if required
|
// Update the rewritten URL, if required
|
||||||
$product->setRewrittenUrl($event->getLocale(), $event->getUrl());
|
$product->setRewrittenUrl($event->getLocale(), $event->getUrl());
|
||||||
|
|
||||||
// Update default category (ifd required)
|
// Update default category (ifd required)
|
||||||
|
|||||||
@@ -21,17 +21,17 @@
|
|||||||
/* */
|
/* */
|
||||||
/**********************************************************************************/
|
/**********************************************************************************/
|
||||||
|
|
||||||
namespace Thelia\Coupon;
|
namespace Thelia\Condition;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Thelia\Condition\ConditionManagerInterface;
|
use Thelia\Condition\Implementation\ConditionInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by JetBrains PhpStorm.
|
* Created by JetBrains PhpStorm.
|
||||||
* Date: 8/19/13
|
* Date: 8/19/13
|
||||||
* Time: 3:24 PM
|
* Time: 3:24 PM
|
||||||
*
|
*
|
||||||
* Manage a set of ConditionManagerInterface
|
* Manage a set of ConditionInterface
|
||||||
*
|
*
|
||||||
* @package Condition
|
* @package Condition
|
||||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
@@ -39,13 +39,13 @@ use Thelia\Condition\ConditionManagerInterface;
|
|||||||
*/
|
*/
|
||||||
class ConditionCollection
|
class ConditionCollection
|
||||||
{
|
{
|
||||||
/** @var array Array of ConditionManagerInterface */
|
/** @var array Array of ConditionInterface */
|
||||||
protected $conditions = array();
|
protected $conditions = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Conditions
|
* Get Conditions
|
||||||
*
|
*
|
||||||
* @return array Array of ConditionManagerInterface
|
* @return array Array of ConditionInterface
|
||||||
*/
|
*/
|
||||||
public function getConditions()
|
public function getConditions()
|
||||||
{
|
{
|
||||||
@@ -53,13 +53,13 @@ class ConditionCollection
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a ConditionManagerInterface to the Collection
|
* Add a ConditionInterface to the Collection
|
||||||
*
|
*
|
||||||
* @param ConditionManagerInterface $condition Condition
|
* @param ConditionInterface $condition Condition
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function add(ConditionManagerInterface $condition)
|
public function add(ConditionInterface $condition)
|
||||||
{
|
{
|
||||||
$this->conditions[] = $condition;
|
$this->conditions[] = $condition;
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ class ConditionCollection
|
|||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
$arrayToSerialize = array();
|
$arrayToSerialize = array();
|
||||||
/** @var ConditionManagerInterface $condition */
|
/** @var ConditionInterface $condition */
|
||||||
foreach ($this->getConditions() as $condition) {
|
foreach ($this->getConditions() as $condition) {
|
||||||
$arrayToSerialize[] = $condition->getSerializableCondition();
|
$arrayToSerialize[] = $condition->getSerializableCondition();
|
||||||
}
|
}
|
||||||
@@ -24,8 +24,9 @@
|
|||||||
namespace Thelia\Condition;
|
namespace Thelia\Condition;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
use Thelia\Condition\Implementation\ConditionInterface;
|
||||||
use Thelia\Condition\Operators;
|
use Thelia\Condition\Operators;
|
||||||
use Thelia\Coupon\ConditionCollection;
|
use Thelia\Condition\ConditionCollection;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,7 +52,7 @@ class ConditionEvaluator
|
|||||||
public function isMatching(ConditionCollection $conditions)
|
public function isMatching(ConditionCollection $conditions)
|
||||||
{
|
{
|
||||||
$isMatching = true;
|
$isMatching = true;
|
||||||
/** @var ConditionManagerInterface $condition */
|
/** @var ConditionInterface $condition */
|
||||||
foreach ($conditions->getConditions() as $condition) {
|
foreach ($conditions->getConditions() as $condition) {
|
||||||
if (!$condition->isMatching()) {
|
if (!$condition->isMatching()) {
|
||||||
$isMatching = false;
|
$isMatching = false;
|
||||||
|
|||||||
@@ -24,8 +24,9 @@
|
|||||||
namespace Thelia\Condition;
|
namespace Thelia\Condition;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
use Thelia\Condition\Implementation\ConditionInterface;
|
||||||
use Thelia\Coupon\FacadeInterface;
|
use Thelia\Coupon\FacadeInterface;
|
||||||
use Thelia\Coupon\ConditionCollection;
|
use Thelia\Condition\ConditionCollection;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,7 +59,7 @@ class ConditionFactory
|
|||||||
public function __construct(ContainerInterface $container)
|
public function __construct(ContainerInterface $container)
|
||||||
{
|
{
|
||||||
$this->container = $container;
|
$this->container = $container;
|
||||||
$this->adapter = $container->get('thelia.adapter');
|
$this->adapter = $container->get('thelia.facade');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,7 +72,7 @@ class ConditionFactory
|
|||||||
public function serializeConditionCollection(ConditionCollection $collection)
|
public function serializeConditionCollection(ConditionCollection $collection)
|
||||||
{
|
{
|
||||||
if ($collection->isEmpty()) {
|
if ($collection->isEmpty()) {
|
||||||
/** @var ConditionManagerInterface $conditionNone */
|
/** @var ConditionInterface $conditionNone */
|
||||||
$conditionNone = $this->container->get(
|
$conditionNone = $this->container->get(
|
||||||
'thelia.condition.match_for_everyone'
|
'thelia.condition.match_for_everyone'
|
||||||
);
|
);
|
||||||
@@ -80,7 +81,7 @@ class ConditionFactory
|
|||||||
$serializableConditions = array();
|
$serializableConditions = array();
|
||||||
$conditions = $collection->getConditions();
|
$conditions = $collection->getConditions();
|
||||||
if ($conditions !== null) {
|
if ($conditions !== null) {
|
||||||
/** @var $condition ConditionManagerInterface */
|
/** @var $condition ConditionInterface */
|
||||||
foreach ($conditions as $condition) {
|
foreach ($conditions as $condition) {
|
||||||
$serializableConditions[] = $condition->getSerializableCondition();
|
$serializableConditions[] = $condition->getSerializableCondition();
|
||||||
}
|
}
|
||||||
@@ -106,7 +107,7 @@ class ConditionFactory
|
|||||||
/** @var SerializableCondition $condition */
|
/** @var SerializableCondition $condition */
|
||||||
foreach ($unserializedConditions as $condition) {
|
foreach ($unserializedConditions as $condition) {
|
||||||
if ($this->container->has($condition->conditionServiceId)) {
|
if ($this->container->has($condition->conditionServiceId)) {
|
||||||
/** @var ConditionManagerInterface $conditionManager */
|
/** @var ConditionInterface $conditionManager */
|
||||||
$conditionManager = $this->build(
|
$conditionManager = $this->build(
|
||||||
$condition->conditionServiceId,
|
$condition->conditionServiceId,
|
||||||
(array) $condition->operators,
|
(array) $condition->operators,
|
||||||
@@ -129,7 +130,7 @@ class ConditionFactory
|
|||||||
* @param array $values Values setting this Condition
|
* @param array $values Values setting this Condition
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @return ConditionManagerInterface Ready to use Condition or false
|
* @return ConditionInterface Ready to use Condition or false
|
||||||
*/
|
*/
|
||||||
public function build($conditionServiceId, array $operators, array $values)
|
public function build($conditionServiceId, array $operators, array $values)
|
||||||
{
|
{
|
||||||
@@ -137,7 +138,7 @@ class ConditionFactory
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var ConditionManagerInterface $condition */
|
/** @var ConditionInterface $condition */
|
||||||
$condition = $this->container->get($conditionServiceId);
|
$condition = $this->container->get($conditionServiceId);
|
||||||
$condition->setValidatorsFromForm($operators, $values);
|
$condition->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
@@ -157,7 +158,7 @@ class ConditionFactory
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var ConditionManagerInterface $condition */
|
/** @var ConditionInterface $condition */
|
||||||
$condition = $this->container->get($conditionServiceId);
|
$condition = $this->container->get($conditionServiceId);
|
||||||
|
|
||||||
return $condition->getValidators();
|
return $condition->getValidators();
|
||||||
|
|||||||
@@ -21,27 +21,27 @@
|
|||||||
/* */
|
/* */
|
||||||
/**********************************************************************************/
|
/**********************************************************************************/
|
||||||
|
|
||||||
namespace Thelia\Coupon;
|
namespace Thelia\Condition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by JetBrains PhpStorm.
|
* Created by JetBrains PhpStorm.
|
||||||
* Date: 8/19/13
|
* Date: 8/19/13
|
||||||
* Time: 3:24 PM
|
* Time: 3:24 PM
|
||||||
*
|
*
|
||||||
* Manage how Coupons could interact with a Checkout
|
* Manage how Condition could interact with each others
|
||||||
*
|
*
|
||||||
* @package Condition
|
* @package Condition
|
||||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class RuleOrganizer implements RuleOrganizerInterface
|
class ConditionOrganizer implements ConditionOrganizerInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Organize ConditionManagerInterface
|
* Organize ConditionInterface
|
||||||
*
|
*
|
||||||
* @param array $conditions Array of ConditionManagerInterface
|
* @param array $conditions Array of ConditionInterface
|
||||||
*
|
*
|
||||||
* @return array Array of ConditionManagerInterface sorted
|
* @return array Array of ConditionInterface sorted
|
||||||
*/
|
*/
|
||||||
public function organize(array $conditions)
|
public function organize(array $conditions)
|
||||||
{
|
{
|
||||||
@@ -21,27 +21,27 @@
|
|||||||
/* */
|
/* */
|
||||||
/**********************************************************************************/
|
/**********************************************************************************/
|
||||||
|
|
||||||
namespace Thelia\Coupon;
|
namespace Thelia\Condition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by JetBrains PhpStorm.
|
* Created by JetBrains PhpStorm.
|
||||||
* Date: 8/19/13
|
* Date: 8/19/13
|
||||||
* Time: 3:24 PM
|
* Time: 3:24 PM
|
||||||
*
|
*
|
||||||
* Manage how Condition could interact with a Checkout
|
* Manage how Condition could interact with each other
|
||||||
*
|
*
|
||||||
* @package Condition
|
* @package Condition
|
||||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
interface RuleOrganizerInterface
|
interface ConditionOrganizerInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Organize ConditionManagerInterface
|
* Organize ConditionInterface
|
||||||
*
|
*
|
||||||
* @param array $conditions Array of ConditionManagerInterface
|
* @param array $conditions Array of ConditionInterface
|
||||||
*
|
*
|
||||||
* @return array Array of ConditionManagerInterface sorted
|
* @return array Array of ConditionInterface sorted
|
||||||
*/
|
*/
|
||||||
public function organize(array $conditions);
|
public function organize(array $conditions);
|
||||||
}
|
}
|
||||||
@@ -21,9 +21,12 @@
|
|||||||
/* */
|
/* */
|
||||||
/**********************************************************************************/
|
/**********************************************************************************/
|
||||||
|
|
||||||
namespace Thelia\Condition;
|
namespace Thelia\Condition\Implementation;
|
||||||
|
|
||||||
use Symfony\Component\Intl\Exception\NotImplementedException;
|
use Symfony\Component\Intl\Exception\NotImplementedException;
|
||||||
|
use Thelia\Condition\ConditionEvaluator;
|
||||||
|
use Thelia\Condition\Operators;
|
||||||
|
use Thelia\Condition\SerializableCondition;
|
||||||
use Thelia\Core\Translation\Translator;
|
use Thelia\Core\Translation\Translator;
|
||||||
use Thelia\Coupon\FacadeInterface;
|
use Thelia\Coupon\FacadeInterface;
|
||||||
use Thelia\Exception\InvalidConditionValueException;
|
use Thelia\Exception\InvalidConditionValueException;
|
||||||
@@ -35,13 +38,13 @@ use Thelia\Type\FloatType;
|
|||||||
* Date: 8/19/13
|
* Date: 8/19/13
|
||||||
* Time: 3:24 PM
|
* Time: 3:24 PM
|
||||||
*
|
*
|
||||||
* Assist in writing a condition of whether the Rule is applied or not
|
* Assist in writing a condition of whether the Condition is applied or not
|
||||||
*
|
*
|
||||||
* @package Constraint
|
* @package Constraint
|
||||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
abstract class ConditionManagerAbstract implements ConditionManagerInterface
|
abstract class ConditionAbstract implements ConditionInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
/** @var string Service Id from Resources/config.xml */
|
/** @var string Service Id from Resources/config.xml */
|
||||||
@@ -54,7 +57,7 @@ abstract class ConditionManagerAbstract implements ConditionManagerInterface
|
|||||||
protected $validators = array();
|
protected $validators = array();
|
||||||
|
|
||||||
/** @var FacadeInterface Provide necessary value from Thelia */
|
/** @var FacadeInterface Provide necessary value from Thelia */
|
||||||
protected $adapter = null;
|
protected $facade = null;
|
||||||
|
|
||||||
/** @var Translator Service Translator */
|
/** @var Translator Service Translator */
|
||||||
protected $translator = null;
|
protected $translator = null;
|
||||||
@@ -71,13 +74,13 @@ abstract class ConditionManagerAbstract implements ConditionManagerInterface
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param FacadeInterface $adapter Service adapter
|
* @param FacadeInterface $facade Service Facade
|
||||||
*/
|
*/
|
||||||
public function __construct(FacadeInterface $adapter)
|
public function __construct(FacadeInterface $facade)
|
||||||
{
|
{
|
||||||
$this->adapter = $adapter;
|
$this->facade = $facade;
|
||||||
$this->translator = $adapter->getTranslator();
|
$this->translator = $facade->getTranslator();
|
||||||
$this->conditionValidator = $adapter->getConditionEvaluator();
|
$this->conditionValidator = $facade->getConditionEvaluator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -181,9 +184,9 @@ abstract class ConditionManagerAbstract implements ConditionManagerInterface
|
|||||||
* @return bool
|
* @return bool
|
||||||
* @throws \Thelia\Exception\InvalidConditionValueException
|
* @throws \Thelia\Exception\InvalidConditionValueException
|
||||||
*/
|
*/
|
||||||
protected function IsCurrencyValid($currencyValue)
|
protected function isCurrencyValid($currencyValue)
|
||||||
{
|
{
|
||||||
$availableCurrencies = $this->adapter->getAvailableCurrencies();
|
$availableCurrencies = $this->facade->getAvailableCurrencies();
|
||||||
/** @var Currency $currency */
|
/** @var Currency $currency */
|
||||||
$currencyFound = false;
|
$currencyFound = false;
|
||||||
foreach ($availableCurrencies as $currency) {
|
foreach ($availableCurrencies as $currency) {
|
||||||
@@ -21,8 +21,9 @@
|
|||||||
/* */
|
/* */
|
||||||
/**********************************************************************************/
|
/**********************************************************************************/
|
||||||
|
|
||||||
namespace Thelia\Condition;
|
namespace Thelia\Condition\Implementation;
|
||||||
|
|
||||||
|
use Thelia\Condition\SerializableCondition;
|
||||||
use Thelia\Core\Translation\Translator;
|
use Thelia\Core\Translation\Translator;
|
||||||
use Thelia\Coupon\FacadeInterface;
|
use Thelia\Coupon\FacadeInterface;
|
||||||
|
|
||||||
@@ -37,7 +38,7 @@ use Thelia\Coupon\FacadeInterface;
|
|||||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
interface ConditionManagerInterface
|
interface ConditionInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -47,7 +48,7 @@ interface ConditionManagerInterface
|
|||||||
function __construct(FacadeInterface $adapter);
|
function __construct(FacadeInterface $adapter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Rule Service id
|
* Get Condition Service id
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
namespace Thelia\Condition\Implementation;
|
namespace Thelia\Condition\Implementation;
|
||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Thelia\Condition\ConditionManagerAbstract;
|
use Thelia\Condition\Implementation\ConditionAbstract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by JetBrains PhpStorm.
|
* Created by JetBrains PhpStorm.
|
||||||
@@ -37,7 +37,7 @@ use Thelia\Condition\ConditionManagerAbstract;
|
|||||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class MatchForEveryoneManager extends ConditionManagerAbstract
|
class MatchForEveryone extends ConditionAbstract
|
||||||
{
|
{
|
||||||
/** @var string Service Id from Resources/config.xml */
|
/** @var string Service Id from Resources/config.xml */
|
||||||
protected $serviceId = 'thelia.condition.match_for_everyone';
|
protected $serviceId = 'thelia.condition.match_for_everyone';
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
namespace Thelia\Condition\Implementation;
|
namespace Thelia\Condition\Implementation;
|
||||||
|
|
||||||
use Symfony\Component\Intl\Exception\NotImplementedException;
|
use Symfony\Component\Intl\Exception\NotImplementedException;
|
||||||
use Thelia\Condition\ConditionManagerAbstract;
|
use Thelia\Condition\Implementation\ConditionAbstract;
|
||||||
use Thelia\Condition\Operators;
|
use Thelia\Condition\Operators;
|
||||||
use Thelia\Exception\InvalidConditionOperatorException;
|
use Thelia\Exception\InvalidConditionOperatorException;
|
||||||
use Thelia\Model\Currency;
|
use Thelia\Model\Currency;
|
||||||
@@ -42,7 +42,7 @@ use Thelia\Model\CurrencyQuery;
|
|||||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class MatchForTotalAmountManager extends ConditionManagerAbstract
|
class MatchForTotalAmount extends ConditionAbstract
|
||||||
{
|
{
|
||||||
/** Condition 1st parameter : price */
|
/** Condition 1st parameter : price */
|
||||||
CONST INPUT1 = 'price';
|
CONST INPUT1 = 'price';
|
||||||
@@ -124,7 +124,7 @@ class MatchForTotalAmountManager extends ConditionManagerAbstract
|
|||||||
$this->isPriceValid($priceValue);
|
$this->isPriceValid($priceValue);
|
||||||
|
|
||||||
|
|
||||||
$this->IsCurrencyValid($currencyValue);
|
$this->isCurrencyValid($currencyValue);
|
||||||
|
|
||||||
|
|
||||||
$this->operators = array(
|
$this->operators = array(
|
||||||
@@ -146,26 +146,13 @@ class MatchForTotalAmountManager extends ConditionManagerAbstract
|
|||||||
*/
|
*/
|
||||||
public function isMatching()
|
public function isMatching()
|
||||||
{
|
{
|
||||||
$isOperator1Legit = $this->isOperatorLegit(
|
|
||||||
$this->operators[self::INPUT1],
|
|
||||||
$this->availableOperators[self::INPUT1]
|
|
||||||
);
|
|
||||||
$isOperator2Legit = $this->isOperatorLegit(
|
|
||||||
$this->operators[self::INPUT2],
|
|
||||||
$this->availableOperators[self::INPUT2]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!$isOperator1Legit || !$isOperator2Legit) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$condition1 = $this->conditionValidator->variableOpComparison(
|
$condition1 = $this->conditionValidator->variableOpComparison(
|
||||||
$this->adapter->getCartTotalPrice(),
|
$this->facade->getCartTotalPrice(),
|
||||||
$this->operators[self::INPUT1],
|
$this->operators[self::INPUT1],
|
||||||
$this->values[self::INPUT1]
|
$this->values[self::INPUT1]
|
||||||
);
|
);
|
||||||
$condition2 = $this->conditionValidator->variableOpComparison(
|
$condition2 = $this->conditionValidator->variableOpComparison(
|
||||||
$this->adapter->getCheckoutCurrency(),
|
$this->facade->getCheckoutCurrency(),
|
||||||
$this->operators[self::INPUT2],
|
$this->operators[self::INPUT2],
|
||||||
$this->values[self::INPUT2]
|
$this->values[self::INPUT2]
|
||||||
);
|
);
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
namespace Thelia\Condition\Implementation;
|
namespace Thelia\Condition\Implementation;
|
||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Thelia\Condition\ConditionManagerAbstract;
|
use Thelia\Condition\Implementation\ConditionAbstract;
|
||||||
use Thelia\Condition\Operators;
|
use Thelia\Condition\Operators;
|
||||||
use Thelia\Exception\InvalidConditionOperatorException;
|
use Thelia\Exception\InvalidConditionOperatorException;
|
||||||
use Thelia\Exception\InvalidConditionValueException;
|
use Thelia\Exception\InvalidConditionValueException;
|
||||||
@@ -40,7 +40,7 @@ use Thelia\Exception\InvalidConditionValueException;
|
|||||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class MatchForXArticlesManager extends ConditionManagerAbstract
|
class MatchForXArticles extends ConditionAbstract
|
||||||
{
|
{
|
||||||
/** Condition 1st parameter : quantity */
|
/** Condition 1st parameter : quantity */
|
||||||
CONST INPUT1 = 'quantity';
|
CONST INPUT1 = 'quantity';
|
||||||
@@ -124,7 +124,7 @@ class MatchForXArticlesManager extends ConditionManagerAbstract
|
|||||||
public function isMatching()
|
public function isMatching()
|
||||||
{
|
{
|
||||||
$condition1 = $this->conditionValidator->variableOpComparison(
|
$condition1 = $this->conditionValidator->variableOpComparison(
|
||||||
$this->adapter->getNbArticlesInCart(),
|
$this->facade->getNbArticlesInCart(),
|
||||||
$this->operators[self::INPUT1],
|
$this->operators[self::INPUT1],
|
||||||
$this->values[self::INPUT1]
|
$this->values[self::INPUT1]
|
||||||
);
|
);
|
||||||
@@ -28,7 +28,7 @@ namespace Thelia\Condition;
|
|||||||
* Date: 8/19/13
|
* Date: 8/19/13
|
||||||
* Time: 3:24 PM
|
* Time: 3:24 PM
|
||||||
*
|
*
|
||||||
* A condition set by an admin ready to be serialized and stored in DataBase
|
* A condition ready to be serialized and stored in DataBase
|
||||||
*
|
*
|
||||||
* @package Condition
|
* @package Condition
|
||||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<!-- Coupon module -->
|
<!-- Coupon module -->
|
||||||
<service id="thelia.adapter" class="Thelia\Coupon\BaseFacade">
|
<service id="thelia.facade" class="Thelia\Coupon\BaseFacade">
|
||||||
<argument type="service" id="service_container" />
|
<argument type="service" id="service_container" />
|
||||||
</service>
|
</service>
|
||||||
<service id="thelia.coupon.manager" class="Thelia\Coupon\CouponManager">
|
<service id="thelia.coupon.manager" class="Thelia\Coupon\CouponManager">
|
||||||
@@ -19,12 +19,12 @@
|
|||||||
<argument type="service" id="service_container" />
|
<argument type="service" id="service_container" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="thelia.coupon.type.remove_x_amount" class="Thelia\Coupon\Type\RemoveXAmountManager">
|
<service id="thelia.coupon.type.remove_x_amount" class="Thelia\Coupon\Type\RemoveXAmount">
|
||||||
<argument type="service" id="thelia.adapter" />
|
<argument type="service" id="thelia.facade" />
|
||||||
<tag name="thelia.coupon.addCoupon"/>
|
<tag name="thelia.coupon.addCoupon"/>
|
||||||
</service>
|
</service>
|
||||||
<service id="thelia.coupon.type.remove_x_percent" class="Thelia\Coupon\Type\RemoveXPercentManager">
|
<service id="thelia.coupon.type.remove_x_percent" class="Thelia\Coupon\Type\RemoveXPercent">
|
||||||
<argument type="service" id="thelia.adapter" />
|
<argument type="service" id="thelia.facade" />
|
||||||
<tag name="thelia.coupon.addCoupon"/>
|
<tag name="thelia.coupon.addCoupon"/>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
@@ -35,21 +35,22 @@
|
|||||||
</service>
|
</service>
|
||||||
<service id="thelia.condition.validator" class="Thelia\Condition\ConditionEvaluator">
|
<service id="thelia.condition.validator" class="Thelia\Condition\ConditionEvaluator">
|
||||||
</service>
|
</service>
|
||||||
<service id="thelia.condition.match_for_everyone" class="Thelia\Condition\Implementation\MatchForEveryoneManager">
|
<service id="thelia.condition.match_for_everyone" class="Thelia\Condition\Implementation\MatchForEveryone">
|
||||||
<argument type="service" id="thelia.adapter" />
|
<argument type="service" id="thelia.facade" />
|
||||||
<tag name="thelia.coupon.addCondition"/>
|
<tag name="thelia.coupon.addCondition"/>
|
||||||
</service>
|
</service>
|
||||||
<service id="thelia.condition.match_for_x_articles" class="Thelia\Condition\Implementation\MatchForXArticlesManager">
|
<service id="thelia.condition.match_for_total_amount" class="Thelia\Condition\Implementation\MatchForTotalAmount">
|
||||||
<argument type="service" id="thelia.adapter" />
|
<argument type="service" id="thelia.facade" />
|
||||||
<tag name="thelia.coupon.addCondition"/>
|
<tag name="thelia.coupon.addCondition"/>
|
||||||
</service>
|
</service>
|
||||||
<service id="thelia.condition.match_for_total_amount" class="Thelia\Condition\Implementation\MatchForTotalAmountManager">
|
<service id="thelia.condition.match_for_x_articles" class="Thelia\Condition\Implementation\MatchForXArticles">
|
||||||
<argument type="service" id="thelia.adapter" />
|
<argument type="service" id="thelia.facade" />
|
||||||
<tag name="thelia.coupon.addCondition"/>
|
<tag name="thelia.coupon.addCondition"/>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</services>
|
</services>
|
||||||
|
|
||||||
</config>
|
</config>
|
||||||
|
|||||||
@@ -26,13 +26,13 @@ namespace Thelia\Controller\Admin;
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\Routing\Router;
|
use Symfony\Component\Routing\Router;
|
||||||
use Thelia\Condition\ConditionFactory;
|
use Thelia\Condition\ConditionFactory;
|
||||||
use Thelia\Condition\ConditionManagerInterface;
|
use Thelia\Condition\Implementation\ConditionInterface;
|
||||||
use Thelia\Core\Security\Resource\AdminResources;
|
use Thelia\Core\Security\Resource\AdminResources;
|
||||||
use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent;
|
use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent;
|
||||||
use Thelia\Core\Event\TheliaEvents;
|
use Thelia\Core\Event\TheliaEvents;
|
||||||
use Thelia\Core\Security\AccessManager;
|
use Thelia\Core\Security\AccessManager;
|
||||||
use Thelia\Coupon\CouponManager;
|
use Thelia\Coupon\CouponManager;
|
||||||
use Thelia\Coupon\ConditionCollection;
|
use Thelia\Condition\ConditionCollection;
|
||||||
use Thelia\Coupon\Type\CouponInterface;
|
use Thelia\Coupon\Type\CouponInterface;
|
||||||
use Thelia\Form\CouponCreationForm;
|
use Thelia\Form\CouponCreationForm;
|
||||||
use Thelia\Form\Exception\FormValidationException;
|
use Thelia\Form\Exception\FormValidationException;
|
||||||
@@ -227,7 +227,7 @@ class CouponController extends BaseAdminController
|
|||||||
|
|
||||||
$args['conditionsObject'] = array();
|
$args['conditionsObject'] = array();
|
||||||
|
|
||||||
/** @var ConditionManagerInterface $condition */
|
/** @var ConditionInterface $condition */
|
||||||
foreach ($conditions->getConditions() as $condition) {
|
foreach ($conditions->getConditions() as $condition) {
|
||||||
$args['conditionsObject'][] = array(
|
$args['conditionsObject'][] = array(
|
||||||
'serviceId' => $condition->getServiceId(),
|
'serviceId' => $condition->getServiceId(),
|
||||||
@@ -519,7 +519,7 @@ class CouponController extends BaseAdminController
|
|||||||
$couponManager = $this->container->get('thelia.coupon.manager');
|
$couponManager = $this->container->get('thelia.coupon.manager');
|
||||||
$availableConditions = $couponManager->getAvailableConditions();
|
$availableConditions = $couponManager->getAvailableConditions();
|
||||||
$cleanedConditions = array();
|
$cleanedConditions = array();
|
||||||
/** @var ConditionManagerInterface $availableCondition */
|
/** @var ConditionInterface $availableCondition */
|
||||||
foreach ($availableConditions as $availableCondition) {
|
foreach ($availableConditions as $availableCondition) {
|
||||||
$condition = array();
|
$condition = array();
|
||||||
$condition['serviceId'] = $availableCondition->getServiceId();
|
$condition['serviceId'] = $availableCondition->getServiceId();
|
||||||
@@ -564,7 +564,7 @@ class CouponController extends BaseAdminController
|
|||||||
protected function cleanConditionForTemplate(ConditionCollection $conditions)
|
protected function cleanConditionForTemplate(ConditionCollection $conditions)
|
||||||
{
|
{
|
||||||
$cleanedConditions = array();
|
$cleanedConditions = array();
|
||||||
/** @var $condition ConditionManagerInterface */
|
/** @var $condition ConditionInterface */
|
||||||
foreach ($conditions->getConditions() as $condition) {
|
foreach ($conditions->getConditions() as $condition) {
|
||||||
$cleanedConditions[] = $condition->getToolTip();
|
$cleanedConditions[] = $condition->getToolTip();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
namespace Thelia\Core\Event\Coupon;
|
namespace Thelia\Core\Event\Coupon;
|
||||||
use Thelia\Core\Event\ActionEvent;
|
use Thelia\Core\Event\ActionEvent;
|
||||||
use Thelia\Coupon\ConditionCollection;
|
use Thelia\Condition\ConditionCollection;
|
||||||
use Thelia\Model\Coupon;
|
use Thelia\Model\Coupon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,7 +39,7 @@ use Thelia\Model\Coupon;
|
|||||||
*/
|
*/
|
||||||
class CouponCreateOrUpdateEvent extends ActionEvent
|
class CouponCreateOrUpdateEvent extends ActionEvent
|
||||||
{
|
{
|
||||||
/** @var ConditionCollection Array of ConditionManagerInterface */
|
/** @var ConditionCollection Array of ConditionInterface */
|
||||||
protected $conditions = null;
|
protected $conditions = null;
|
||||||
|
|
||||||
/** @var string Coupon code (ex: XMAS) */
|
/** @var string Coupon code (ex: XMAS) */
|
||||||
@@ -280,7 +280,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
|||||||
/**
|
/**
|
||||||
* Get Conditions
|
* Get Conditions
|
||||||
*
|
*
|
||||||
* @return null|ConditionCollection Array of ConditionManagerInterface
|
* @return null|ConditionCollection Array of ConditionInterface
|
||||||
*/
|
*/
|
||||||
public function getConditions()
|
public function getConditions()
|
||||||
{
|
{
|
||||||
@@ -290,7 +290,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
|||||||
/**
|
/**
|
||||||
* Set Conditions
|
* Set Conditions
|
||||||
*
|
*
|
||||||
* @param ConditionCollection $conditions Array of ConditionManagerInterface
|
* @param ConditionCollection $conditions Array of ConditionInterface
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -681,7 +681,7 @@ final class TheliaEvents
|
|||||||
const MAILTRANSPORTER_CONFIG = 'action.mailertransporter.config';
|
const MAILTRANSPORTER_CONFIG = 'action.mailertransporter.config';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sent when Thelia try to generate a rewriten url
|
* sent when Thelia try to generate a rewritten url
|
||||||
*/
|
*/
|
||||||
const GENERATE_REWRITTENURL = 'action.generate_rewritenurl';
|
const GENERATE_REWRITTENURL = 'action.generate_rewritenurl';
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace Thelia\Core\Template\Loop;
|
|||||||
use Propel\Runtime\ActiveQuery\Criteria;
|
use Propel\Runtime\ActiveQuery\Criteria;
|
||||||
use Propel\Runtime\Util\PropelModelPager;
|
use Propel\Runtime\Util\PropelModelPager;
|
||||||
use Thelia\Condition\ConditionFactory;
|
use Thelia\Condition\ConditionFactory;
|
||||||
use Thelia\Condition\ConditionManagerInterface;
|
use Thelia\Condition\Implementation\ConditionInterface;
|
||||||
use Thelia\Core\HttpFoundation\Request;
|
use Thelia\Core\HttpFoundation\Request;
|
||||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||||
use Thelia\Core\Template\Element\LoopResult;
|
use Thelia\Core\Template\Element\LoopResult;
|
||||||
@@ -106,7 +106,7 @@ class Coupon extends BaseI18nLoop implements PropelSearchLoopInterface
|
|||||||
/** @var CouponInterface $couponManager */
|
/** @var CouponInterface $couponManager */
|
||||||
$couponManager = $this->container->get($coupon->getType());
|
$couponManager = $this->container->get($coupon->getType());
|
||||||
$couponManager->set(
|
$couponManager->set(
|
||||||
$this->container->get('thelia.adapter'),
|
$this->container->get('thelia.facade'),
|
||||||
$coupon->getCode(),
|
$coupon->getCode(),
|
||||||
$coupon->getTitle(),
|
$coupon->getTitle(),
|
||||||
$coupon->getShortDescription(),
|
$coupon->getShortDescription(),
|
||||||
@@ -125,7 +125,7 @@ class Coupon extends BaseI18nLoop implements PropelSearchLoopInterface
|
|||||||
$daysLeftBeforeExpiration = floor($datediff/(60*60*24));
|
$daysLeftBeforeExpiration = floor($datediff/(60*60*24));
|
||||||
|
|
||||||
$cleanedConditions = array();
|
$cleanedConditions = array();
|
||||||
/** @var ConditionManagerInterface $condition */
|
/** @var ConditionInterface $condition */
|
||||||
foreach ($conditions->getConditions() as $condition) {
|
foreach ($conditions->getConditions() as $condition) {
|
||||||
$cleanedConditions[] = $condition->getToolTip();
|
$cleanedConditions[] = $condition->getToolTip();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,19 +131,19 @@ class TemplateHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Récursively examine files in a directory tree, and extract translatable strings.
|
* Recursively examine files in a directory tree, and extract translatable strings.
|
||||||
*
|
*
|
||||||
* Returns an array of translatable strings, each item having with the following structure:
|
* Returns an array of translatable strings, each item having with the following structure:
|
||||||
* 'files' an arfray of file names in which the string appears,
|
* 'files' an array of file names in which the string appears,
|
||||||
* 'text' the translatable text
|
* 'text' the translatable text
|
||||||
* 'translation' => the text translation, or an empty string if none available.
|
* 'translation' => the text translation, or an empty string if none available.
|
||||||
* 'dollar' => true if the translatable text contains a $
|
* 'dollar' => true if the translatable text contains a $
|
||||||
*
|
*
|
||||||
* @param string $directory the path to the directory to examine
|
* @param string $directory the path to the directory to examine
|
||||||
* @param string $walkMode type of file scanning: WALK_MODE_PHP or WALK_MODE_TEMPLATE
|
* @param string $walkMode type of file scanning: WALK_MODE_PHP or WALK_MODE_TEMPLATE
|
||||||
* @param Thelia\Core\Translation\Translator $translator the current translator
|
* @param \Thelia\Core\Translation\Translator $translator the current translator
|
||||||
* @param string $currentLocale the current locale
|
* @param string $currentLocale the current locale
|
||||||
* @param array $strings the liste of strings
|
* @param array $strings the list of strings
|
||||||
* @throws \InvalidArgumentException if $walkMode contains an invalid value
|
* @throws \InvalidArgumentException if $walkMode contains an invalid value
|
||||||
* @return number the total number of translatable texts
|
* @return number the total number of translatable texts
|
||||||
*/
|
*/
|
||||||
@@ -258,15 +258,15 @@ class TemplateHelper
|
|||||||
|
|
||||||
fwrite($fp, ");\n");
|
fwrite($fp, ");\n");
|
||||||
|
|
||||||
@fclose($fh);
|
@fclose($fp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new \RuntimeException(
|
throw new \RuntimeException(
|
||||||
$this->getTranslator()->trans(
|
Translator::getInstance()->trans(
|
||||||
"Failed to open translation file %file. Please be sure that this file is writable by your Web server",
|
'Failed to open translation file %file. Please be sure that this file is writable by your Web server',
|
||||||
array('%file' => $file)
|
array('%file' => $file)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
namespace Thelia\Coupon;
|
namespace Thelia\Coupon;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Component\Translation\Exception\NotFoundResourceException;
|
|
||||||
use Thelia\Condition\ConditionFactory;
|
use Thelia\Condition\ConditionFactory;
|
||||||
use Thelia\Coupon\Type\CouponInterface;
|
use Thelia\Coupon\Type\CouponInterface;
|
||||||
use Thelia\Exception\CouponExpiredException;
|
use Thelia\Exception\CouponExpiredException;
|
||||||
@@ -48,7 +47,7 @@ class CouponFactory
|
|||||||
protected $container = null;
|
protected $container = null;
|
||||||
|
|
||||||
/** @var FacadeInterface Provide necessary value from Thelia*/
|
/** @var FacadeInterface Provide necessary value from Thelia*/
|
||||||
protected $adapter;
|
protected $facade;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -58,7 +57,7 @@ class CouponFactory
|
|||||||
public function __construct(ContainerInterface $container)
|
public function __construct(ContainerInterface $container)
|
||||||
{
|
{
|
||||||
$this->container = $container;
|
$this->container = $container;
|
||||||
$this->adapter = $container->get('thelia.adapter');
|
$this->facade = $container->get('thelia.facade');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,17 +67,14 @@ class CouponFactory
|
|||||||
*
|
*
|
||||||
* @throws \Thelia\Exception\CouponExpiredException
|
* @throws \Thelia\Exception\CouponExpiredException
|
||||||
* @throws \Thelia\Exception\InvalidConditionException
|
* @throws \Thelia\Exception\InvalidConditionException
|
||||||
* @throws \Symfony\Component\Translation\Exception\NotFoundResourceException
|
|
||||||
* @return CouponInterface ready to be processed
|
* @return CouponInterface ready to be processed
|
||||||
*/
|
*/
|
||||||
public function buildCouponFromCode($couponCode)
|
public function buildCouponFromCode($couponCode)
|
||||||
{
|
{
|
||||||
/** @var Coupon $couponModel */
|
/** @var Coupon $couponModel */
|
||||||
$couponModel = $this->adapter->findOneCouponByCode($couponCode);
|
$couponModel = $this->facade->findOneCouponByCode($couponCode);
|
||||||
if ($couponModel === null) {
|
if ($couponModel === null) {
|
||||||
throw new NotFoundResourceException(
|
return false;
|
||||||
'Coupon ' . $couponCode . ' not found in Database'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($couponModel->getExpirationDate() < new \DateTime()) {
|
if ($couponModel->getExpirationDate() < new \DateTime()) {
|
||||||
@@ -86,8 +82,8 @@ class CouponFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @var CouponInterface $couponInterface */
|
/** @var CouponInterface $couponInterface */
|
||||||
$couponInterface = $this->buildCouponInterfaceFromModel($couponModel);
|
$couponInterface = $this->buildCouponFromModel($couponModel);
|
||||||
if ($couponInterface->getConditions()->isEmpty()) {
|
if ($couponInterface && $couponInterface->getConditions()->isEmpty()) {
|
||||||
throw new InvalidConditionException(
|
throw new InvalidConditionException(
|
||||||
get_class($couponInterface)
|
get_class($couponInterface)
|
||||||
);
|
);
|
||||||
@@ -103,7 +99,7 @@ class CouponFactory
|
|||||||
*
|
*
|
||||||
* @return CouponInterface ready to use CouponInterface object instance
|
* @return CouponInterface ready to use CouponInterface object instance
|
||||||
*/
|
*/
|
||||||
protected function buildCouponInterfaceFromModel(Coupon $model)
|
public function buildCouponFromModel(Coupon $model)
|
||||||
{
|
{
|
||||||
$isCumulative = ($model->getIsCumulative() == 1 ? true : false);
|
$isCumulative = ($model->getIsCumulative() == 1 ? true : false);
|
||||||
$isRemovingPostage = ($model->getIsRemovingPostage() == 1 ? true : false);
|
$isRemovingPostage = ($model->getIsRemovingPostage() == 1 ? true : false);
|
||||||
@@ -115,7 +111,7 @@ class CouponFactory
|
|||||||
/** @var CouponInterface $couponManager*/
|
/** @var CouponInterface $couponManager*/
|
||||||
$couponManager = $this->container->get($model->getType());
|
$couponManager = $this->container->get($model->getType());
|
||||||
$couponManager->set(
|
$couponManager->set(
|
||||||
$this->adapter,
|
$this->facade,
|
||||||
$model->getCode(),
|
$model->getCode(),
|
||||||
$model->getTitle(),
|
$model->getTitle(),
|
||||||
$model->getShortDescription(),
|
$model->getShortDescription(),
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
namespace Thelia\Coupon;
|
namespace Thelia\Coupon;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Thelia\Condition\ConditionManagerInterface;
|
use Thelia\Condition\Implementation\ConditionInterface;
|
||||||
use Thelia\Coupon\Type\CouponInterface;
|
use Thelia\Coupon\Type\CouponInterface;
|
||||||
use Thelia\Model\Coupon;
|
use Thelia\Model\Coupon;
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ use Thelia\Model\Coupon;
|
|||||||
class CouponManager
|
class CouponManager
|
||||||
{
|
{
|
||||||
/** @var FacadeInterface Provides necessary value from Thelia */
|
/** @var FacadeInterface Provides necessary value from Thelia */
|
||||||
protected $adapter = null;
|
protected $facade = null;
|
||||||
|
|
||||||
/** @var ContainerInterface Service Container */
|
/** @var ContainerInterface Service Container */
|
||||||
protected $container = null;
|
protected $container = null;
|
||||||
@@ -64,8 +64,8 @@ class CouponManager
|
|||||||
public function __construct(ContainerInterface $container)
|
public function __construct(ContainerInterface $container)
|
||||||
{
|
{
|
||||||
$this->container = $container;
|
$this->container = $container;
|
||||||
$this->adapter = $container->get('thelia.adapter');
|
$this->facade = $container->get('thelia.facade');
|
||||||
$this->coupons = $this->adapter->getCurrentCoupons();
|
$this->coupons = $this->facade->getCurrentCoupons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -87,12 +87,12 @@ class CouponManager
|
|||||||
$discount = $this->getEffect($couponsKept);
|
$discount = $this->getEffect($couponsKept);
|
||||||
|
|
||||||
if ($isRemovingPostage) {
|
if ($isRemovingPostage) {
|
||||||
$postage = $this->adapter->getCheckoutPostagePrice();
|
$postage = $this->facade->getCheckoutPostagePrice();
|
||||||
$discount += $postage;
|
$discount += $postage;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Just In Case test
|
// Just In Case test
|
||||||
$checkoutTotalPrice = $this->adapter->getCartTotalPrice();
|
$checkoutTotalPrice = $this->facade->getCartTotalPrice();
|
||||||
if ($discount >= $checkoutTotalPrice) {
|
if ($discount >= $checkoutTotalPrice) {
|
||||||
$discount = $checkoutTotalPrice;
|
$discount = $checkoutTotalPrice;
|
||||||
}
|
}
|
||||||
@@ -164,7 +164,7 @@ class CouponManager
|
|||||||
|
|
||||||
/** @var CouponInterface $coupon */
|
/** @var CouponInterface $coupon */
|
||||||
foreach ($coupons as $coupon) {
|
foreach ($coupons as $coupon) {
|
||||||
if ($coupon->isMatching($this->adapter)) {
|
if ($coupon->isMatching($this->facade)) {
|
||||||
$couponsKept[] = $coupon;
|
$couponsKept[] = $coupon;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -184,7 +184,7 @@ class CouponManager
|
|||||||
$discount = 0.00;
|
$discount = 0.00;
|
||||||
/** @var CouponInterface $coupon */
|
/** @var CouponInterface $coupon */
|
||||||
foreach ($coupons as $coupon) {
|
foreach ($coupons as $coupon) {
|
||||||
$discount += $coupon->exec($this->adapter);
|
$discount += $coupon->exec($this->facade);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $discount;
|
return $discount;
|
||||||
@@ -213,9 +213,9 @@ class CouponManager
|
|||||||
/**
|
/**
|
||||||
* Add an available ConstraintManager (Services)
|
* Add an available ConstraintManager (Services)
|
||||||
*
|
*
|
||||||
* @param ConditionManagerInterface $condition ConditionManagerInterface
|
* @param ConditionInterface $condition ConditionInterface
|
||||||
*/
|
*/
|
||||||
public function addAvailableCondition(ConditionManagerInterface $condition)
|
public function addAvailableCondition(ConditionInterface $condition)
|
||||||
{
|
{
|
||||||
$this->availableConditions[] = $condition;
|
$this->availableConditions[] = $condition;
|
||||||
}
|
}
|
||||||
@@ -237,20 +237,21 @@ class CouponManager
|
|||||||
*
|
*
|
||||||
* @param \Thelia\Model\Coupon $coupon Coupon consumed
|
* @param \Thelia\Model\Coupon $coupon Coupon consumed
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return int Usage left after decremental
|
||||||
*/
|
*/
|
||||||
public function decrementeQuantity(Coupon $coupon)
|
public function decrementQuantity(Coupon $coupon)
|
||||||
{
|
{
|
||||||
$ret = true;
|
$ret = -1;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$oldMaxUsage = $coupon->getMaxUsage();
|
$usageLeft = $coupon->getMaxUsage();
|
||||||
|
|
||||||
if ($oldMaxUsage > 0) {
|
if ($usageLeft > 0) {
|
||||||
$oldMaxUsage--;
|
$usageLeft--;
|
||||||
$coupon->setMaxUsage($$oldMaxUsage);
|
$coupon->setMaxUsage($usageLeft);
|
||||||
|
|
||||||
$coupon->save();
|
$coupon->save();
|
||||||
|
$ret = $usageLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch(\Exception $e) {
|
} catch(\Exception $e) {
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ use Symfony\Component\Intl\Exception\NotImplementedException;
|
|||||||
use Thelia\Condition\ConditionEvaluator;
|
use Thelia\Condition\ConditionEvaluator;
|
||||||
use Thelia\Core\Translation\Translator;
|
use Thelia\Core\Translation\Translator;
|
||||||
use Thelia\Coupon\FacadeInterface;
|
use Thelia\Coupon\FacadeInterface;
|
||||||
use Thelia\Coupon\ConditionCollection;
|
use Thelia\Condition\ConditionCollection;
|
||||||
use Thelia\Coupon\RuleOrganizerInterface;
|
use Thelia\Condition\ConditionOrganizerInterface;
|
||||||
use Thelia\Exception\InvalidConditionException;
|
use Thelia\Exception\InvalidConditionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,15 +45,15 @@ use Thelia\Exception\InvalidConditionException;
|
|||||||
abstract class CouponAbstract implements CouponInterface
|
abstract class CouponAbstract implements CouponInterface
|
||||||
{
|
{
|
||||||
/** @var FacadeInterface Provide necessary value from Thelia */
|
/** @var FacadeInterface Provide necessary value from Thelia */
|
||||||
protected $adapter = null;
|
protected $facade = null;
|
||||||
|
|
||||||
/** @var Translator Service Translator */
|
/** @var Translator Service Translator */
|
||||||
protected $translator = null;
|
protected $translator = null;
|
||||||
|
|
||||||
/** @var RuleOrganizerInterface */
|
/** @var ConditionOrganizerInterface */
|
||||||
protected $organizer = null;
|
protected $organizer = null;
|
||||||
|
|
||||||
/** @var ConditionCollection Array of ConditionManagerInterface */
|
/** @var ConditionCollection Array of ConditionInterface */
|
||||||
protected $conditions = null;
|
protected $conditions = null;
|
||||||
|
|
||||||
/** @var ConditionEvaluator Condition validator */
|
/** @var ConditionEvaluator Condition validator */
|
||||||
@@ -104,19 +104,19 @@ abstract class CouponAbstract implements CouponInterface
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param FacadeInterface $adapter Service adapter
|
* @param FacadeInterface $facade Service facade
|
||||||
*/
|
*/
|
||||||
public function __construct(FacadeInterface $adapter)
|
public function __construct(FacadeInterface $facade)
|
||||||
{
|
{
|
||||||
$this->adapter = $adapter;
|
$this->facade = $facade;
|
||||||
$this->translator = $adapter->getTranslator();
|
$this->translator = $facade->getTranslator();
|
||||||
$this->conditionEvaluator = $adapter->getConditionEvaluator();
|
$this->conditionEvaluator = $facade->getConditionEvaluator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Condition Organizer
|
* Set Condition Organizer
|
||||||
*
|
*
|
||||||
* @param RuleOrganizerInterface $organizer Manage Condition groups (&& and ||)
|
* @param ConditionOrganizerInterface $organizer Manage Condition groups (&& and ||)
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
@@ -214,7 +214,7 @@ abstract class CouponAbstract implements CouponInterface
|
|||||||
* Replace the existing Conditions by those given in parameter
|
* Replace the existing Conditions by those given in parameter
|
||||||
* If one Condition is badly implemented, no Condition will be added
|
* If one Condition is badly implemented, no Condition will be added
|
||||||
*
|
*
|
||||||
* @param ConditionCollection $conditions ConditionManagerInterface to add
|
* @param ConditionCollection $conditions ConditionInterface to add
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
* @throws \Thelia\Exception\InvalidConditionException
|
* @throws \Thelia\Exception\InvalidConditionException
|
||||||
|
|||||||
@@ -23,7 +23,8 @@
|
|||||||
|
|
||||||
namespace Thelia\Coupon\Type;
|
namespace Thelia\Coupon\Type;
|
||||||
|
|
||||||
use Thelia\Coupon\ConditionCollection;
|
use Thelia\Condition\ConditionCollection;
|
||||||
|
use Thelia\Coupon\FacadeInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by JetBrains PhpStorm.
|
* Created by JetBrains PhpStorm.
|
||||||
@@ -62,7 +63,7 @@ interface CouponInterface
|
|||||||
/**
|
/**
|
||||||
* Set Coupon
|
* Set Coupon
|
||||||
*
|
*
|
||||||
* @param CouponInterface $adapter Provides necessary value from Thelia
|
* @param FacadeInterface $facade Provides necessary value from Thelia
|
||||||
* @param string $code Coupon code (ex: XMAS)
|
* @param string $code Coupon code (ex: XMAS)
|
||||||
* @param string $title Coupon title (ex: Coupon for XMAS)
|
* @param string $title Coupon title (ex: Coupon for XMAS)
|
||||||
* @param string $shortDescription Coupon short description
|
* @param string $shortDescription Coupon short description
|
||||||
@@ -77,7 +78,7 @@ interface CouponInterface
|
|||||||
* @param \Datetime $expirationDate When the Code is expiring
|
* @param \Datetime $expirationDate When the Code is expiring
|
||||||
*/
|
*/
|
||||||
public function set(
|
public function set(
|
||||||
$adapter,
|
FacadeInterface $facade,
|
||||||
$code,
|
$code,
|
||||||
$title,
|
$title,
|
||||||
$shortDescription,
|
$shortDescription,
|
||||||
@@ -139,20 +140,20 @@ interface CouponInterface
|
|||||||
/**
|
/**
|
||||||
* Return condition to validate the Coupon or not
|
* Return condition to validate the Coupon or not
|
||||||
*
|
*
|
||||||
* @return ConditionCollection A set of ConditionManagerInterface
|
* @return ConditionCollection A set of ConditionInterface
|
||||||
*/
|
*/
|
||||||
public function getConditions();
|
public function getConditions();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace the existing Rules by those given in parameter
|
* Replace the existing Conditions by those given in parameter
|
||||||
* If one Rule is badly implemented, no Rule will be added
|
* If one Condition is badly implemented, no Condition will be added
|
||||||
*
|
*
|
||||||
* @param ConditionCollection $rules ConditionManagerInterface to add
|
* @param ConditionCollection $conditions ConditionInterface to add
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
* @throws \Thelia\Exception\InvalidConditionException
|
* @throws \Thelia\Exception\InvalidConditionException
|
||||||
*/
|
*/
|
||||||
public function setConditions(ConditionCollection $rules);
|
public function setConditions(ConditionCollection $conditions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return Coupon expiration date
|
* Return Coupon expiration date
|
||||||
@@ -198,7 +199,7 @@ interface CouponInterface
|
|||||||
* A positive value
|
* A positive value
|
||||||
*
|
*
|
||||||
* Effects could also affect something else than the final Checkout price
|
* Effects could also affect something else than the final Checkout price
|
||||||
* CouponAdapter $adapter could be use to directly pass a Session value
|
* FacadeInterface $facade could be used to directly pass a Session value
|
||||||
* some would wish to modify
|
* some would wish to modify
|
||||||
* Hence affecting a wide variety of Thelia elements
|
* Hence affecting a wide variety of Thelia elements
|
||||||
*
|
*
|
||||||
@@ -207,7 +208,7 @@ interface CouponInterface
|
|||||||
public function exec();
|
public function exec();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the current Coupon is matching its conditions (Rules)
|
* Check if the current Coupon is matching its conditions
|
||||||
* Thelia variables are given by the FacadeInterface
|
* Thelia variables are given by the FacadeInterface
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
namespace Thelia\Coupon\Type;
|
namespace Thelia\Coupon\Type;
|
||||||
|
|
||||||
|
use Thelia\Coupon\FacadeInterface;
|
||||||
use Thelia\Coupon\Type\CouponAbstract;
|
use Thelia\Coupon\Type\CouponAbstract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,7 +37,7 @@ use Thelia\Coupon\Type\CouponAbstract;
|
|||||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class RemoveXAmountManager extends CouponAbstract
|
class RemoveXAmount extends CouponAbstract
|
||||||
{
|
{
|
||||||
/** @var string Service Id */
|
/** @var string Service Id */
|
||||||
protected $serviceId = 'thelia.coupon.type.remove_x_amount';
|
protected $serviceId = 'thelia.coupon.type.remove_x_amount';
|
||||||
@@ -44,7 +45,7 @@ class RemoveXAmountManager extends CouponAbstract
|
|||||||
/**
|
/**
|
||||||
* Set Coupon
|
* Set Coupon
|
||||||
*
|
*
|
||||||
* @param CouponInterface $adapter Provides necessary value from Thelia
|
* @param FacadeInterface $facade Provides necessary value from Thelia
|
||||||
* @param string $code Coupon code (ex: XMAS)
|
* @param string $code Coupon code (ex: XMAS)
|
||||||
* @param string $title Coupon title (ex: Coupon for XMAS)
|
* @param string $title Coupon title (ex: Coupon for XMAS)
|
||||||
* @param string $shortDescription Coupon short description
|
* @param string $shortDescription Coupon short description
|
||||||
@@ -59,7 +60,7 @@ class RemoveXAmountManager extends CouponAbstract
|
|||||||
* @param \Datetime $expirationDate When the Code is expiring
|
* @param \Datetime $expirationDate When the Code is expiring
|
||||||
*/
|
*/
|
||||||
public function set(
|
public function set(
|
||||||
$adapter,
|
FacadeInterface $facade,
|
||||||
$code,
|
$code,
|
||||||
$title,
|
$title,
|
||||||
$shortDescription,
|
$shortDescription,
|
||||||
@@ -87,7 +88,7 @@ class RemoveXAmountManager extends CouponAbstract
|
|||||||
$this->isEnabled = $isEnabled;
|
$this->isEnabled = $isEnabled;
|
||||||
$this->maxUsage = $maxUsage;
|
$this->maxUsage = $maxUsage;
|
||||||
$this->expirationDate = $expirationDate;
|
$this->expirationDate = $expirationDate;
|
||||||
$this->adapter = $adapter;
|
$this->facade = $facade;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,7 +98,7 @@ class RemoveXAmountManager extends CouponAbstract
|
|||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return $this->adapter
|
return $this->facade
|
||||||
->getTranslator()
|
->getTranslator()
|
||||||
->trans('Remove X amount to total cart', array(), 'constraint');
|
->trans('Remove X amount to total cart', array(), 'constraint');
|
||||||
}
|
}
|
||||||
@@ -109,7 +110,7 @@ class RemoveXAmountManager extends CouponAbstract
|
|||||||
*/
|
*/
|
||||||
public function getToolTip()
|
public function getToolTip()
|
||||||
{
|
{
|
||||||
$toolTip = $this->adapter
|
$toolTip = $this->facade
|
||||||
->getTranslator()
|
->getTranslator()
|
||||||
->trans(
|
->trans(
|
||||||
'This coupon will remove the entered amount to the customer total checkout. If the discount is superior to the total checkout price the customer will only pay the postage. Unless if the coupon is set to remove postage too.',
|
'This coupon will remove the entered amount to the customer total checkout. If the discount is superior to the total checkout price the customer will only pay the postage. Unless if the coupon is set to remove postage too.',
|
||||||
@@ -23,8 +23,9 @@
|
|||||||
|
|
||||||
namespace Thelia\Coupon\Type;
|
namespace Thelia\Coupon\Type;
|
||||||
|
|
||||||
|
use Thelia\Coupon\FacadeInterface;
|
||||||
use Thelia\Coupon\Type\CouponAbstract;
|
use Thelia\Coupon\Type\CouponAbstract;
|
||||||
use Thelia\Exception\MissingAdapterException;
|
use Thelia\Exception\MissingFacadeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by JetBrains PhpStorm.
|
* Created by JetBrains PhpStorm.
|
||||||
@@ -35,7 +36,7 @@ use Thelia\Exception\MissingAdapterException;
|
|||||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class RemoveXPercentManager extends CouponAbstract
|
class RemoveXPercent extends CouponAbstract
|
||||||
{
|
{
|
||||||
/** @var string Service Id */
|
/** @var string Service Id */
|
||||||
protected $serviceId = 'thelia.coupon.type.remove_x_percent';
|
protected $serviceId = 'thelia.coupon.type.remove_x_percent';
|
||||||
@@ -45,7 +46,7 @@ class RemoveXPercentManager extends CouponAbstract
|
|||||||
/**
|
/**
|
||||||
* Set Coupon
|
* Set Coupon
|
||||||
*
|
*
|
||||||
* @param CouponInterface $adapter Provides necessary value from Thelia
|
* @param FacadeInterface $facade Provides necessary value from Thelia
|
||||||
* @param string $code Coupon code (ex: XMAS)
|
* @param string $code Coupon code (ex: XMAS)
|
||||||
* @param string $title Coupon title (ex: Coupon for XMAS)
|
* @param string $title Coupon title (ex: Coupon for XMAS)
|
||||||
* @param string $shortDescription Coupon short description
|
* @param string $shortDescription Coupon short description
|
||||||
@@ -60,7 +61,7 @@ class RemoveXPercentManager extends CouponAbstract
|
|||||||
* @param \Datetime $expirationDate When the Code is expiring
|
* @param \Datetime $expirationDate When the Code is expiring
|
||||||
*/
|
*/
|
||||||
public function set(
|
public function set(
|
||||||
$adapter,
|
FacadeInterface $facade,
|
||||||
$code,
|
$code,
|
||||||
$title,
|
$title,
|
||||||
$shortDescription,
|
$shortDescription,
|
||||||
@@ -87,14 +88,14 @@ class RemoveXPercentManager extends CouponAbstract
|
|||||||
$this->isEnabled = $isEnabled;
|
$this->isEnabled = $isEnabled;
|
||||||
$this->maxUsage = $maxUsage;
|
$this->maxUsage = $maxUsage;
|
||||||
$this->expirationDate = $expirationDate;
|
$this->expirationDate = $expirationDate;
|
||||||
$this->adapter = $adapter;
|
$this->facade = $facade;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return effects generated by the coupon
|
* Return effects generated by the coupon
|
||||||
* A negative value
|
* A negative value
|
||||||
*
|
*
|
||||||
* @throws \Thelia\Exception\MissingAdapterException
|
* @throws \Thelia\Exception\MissingFacadeException
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
@@ -106,7 +107,7 @@ class RemoveXPercentManager extends CouponAbstract
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$basePrice = $this->adapter->getCartTotalPrice();
|
$basePrice = $this->facade->getCartTotalPrice();
|
||||||
|
|
||||||
return $basePrice * (( $this->percent ) / 100);
|
return $basePrice * (( $this->percent ) / 100);
|
||||||
}
|
}
|
||||||
@@ -119,7 +120,7 @@ class RemoveXPercentManager extends CouponAbstract
|
|||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return $this->adapter
|
return $this->facade
|
||||||
->getTranslator()
|
->getTranslator()
|
||||||
->trans('Remove X percent to total cart', array(), 'constraint');
|
->trans('Remove X percent to total cart', array(), 'constraint');
|
||||||
}
|
}
|
||||||
@@ -131,7 +132,7 @@ class RemoveXPercentManager extends CouponAbstract
|
|||||||
*/
|
*/
|
||||||
public function getToolTip()
|
public function getToolTip()
|
||||||
{
|
{
|
||||||
$toolTip = $this->adapter
|
$toolTip = $this->facade
|
||||||
->getTranslator()
|
->getTranslator()
|
||||||
->trans(
|
->trans(
|
||||||
'This coupon will remove the entered percentage to the customer total checkout. If the discount is superior to the total checkout price the customer will only pay the postage. Unless if the coupon is set to remove postage too.',
|
'This coupon will remove the entered percentage to the customer total checkout. If the discount is superior to the total checkout price the customer will only pay the postage. Unless if the coupon is set to remove postage too.',
|
||||||
@@ -30,13 +30,13 @@ use Thelia\Log\Tlog;
|
|||||||
* Date: 8/19/13
|
* Date: 8/19/13
|
||||||
* Time: 3:24 PM
|
* Time: 3:24 PM
|
||||||
*
|
*
|
||||||
* Thrown when the Adapter is not set
|
* Thrown when the Facade is not set
|
||||||
*
|
*
|
||||||
* @package Coupon
|
* @package Coupon
|
||||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class MissingAdapterException extends \RuntimeException
|
class MissingFacadeException extends \RuntimeException
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
@@ -38,7 +38,7 @@ class CategoryModificationForm extends CategoryCreationForm
|
|||||||
->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
|
->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
|
||||||
|
|
||||||
->add("url", "text", array(
|
->add("url", "text", array(
|
||||||
"label" => Translator::getInstance()->trans("Rewriten URL *"),
|
"label" => Translator::getInstance()->trans("Rewritten URL *"),
|
||||||
"constraints" => array(new NotBlank()),
|
"constraints" => array(new NotBlank()),
|
||||||
"label_attr" => array("for" => "rewriten_url")
|
"label_attr" => array("for" => "rewriten_url")
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class ContentModificationForm extends ContentCreationForm
|
|||||||
->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
|
->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
|
||||||
|
|
||||||
->add("url", "text", array(
|
->add("url", "text", array(
|
||||||
"label" => Translator::getInstance()->trans("Rewriten URL *"),
|
"label" => Translator::getInstance()->trans("Rewritten URL *"),
|
||||||
"constraints" => array(new NotBlank()),
|
"constraints" => array(new NotBlank()),
|
||||||
"label_attr" => array("for" => "rewritten_url")
|
"label_attr" => array("for" => "rewritten_url")
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class FolderModificationForm extends FolderCreationForm
|
|||||||
->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
|
->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
|
||||||
|
|
||||||
->add("url", "text", array(
|
->add("url", "text", array(
|
||||||
"label" => Translator::getInstance()->trans("Rewriten URL *"),
|
"label" => Translator::getInstance()->trans("Rewritten URL *"),
|
||||||
"constraints" => array(new NotBlank()),
|
"constraints" => array(new NotBlank()),
|
||||||
"label_attr" => array("for" => "rewriten_url")
|
"label_attr" => array("for" => "rewriten_url")
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class ProductModificationForm extends ProductCreationForm
|
|||||||
|
|
||||||
))
|
))
|
||||||
->add("url", "text", array(
|
->add("url", "text", array(
|
||||||
"label" => Translator::getInstance()->trans("Rewriten URL *"),
|
"label" => Translator::getInstance()->trans("Rewritten URL *"),
|
||||||
"constraints" => array(new NotBlank()),
|
"constraints" => array(new NotBlank()),
|
||||||
"label_attr" => array("for" => "rewriten_url_field")
|
"label_attr" => array("for" => "rewriten_url_field")
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -30,17 +30,17 @@ use Thelia\Model\RewritingUrlQuery;
|
|||||||
use Thelia\Model\RewritingUrl;
|
use Thelia\Model\RewritingUrl;
|
||||||
use Thelia\Tools\URL;
|
use Thelia\Tools\URL;
|
||||||
/**
|
/**
|
||||||
* A trait for managing Rewriten URLs from model classes
|
* A trait for managing Rewritten URLs from model classes
|
||||||
*/
|
*/
|
||||||
trait UrlRewritingTrait {
|
trait UrlRewritingTrait {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns string the view name of the rewriten object (e.g., 'category', 'product')
|
* @returns string the view name of the rewritten object (e.g., 'category', 'product')
|
||||||
*/
|
*/
|
||||||
protected abstract function getRewrittenUrlViewName();
|
protected abstract function getRewrittenUrlViewName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the object URL for the given locale, rewriten if rewriting is enabled.
|
* Get the object URL for the given locale, rewritten if rewriting is enabled.
|
||||||
*
|
*
|
||||||
* @param string $locale a valid locale (e.g. en_US)
|
* @param string $locale a valid locale (e.g. en_US)
|
||||||
*/
|
*/
|
||||||
@@ -53,7 +53,7 @@ trait UrlRewritingTrait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a rewriten URL from the object title, and store it in the rewriting table
|
* Generate a rewritten URL from the object title, and store it in the rewriting table
|
||||||
*
|
*
|
||||||
* @param string $locale a valid locale (e.g. en_US)
|
* @param string $locale a valid locale (e.g. en_US)
|
||||||
*/
|
*/
|
||||||
@@ -112,7 +112,7 @@ trait UrlRewritingTrait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the rewriten URL for the given locale
|
* return the rewritten URL for the given locale
|
||||||
*
|
*
|
||||||
* @param string $locale a valid locale (e.g. en_US)
|
* @param string $locale a valid locale (e.g. en_US)
|
||||||
* @return null
|
* @return null
|
||||||
@@ -137,7 +137,7 @@ trait UrlRewritingTrait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the rewriten URL for the given locale
|
* Set the rewritten URL for the given locale
|
||||||
*
|
*
|
||||||
* @param string $locale a valid locale (e.g. en_US)
|
* @param string $locale a valid locale (e.g. en_US)
|
||||||
* @param $url the wanted url
|
* @param $url the wanted url
|
||||||
|
|||||||
186
core/lib/Thelia/Tests/Condition/ConditionCollectionTest.php
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
<?php
|
||||||
|
/**********************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Thelia */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : info@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it and/or modify */
|
||||||
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
|
/* the Free Software Foundation; either version 3 of the License */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will be useful, */
|
||||||
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
|
/* GNU General Public License for more details. */
|
||||||
|
/* */
|
||||||
|
/* You should have received a copy of the GNU General Public License */
|
||||||
|
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
/* */
|
||||||
|
/**********************************************************************************/
|
||||||
|
|
||||||
|
namespace Thelia\Condition;
|
||||||
|
use Thelia\Condition\Implementation\MatchForTotalAmount;
|
||||||
|
use Thelia\Model\CurrencyQuery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by JetBrains PhpStorm.
|
||||||
|
* Date: 8/19/13
|
||||||
|
* Time: 3:24 PM
|
||||||
|
*
|
||||||
|
* Unit Test ConditionCollection Class
|
||||||
|
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-11-17 at 18:59:24.
|
||||||
|
*
|
||||||
|
* @package Condition
|
||||||
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class ConditionCollectionTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var ConditionCollection
|
||||||
|
*/
|
||||||
|
protected $object;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up the fixture, for example, opens a network connection.
|
||||||
|
* This method is called before a test is executed.
|
||||||
|
*/
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate adapter stub
|
||||||
|
*
|
||||||
|
* @param int $cartTotalPrice Cart total price
|
||||||
|
* @param string $checkoutCurrency Checkout currency
|
||||||
|
* @param string $i18nOutput Output from each translation
|
||||||
|
*
|
||||||
|
* @return \PHPUnit_Framework_MockObject_MockObject
|
||||||
|
*/
|
||||||
|
public function generateFacadeStub($cartTotalPrice = 400, $checkoutCurrency = 'EUR', $i18nOutput = '')
|
||||||
|
{
|
||||||
|
$stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$currencies = CurrencyQuery::create();
|
||||||
|
$currencies = $currencies->find();
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getAvailableCurrencies')
|
||||||
|
->will($this->returnValue($currencies));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCartTotalPrice')
|
||||||
|
->will($this->returnValue($cartTotalPrice));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCheckoutCurrency')
|
||||||
|
->will($this->returnValue($checkoutCurrency));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getConditionEvaluator')
|
||||||
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
|
$stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubTranslator->expects($this->any())
|
||||||
|
->method('trans')
|
||||||
|
->will($this->returnValue($i18nOutput));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getTranslator')
|
||||||
|
->will($this->returnValue($stubTranslator));
|
||||||
|
|
||||||
|
return $stubFacade;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tears down the fixture, for example, closes a network connection.
|
||||||
|
* This method is called after a test is executed.
|
||||||
|
*/
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Condition\ConditionCollection::getConditions
|
||||||
|
* @covers Thelia\Condition\ConditionCollection::add
|
||||||
|
*/
|
||||||
|
public function testGetConditions()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub();
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::EQUAL,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$collection = new ConditionCollection();
|
||||||
|
$collection->add($condition1);
|
||||||
|
|
||||||
|
$expected = $condition1;
|
||||||
|
$actual = $collection->getConditions()[0];
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
|
||||||
|
$this->assertFalse($collection->isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Condition\ConditionCollection::isEmpty
|
||||||
|
*/
|
||||||
|
public function testIsEmpty()
|
||||||
|
{
|
||||||
|
$collection = new ConditionCollection();
|
||||||
|
$this->assertTrue($collection->isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Condition\ConditionCollection::__toString
|
||||||
|
*/
|
||||||
|
public function test__toString()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub();
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators1 = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values1 = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition1->setValidatorsFromForm($operators1, $values1);
|
||||||
|
|
||||||
|
$condition2 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators2 = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::INFERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values2 = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 600,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition2->setValidatorsFromForm($operators2, $values2);
|
||||||
|
|
||||||
|
$collection = new ConditionCollection();
|
||||||
|
$collection->add($condition1);
|
||||||
|
$collection->add($condition2);
|
||||||
|
|
||||||
|
$expected = '[{"conditionServiceId":"thelia.condition.match_for_total_amount","operators":{"price":">","currency":"=="},"values":{"price":400,"currency":"EUR"}},{"conditionServiceId":"thelia.condition.match_for_total_amount","operators":{"price":"<","currency":"=="},"values":{"price":600,"currency":"EUR"}}]';
|
||||||
|
$actual = $collection->__toString();;
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,9 +25,7 @@ namespace Thelia\Condition\Implementation;
|
|||||||
|
|
||||||
use Thelia\Condition\ConditionEvaluator;
|
use Thelia\Condition\ConditionEvaluator;
|
||||||
use Thelia\Condition\Operators;
|
use Thelia\Condition\Operators;
|
||||||
use Thelia\Coupon\FacadeInterface;
|
use Thelia\Condition\ConditionCollection;
|
||||||
use Thelia\Coupon\ConditionCollection;
|
|
||||||
use Thelia\Model\CurrencyQuery;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by JetBrains PhpStorm.
|
* Created by JetBrains PhpStorm.
|
||||||
@@ -51,328 +49,11 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTestSuccess1Rules()
|
/**
|
||||||
{
|
* Test vatiable comparison
|
||||||
$stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
|
*
|
||||||
->disableOriginalConstructor()
|
* @covers Thelia\Condition\ConditionEvaluator::variableOpComparison
|
||||||
->getMock();
|
*/
|
||||||
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
|
||||||
$stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getTranslator')
|
|
||||||
->will($this->returnValue($stubTranslator));
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getConditionEvaluator')
|
|
||||||
->will($this->returnValue(new ConditionEvaluator()));
|
|
||||||
|
|
||||||
$currencies = CurrencyQuery::create();
|
|
||||||
$currencies = $currencies->find();
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getAvailableCurrencies')
|
|
||||||
->will($this->returnValue($currencies));
|
|
||||||
|
|
||||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$stubMatchForTotalAmountManager = $this->getMockBuilder('\Thelia\Condition\Implementation\MatchForTotalAmountManager')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
$stubMatchForTotalAmountManager->expects($this->any())
|
|
||||||
->method('isMatching')
|
|
||||||
->will($this->returnValue(true));
|
|
||||||
|
|
||||||
$stubContainer->expects($this->any())
|
|
||||||
->method('get')
|
|
||||||
->will($this->returnValue($stubMatchForTotalAmountManager));
|
|
||||||
|
|
||||||
$stubContainer->expects($this->any())
|
|
||||||
->method('has')
|
|
||||||
->will($this->returnValue(true));
|
|
||||||
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getContainer')
|
|
||||||
->will($this->returnValue($stubContainer));
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getCheckoutCurrency')
|
|
||||||
->will($this->returnValue('EUR'));
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getCartTotalPrice')
|
|
||||||
->will($this->returnValue(401.00));
|
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => '>',
|
|
||||||
MatchForTotalAmountManager::INPUT2 => '=='
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => 400.00,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR');
|
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$conditions = new ConditionCollection();
|
|
||||||
$conditions->add($condition1);
|
|
||||||
|
|
||||||
$conditionEvaluator = new ConditionEvaluator();
|
|
||||||
$isValid = $conditionEvaluator->isMatching($conditions);
|
|
||||||
|
|
||||||
$expected = true;
|
|
||||||
$actual =$isValid;
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testTestFail1Rules()
|
|
||||||
{
|
|
||||||
$stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
|
||||||
$stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getTranslator')
|
|
||||||
->will($this->returnValue($stubTranslator));
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getConditionEvaluator')
|
|
||||||
->will($this->returnValue(new ConditionEvaluator()));
|
|
||||||
|
|
||||||
$currencies = CurrencyQuery::create();
|
|
||||||
$currencies = $currencies->find();
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getAvailableCurrencies')
|
|
||||||
->will($this->returnValue($currencies));
|
|
||||||
|
|
||||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$stubMatchForTotalAmountManager = $this->getMockBuilder('\Thelia\Condition\Implementation\MatchForTotalAmountManager')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
$stubMatchForTotalAmountManager->expects($this->any())
|
|
||||||
->method('isMatching')
|
|
||||||
->will($this->returnValue(true));
|
|
||||||
|
|
||||||
$stubContainer->expects($this->any())
|
|
||||||
->method('get')
|
|
||||||
->will($this->returnValue($stubMatchForTotalAmountManager));
|
|
||||||
|
|
||||||
$stubContainer->expects($this->any())
|
|
||||||
->method('has')
|
|
||||||
->will($this->returnValue(true));
|
|
||||||
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getContainer')
|
|
||||||
->will($this->returnValue($stubContainer));
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getCheckoutCurrency')
|
|
||||||
->will($this->returnValue('EUR'));
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getCartTotalPrice')
|
|
||||||
->will($this->returnValue(400.00));
|
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => '>',
|
|
||||||
MatchForTotalAmountManager::INPUT2 => '=='
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => 400.00,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR');
|
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$conditions = new ConditionCollection();
|
|
||||||
$conditions->add($condition1);
|
|
||||||
|
|
||||||
$conditionEvaluator = new ConditionEvaluator();
|
|
||||||
$isValid = $conditionEvaluator->isMatching($conditions);
|
|
||||||
|
|
||||||
$expected = false;
|
|
||||||
$actual =$isValid;
|
|
||||||
$this->assertEquals($expected, $actual, 'Conditions evaluator always think Customer is matching conditions');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testTestSuccess2Rules()
|
|
||||||
{
|
|
||||||
$stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
|
||||||
$stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getTranslator')
|
|
||||||
->will($this->returnValue($stubTranslator));
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getConditionEvaluator')
|
|
||||||
->will($this->returnValue(new ConditionEvaluator()));
|
|
||||||
|
|
||||||
$currencies = CurrencyQuery::create();
|
|
||||||
$currencies = $currencies->find();
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getAvailableCurrencies')
|
|
||||||
->will($this->returnValue($currencies));
|
|
||||||
|
|
||||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$stubMatchForTotalAmountManager = $this->getMockBuilder('\Thelia\Condition\Implementation\MatchForTotalAmountManager')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
$stubMatchForTotalAmountManager->expects($this->any())
|
|
||||||
->method('isMatching')
|
|
||||||
->will($this->returnValue(true));
|
|
||||||
|
|
||||||
$stubContainer->expects($this->any())
|
|
||||||
->method('get')
|
|
||||||
->will($this->returnValue($stubMatchForTotalAmountManager));
|
|
||||||
|
|
||||||
$stubContainer->expects($this->any())
|
|
||||||
->method('has')
|
|
||||||
->will($this->returnValue(true));
|
|
||||||
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getContainer')
|
|
||||||
->will($this->returnValue($stubContainer));
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getCheckoutCurrency')
|
|
||||||
->will($this->returnValue('EUR'));
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getCartTotalPrice')
|
|
||||||
->will($this->returnValue(401.00));
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getNbArticlesInCart')
|
|
||||||
->will($this->returnValue(5));
|
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => '>',
|
|
||||||
MatchForTotalAmountManager::INPUT2 => '=='
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => 400.00,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR');
|
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$condition2 = new MatchForXArticlesManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForXArticlesManager::INPUT1 => '>'
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForXArticlesManager::INPUT1 => 4
|
|
||||||
);
|
|
||||||
$condition2->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$conditions = new ConditionCollection();
|
|
||||||
$conditions->add($condition1);
|
|
||||||
$conditions->add($condition2);
|
|
||||||
|
|
||||||
$conditionEvaluator = new ConditionEvaluator();
|
|
||||||
$isValid = $conditionEvaluator->isMatching($conditions);
|
|
||||||
|
|
||||||
$expected = true;
|
|
||||||
$actual =$isValid;
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testTestFail2Rules()
|
|
||||||
{
|
|
||||||
$stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
|
||||||
$stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getTranslator')
|
|
||||||
->will($this->returnValue($stubTranslator));
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getConditionEvaluator')
|
|
||||||
->will($this->returnValue(new ConditionEvaluator()));
|
|
||||||
|
|
||||||
$currencies = CurrencyQuery::create();
|
|
||||||
$currencies = $currencies->find();
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getAvailableCurrencies')
|
|
||||||
->will($this->returnValue($currencies));
|
|
||||||
|
|
||||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$stubMatchForTotalAmountManager = $this->getMockBuilder('\Thelia\Condition\Implementation\MatchForTotalAmountManager')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
$stubMatchForTotalAmountManager->expects($this->any())
|
|
||||||
->method('isMatching')
|
|
||||||
->will($this->returnValue(true));
|
|
||||||
|
|
||||||
$stubContainer->expects($this->any())
|
|
||||||
->method('get')
|
|
||||||
->will($this->returnValue($stubMatchForTotalAmountManager));
|
|
||||||
|
|
||||||
$stubContainer->expects($this->any())
|
|
||||||
->method('has')
|
|
||||||
->will($this->returnValue(true));
|
|
||||||
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getContainer')
|
|
||||||
->will($this->returnValue($stubContainer));
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getCheckoutCurrency')
|
|
||||||
->will($this->returnValue('EUR'));
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getCartTotalPrice')
|
|
||||||
->will($this->returnValue(400.00));
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getNbArticlesInCart')
|
|
||||||
->will($this->returnValue(5));
|
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => '>',
|
|
||||||
MatchForTotalAmountManager::INPUT2 => '=='
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => 400.00,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR');
|
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$condition2 = new MatchForXArticlesManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForXArticlesManager::INPUT1 => '>'
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForXArticlesManager::INPUT1 => 4
|
|
||||||
);
|
|
||||||
$condition2->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$conditions = new ConditionCollection();
|
|
||||||
$conditions->add($condition1);
|
|
||||||
$conditions->add($condition2);
|
|
||||||
|
|
||||||
$conditionEvaluator = new ConditionEvaluator();
|
|
||||||
$isValid = $conditionEvaluator->isMatching($conditions);
|
|
||||||
|
|
||||||
$expected = false;
|
|
||||||
$actual =$isValid;
|
|
||||||
$this->assertEquals($expected, $actual, 'Conditions evaluator always think Customer is matching conditions');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testVariableOpComparisonSuccess()
|
public function testVariableOpComparisonSuccess()
|
||||||
{
|
{
|
||||||
$conditionEvaluator = new ConditionEvaluator();
|
$conditionEvaluator = new ConditionEvaluator();
|
||||||
@@ -409,6 +90,11 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test vatiable comparison
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\ConditionEvaluator::variableOpComparison
|
||||||
|
*/
|
||||||
public function testVariableOpComparisonFail()
|
public function testVariableOpComparisonFail()
|
||||||
{
|
{
|
||||||
$conditionEvaluator = new ConditionEvaluator();
|
$conditionEvaluator = new ConditionEvaluator();
|
||||||
@@ -440,7 +126,10 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test vatiable comparison
|
||||||
|
*
|
||||||
* @expectedException \Exception
|
* @expectedException \Exception
|
||||||
|
* @covers Thelia\Condition\ConditionEvaluator::variableOpComparison
|
||||||
*/
|
*/
|
||||||
public function testVariableOpComparisonException()
|
public function testVariableOpComparisonException()
|
||||||
{
|
{
|
||||||
@@ -450,6 +139,68 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals($expected, $actual);
|
$this->assertEquals($expected, $actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test condition collection matching
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\ConditionEvaluator::isMatching
|
||||||
|
*/
|
||||||
|
public function testIsMatchingTrue()
|
||||||
|
{
|
||||||
|
$stubConditionTrue1 = $this->getMockBuilder('\Thelia\Condition\Implementation\MatchForXArticles')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubConditionTrue1->expects($this->any())
|
||||||
|
->method('isMatching')
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$stubConditionTrue2 = $this->getMockBuilder('\Thelia\Condition\Implementation\MatchForXArticles')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubConditionTrue2->expects($this->any())
|
||||||
|
->method('isMatching')
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$collection = new ConditionCollection();
|
||||||
|
$collection->add($stubConditionTrue1);
|
||||||
|
$collection->add($stubConditionTrue2);
|
||||||
|
|
||||||
|
$conitionEvaluator = new ConditionEvaluator();
|
||||||
|
$actual = $conitionEvaluator->isMatching($collection);
|
||||||
|
|
||||||
|
$this->assertTrue($actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test condition collection matching
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\ConditionEvaluator::isMatching
|
||||||
|
*/
|
||||||
|
public function testIsMatchingFalse()
|
||||||
|
{
|
||||||
|
$stubConditionTrue = $this->getMockBuilder('\Thelia\Condition\Implementation\MatchForXArticles')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubConditionTrue->expects($this->any())
|
||||||
|
->method('isMatching')
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$stubConditionFalse = $this->getMockBuilder('\Thelia\Condition\Implementation\MatchForXArticles')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubConditionFalse->expects($this->any())
|
||||||
|
->method('isMatching')
|
||||||
|
->will($this->returnValue(false));
|
||||||
|
|
||||||
|
$collection = new ConditionCollection();
|
||||||
|
$collection->add($stubConditionTrue);
|
||||||
|
$collection->add($stubConditionFalse);
|
||||||
|
|
||||||
|
$conitionEvaluator = new ConditionEvaluator();
|
||||||
|
$actual = $conitionEvaluator->isMatching($collection);
|
||||||
|
|
||||||
|
$this->assertFalse($actual);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tears down the fixture, for example, closes a network connection.
|
* Tears down the fixture, for example, closes a network connection.
|
||||||
* This method is called after a test is executed.
|
* This method is called after a test is executed.
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ use Thelia\Condition\ConditionEvaluator;
|
|||||||
use Thelia\Condition\ConditionFactory;
|
use Thelia\Condition\ConditionFactory;
|
||||||
use Thelia\Condition\Operators;
|
use Thelia\Condition\Operators;
|
||||||
use Thelia\Coupon\FacadeInterface;
|
use Thelia\Coupon\FacadeInterface;
|
||||||
use Thelia\Coupon\ConditionCollection;
|
use Thelia\Condition\ConditionCollection;
|
||||||
use Thelia\Model\CurrencyQuery;
|
use Thelia\Model\CurrencyQuery;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,7 +84,7 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase
|
|||||||
->getMock();
|
->getMock();
|
||||||
$stubContainer->expects($this->any())
|
$stubContainer->expects($this->any())
|
||||||
->method('get')
|
->method('get')
|
||||||
->will($this->returnValue(new MatchForTotalAmountManager($stubFacade)));
|
->will($this->returnValue(new MatchForTotalAmount($stubFacade)));
|
||||||
|
|
||||||
$stubContainer->expects($this->any())
|
$stubContainer->expects($this->any())
|
||||||
->method('has')
|
->method('has')
|
||||||
@@ -94,14 +94,14 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase
|
|||||||
->method('getContainer')
|
->method('getContainer')
|
||||||
->will($this->returnValue($stubContainer));
|
->will($this->returnValue($stubContainer));
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForTotalAmountManager::INPUT1 => 40.00,
|
MatchForTotalAmount::INPUT1 => 40.00,
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR'
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase
|
|||||||
->getMock();
|
->getMock();
|
||||||
$stubContainer->expects($this->any())
|
$stubContainer->expects($this->any())
|
||||||
->method('get')
|
->method('get')
|
||||||
->will($this->returnValue(new MatchForTotalAmountManager($stubFacade)));
|
->will($this->returnValue(new MatchForTotalAmount($stubFacade)));
|
||||||
|
|
||||||
$stubContainer->expects($this->any())
|
$stubContainer->expects($this->any())
|
||||||
->method('has')
|
->method('has')
|
||||||
@@ -158,14 +158,14 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase
|
|||||||
->method('getContainer')
|
->method('getContainer')
|
||||||
->will($this->returnValue($stubContainer));
|
->will($this->returnValue($stubContainer));
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForTotalAmountManager::INPUT1 => 40.00,
|
MatchForTotalAmount::INPUT1 => 40.00,
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR'
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase
|
|||||||
->getMock();
|
->getMock();
|
||||||
$stubContainer->expects($this->any())
|
$stubContainer->expects($this->any())
|
||||||
->method('get')
|
->method('get')
|
||||||
->will($this->returnValue(new MatchForTotalAmountManager($stubFacade)));
|
->will($this->returnValue(new MatchForTotalAmount($stubFacade)));
|
||||||
|
|
||||||
$stubContainer->expects($this->any())
|
$stubContainer->expects($this->any())
|
||||||
->method('has')
|
->method('has')
|
||||||
@@ -220,25 +220,25 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase
|
|||||||
->method('getContainer')
|
->method('getContainer')
|
||||||
->will($this->returnValue($stubContainer));
|
->will($this->returnValue($stubContainer));
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForTotalAmountManager::INPUT1 => 40.00,
|
MatchForTotalAmount::INPUT1 => 40.00,
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR'
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
$condition2 = new MatchForTotalAmountManager($stubFacade);
|
$condition2 = new MatchForTotalAmount($stubFacade);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForTotalAmountManager::INPUT1 => 400.00,
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR'
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
);
|
);
|
||||||
$condition2->setValidatorsFromForm($operators, $values);
|
$condition2->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
@@ -287,7 +287,7 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase
|
|||||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container')
|
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
$stubContainer->expects($this->any())
|
$stubContainer->expects($this->any())
|
||||||
->method('get')
|
->method('get')
|
||||||
->will($this->returnValue($condition1));
|
->will($this->returnValue($condition1));
|
||||||
@@ -301,12 +301,12 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase
|
|||||||
->will($this->returnValue($stubContainer));
|
->will($this->returnValue($stubContainer));
|
||||||
|
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForTotalAmountManager::INPUT1 => 40.00,
|
MatchForTotalAmount::INPUT1 => 40.00,
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR'
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
@@ -352,7 +352,7 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase
|
|||||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container')
|
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
$stubContainer->expects($this->any())
|
$stubContainer->expects($this->any())
|
||||||
->method('get')
|
->method('get')
|
||||||
->will($this->returnValue($condition1));
|
->will($this->returnValue($condition1));
|
||||||
@@ -366,12 +366,12 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase
|
|||||||
->will($this->returnValue($stubContainer));
|
->will($this->returnValue($stubContainer));
|
||||||
|
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForTotalAmountManager::INPUT1 => 40.00,
|
MatchForTotalAmount::INPUT1 => 40.00,
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR'
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
@@ -387,6 +387,66 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test condition serialization if collection is empty
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\ConditionFactory::serializeConditionCollection
|
||||||
|
*/
|
||||||
|
public function testSerializeConditionCollectionEmpty()
|
||||||
|
{
|
||||||
|
$stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getTranslator')
|
||||||
|
->will($this->returnValue($stubTranslator));
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getConditionEvaluator')
|
||||||
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
|
$currencies = CurrencyQuery::create();
|
||||||
|
$currencies = $currencies->find();
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getAvailableCurrencies')
|
||||||
|
->will($this->returnValue($currencies));
|
||||||
|
|
||||||
|
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('get')
|
||||||
|
->will($this->returnValue(new MatchForEveryone($stubFacade)));
|
||||||
|
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('has')
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getContainer')
|
||||||
|
->will($this->returnValue($stubContainer));
|
||||||
|
|
||||||
|
|
||||||
|
$conditions = new ConditionCollection();
|
||||||
|
|
||||||
|
$conditionFactory = new ConditionFactory($stubContainer);
|
||||||
|
|
||||||
|
|
||||||
|
$conditionNone = new MatchForEveryone($stubFacade);
|
||||||
|
$expectedCollection = new ConditionCollection();
|
||||||
|
$expectedCollection->add($conditionNone);
|
||||||
|
|
||||||
|
$expected = $conditionFactory->serializeConditionCollection($expectedCollection);
|
||||||
|
$actual = $conditionFactory->serializeConditionCollection($conditions);
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tears down the fixture, for example, closes a network connection.
|
* Tears down the fixture, for example, closes a network connection.
|
||||||
* This method is called after a test is executed.
|
* This method is called after a test is executed.
|
||||||
|
|||||||
@@ -33,13 +33,13 @@ use Thelia\Model\Currency;
|
|||||||
* Date: 8/19/13
|
* Date: 8/19/13
|
||||||
* Time: 3:24 PM
|
* Time: 3:24 PM
|
||||||
*
|
*
|
||||||
* Unit Test MatchForEveryoneManager Class
|
* Unit Test MatchForEveryone Class
|
||||||
*
|
*
|
||||||
* @package Condition
|
* @package Condition
|
||||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class MatchForEveryoneManagerTest extends \PHPUnit_Framework_TestCase
|
class MatchForEveryoneTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/** @var FacadeInterface $stubTheliaAdapter */
|
/** @var FacadeInterface $stubTheliaAdapter */
|
||||||
protected $stubTheliaAdapter = null;
|
protected $stubTheliaAdapter = null;
|
||||||
@@ -49,10 +49,11 @@ class MatchForEveryoneManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
*
|
*
|
||||||
* @param int $cartTotalPrice Cart total price
|
* @param int $cartTotalPrice Cart total price
|
||||||
* @param string $checkoutCurrency Checkout currency
|
* @param string $checkoutCurrency Checkout currency
|
||||||
|
* @param string $i18nOutput Output from each translation
|
||||||
*
|
*
|
||||||
* @return \PHPUnit_Framework_MockObject_MockObject
|
* @return \PHPUnit_Framework_MockObject_MockObject
|
||||||
*/
|
*/
|
||||||
public function generateAdapterStub($cartTotalPrice = 400, $checkoutCurrency = 'EUR')
|
public function generateFacadeStub($cartTotalPrice = 400, $checkoutCurrency = 'EUR', $i18nOutput = '')
|
||||||
{
|
{
|
||||||
$stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
|
$stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
@@ -70,6 +71,17 @@ class MatchForEveryoneManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
->method('getConditionEvaluator')
|
->method('getConditionEvaluator')
|
||||||
->will($this->returnValue(new ConditionEvaluator()));
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
|
$stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubTranslator->expects($this->any())
|
||||||
|
->method('trans')
|
||||||
|
->will($this->returnValue($i18nOutput));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getTranslator')
|
||||||
|
->will($this->returnValue($stubTranslator));
|
||||||
|
|
||||||
$currency1 = new Currency();
|
$currency1 = new Currency();
|
||||||
$currency1->setCode('EUR');
|
$currency1->setCode('EUR');
|
||||||
$currency2 = new Currency();
|
$currency2 = new Currency();
|
||||||
@@ -84,15 +96,15 @@ class MatchForEveryoneManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* Check if validity test on BackOffice inputs are working
|
* Check if validity test on BackOffice inputs are working
|
||||||
*
|
*
|
||||||
* @covers Thelia\Condition\Implementation\MatchForEveryoneManager::setValidators
|
* @covers Thelia\Condition\Implementation\MatchForEveryone::setValidators
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function testValidBackOfficeInputOperator()
|
public function testValidBackOfficeInputOperator()
|
||||||
{
|
{
|
||||||
$stubFacade = $this->generateAdapterStub(399, 'EUR');
|
$stubFacade = $this->generateFacadeStub(399, 'EUR');
|
||||||
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
/** @var FacadeInterface $stubFacade */
|
||||||
$condition1 = new MatchForEveryoneManager($stubFacade);
|
$condition1 = new MatchForEveryone($stubFacade);
|
||||||
$operators = array();
|
$operators = array();
|
||||||
$values = array();
|
$values = array();
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
@@ -107,15 +119,15 @@ class MatchForEveryoneManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* Check if condition is always matching
|
* Check if condition is always matching
|
||||||
*
|
*
|
||||||
* @covers Thelia\Condition\Implementation\MatchForEveryoneManager::isMatching
|
* @covers Thelia\Condition\Implementation\MatchForEveryone::isMatching
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function testIsMatching()
|
public function testIsMatching()
|
||||||
{
|
{
|
||||||
$stubFacade = $this->generateAdapterStub(399, 'EUR');
|
$stubFacade = $this->generateFacadeStub(399, 'EUR');
|
||||||
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
/** @var FacadeInterface $stubFacade */
|
||||||
$condition1 = new MatchForEveryoneManager($stubFacade);
|
$condition1 = new MatchForEveryone($stubFacade);
|
||||||
|
|
||||||
$isValid = $condition1->isMatching();
|
$isValid = $condition1->isMatching();
|
||||||
|
|
||||||
@@ -124,4 +136,67 @@ class MatchForEveryoneManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals($expected, $actual);
|
$this->assertEquals($expected, $actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check getName i18n
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForEveryone::getName
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testGetName()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub(399, 'EUR', 'Everybody can use it (no condition)');
|
||||||
|
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$condition1 = new MatchForEveryone($stubFacade);
|
||||||
|
|
||||||
|
$actual = $condition1->getName();
|
||||||
|
$expected = 'Everybody can use it (no condition)';
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check tooltip i18n
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForEveryone::getToolTip
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testGetToolTip()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub(399, 'EUR', 'Will return always true');
|
||||||
|
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$condition1 = new MatchForEveryone($stubFacade);
|
||||||
|
|
||||||
|
$actual = $condition1->getToolTip();
|
||||||
|
$expected = 'Will return always true';
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check validator
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForEveryone::generateInputs
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForEveryone::setValidatorsFromForm
|
||||||
|
*/
|
||||||
|
public function testGetValidator()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub(399, 'EUR');
|
||||||
|
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$condition1 = new MatchForEveryone($stubFacade);
|
||||||
|
$actual1 = $condition1->setValidatorsFromForm(array(), array());
|
||||||
|
$expected1 = $condition1;
|
||||||
|
$actual2 = $condition1->getValidators();
|
||||||
|
|
||||||
|
$validators = array();
|
||||||
|
$validators['inputs'] = array();
|
||||||
|
$validators['setOperators'] = array();
|
||||||
|
$validators['setValues'] = array();
|
||||||
|
$expected2 = $validators;
|
||||||
|
|
||||||
|
$this->assertEquals($expected1, $actual1);
|
||||||
|
$this->assertEquals($expected2, $actual2);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,610 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**********************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* Thelia */
|
|
||||||
/* */
|
|
||||||
/* Copyright (c) OpenStudio */
|
|
||||||
/* email : info@thelia.net */
|
|
||||||
/* web : http://www.thelia.net */
|
|
||||||
/* */
|
|
||||||
/* This program is free software; you can redistribute it and/or modify */
|
|
||||||
/* it under the terms of the GNU General Public License as published by */
|
|
||||||
/* the Free Software Foundation; either version 3 of the License */
|
|
||||||
/* */
|
|
||||||
/* This program is distributed in the hope that it will be useful, */
|
|
||||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
|
||||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
|
||||||
/* GNU General Public License for more details. */
|
|
||||||
/* */
|
|
||||||
/* You should have received a copy of the GNU General Public License */
|
|
||||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
||||||
/* */
|
|
||||||
/**********************************************************************************/
|
|
||||||
|
|
||||||
namespace Thelia\Condition\Implementation;
|
|
||||||
|
|
||||||
use Thelia\Condition\ConditionEvaluator;
|
|
||||||
use Thelia\Condition\Operators;
|
|
||||||
use Thelia\Coupon\FacadeInterface;
|
|
||||||
use Thelia\Exception\InvalidConditionValueException;
|
|
||||||
use Thelia\Model\Currency;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by JetBrains PhpStorm.
|
|
||||||
* Date: 8/19/13
|
|
||||||
* Time: 3:24 PM
|
|
||||||
*
|
|
||||||
* Unit Test MatchForTotalAmountManager Class
|
|
||||||
*
|
|
||||||
* @package Condition
|
|
||||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
/** @var FacadeInterface $stubTheliaAdapter */
|
|
||||||
protected $stubTheliaAdapter = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate adapter stub
|
|
||||||
*
|
|
||||||
* @param int $cartTotalPrice Cart total price
|
|
||||||
* @param string $checkoutCurrency Checkout currency
|
|
||||||
*
|
|
||||||
* @return \PHPUnit_Framework_MockObject_MockObject
|
|
||||||
*/
|
|
||||||
public function generateAdapterStub($cartTotalPrice = 400, $checkoutCurrency = 'EUR')
|
|
||||||
{
|
|
||||||
$stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getCartTotalPrice')
|
|
||||||
->will($this->returnValue($cartTotalPrice));
|
|
||||||
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getCheckoutCurrency')
|
|
||||||
->will($this->returnValue($checkoutCurrency));
|
|
||||||
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getConditionEvaluator')
|
|
||||||
->will($this->returnValue(new ConditionEvaluator()));
|
|
||||||
|
|
||||||
$currency1 = new Currency();
|
|
||||||
$currency1->setCode('EUR');
|
|
||||||
$currency2 = new Currency();
|
|
||||||
$currency2->setCode('USD');
|
|
||||||
$stubFacade->expects($this->any())
|
|
||||||
->method('getAvailableCurrencies')
|
|
||||||
->will($this->returnValue(array($currency1, $currency2)));
|
|
||||||
|
|
||||||
return $stubFacade;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets up the fixture, for example, opens a network connection.
|
|
||||||
* This method is called before a test is executed.
|
|
||||||
*/
|
|
||||||
protected function setUp()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if validity test on BackOffice inputs are working
|
|
||||||
*
|
|
||||||
* @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::setValidators
|
|
||||||
* @expectedException \Thelia\Exception\InvalidConditionOperatorException
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function testInValidBackOfficeInputOperator()
|
|
||||||
{
|
|
||||||
$stubFacade = $this->generateAdapterStub(399, 'EUR');
|
|
||||||
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::IN,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => '400',
|
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR');
|
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$isValid = $condition1->isMatching();
|
|
||||||
|
|
||||||
$expected = true;
|
|
||||||
$actual =$isValid;
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if validity test on BackOffice inputs are working
|
|
||||||
*
|
|
||||||
* @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::setValidators
|
|
||||||
* @expectedException \Thelia\Exception\InvalidConditionOperatorException
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function testInValidBackOfficeInputOperator2()
|
|
||||||
{
|
|
||||||
$stubFacade = $this->generateAdapterStub(399, 'EUR');
|
|
||||||
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::INFERIOR
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => '400',
|
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR');
|
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$isValid = $condition1->isMatching();
|
|
||||||
|
|
||||||
$expected = true;
|
|
||||||
$actual =$isValid;
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if validity test on BackOffice inputs are working
|
|
||||||
*
|
|
||||||
* @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::setValidators
|
|
||||||
* @expectedException \Thelia\Exception\InvalidConditionValueException
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function testInValidBackOfficeInputValue()
|
|
||||||
{
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
|
||||||
$stubFacade = $this->generateAdapterStub(399, 'EUR');
|
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => 'X',
|
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR');
|
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$isValid = $condition1->isMatching();
|
|
||||||
|
|
||||||
$expected = true;
|
|
||||||
$actual =$isValid;
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if validity test on BackOffice inputs are working
|
|
||||||
*
|
|
||||||
* @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::setValidators
|
|
||||||
* @expectedException \Thelia\Exception\InvalidConditionValueException
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function testInValidBackOfficeInputValue2()
|
|
||||||
{
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
|
||||||
$stubFacade = $this->generateAdapterStub(399, 'EUR');
|
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => 400,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => 'FLA');
|
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$isValid = $condition1->isMatching();
|
|
||||||
|
|
||||||
$expected = true;
|
|
||||||
$actual =$isValid;
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if test inferior operator is working
|
|
||||||
*
|
|
||||||
* @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function testMatchingConditionInferior()
|
|
||||||
{
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
|
||||||
$stubFacade = $this->generateAdapterStub(399, 'EUR');
|
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => 400.00,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR');
|
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$isValid = $condition1->isMatching();
|
|
||||||
|
|
||||||
$expected = true;
|
|
||||||
$actual =$isValid;
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if test inferior operator is working
|
|
||||||
*
|
|
||||||
* @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function testNotMatchingConditionInferior()
|
|
||||||
{
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
|
||||||
$stubFacade = $this->generateAdapterStub(400, 'EUR');
|
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => 400.00,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR');
|
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$isValid = $condition1->isMatching();
|
|
||||||
|
|
||||||
$expected = false;
|
|
||||||
$actual =$isValid;
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if test inferior operator is working
|
|
||||||
*
|
|
||||||
* @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function testMatchingConditionInferiorEquals()
|
|
||||||
{
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
|
||||||
$stubFacade = $this->generateAdapterStub(400, 'EUR');
|
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR_OR_EQUAL,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => 400.00,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR');
|
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$isValid = $condition1->isMatching();
|
|
||||||
|
|
||||||
$expected = true;
|
|
||||||
$actual =$isValid;
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if test inferior operator is working
|
|
||||||
*
|
|
||||||
* @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function testMatchingConditionInferiorEquals2()
|
|
||||||
{
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
|
||||||
$stubFacade = $this->generateAdapterStub(399, 'EUR');
|
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR_OR_EQUAL,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => 400.00,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR');
|
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$isValid = $condition1->isMatching();
|
|
||||||
|
|
||||||
$expected = true;
|
|
||||||
$actual =$isValid;
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if test inferior operator is working
|
|
||||||
*
|
|
||||||
* @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function testNotMatchingConditionInferiorEquals()
|
|
||||||
{
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
|
||||||
$stubFacade = $this->generateAdapterStub(401, 'EUR');
|
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR_OR_EQUAL,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => 400.00,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR');
|
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$isValid = $condition1->isMatching();
|
|
||||||
|
|
||||||
$expected = false;
|
|
||||||
$actual =$isValid;
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if test equals operator is working
|
|
||||||
*
|
|
||||||
* @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function testMatchingConditionEqual()
|
|
||||||
{
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
|
||||||
$stubFacade = $this->generateAdapterStub(400, 'EUR');
|
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::EQUAL,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => 400.00,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR');
|
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$isValid = $condition1->isMatching();
|
|
||||||
|
|
||||||
$expected = true;
|
|
||||||
$actual =$isValid;
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if test equals operator is working
|
|
||||||
*
|
|
||||||
* @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function testNotMatchingConditionEqual()
|
|
||||||
{
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
|
||||||
$stubFacade = $this->generateAdapterStub(399, 'EUR');
|
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::EQUAL,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => 400.00,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR');
|
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$isValid = $condition1->isMatching();
|
|
||||||
|
|
||||||
$expected = false;
|
|
||||||
$actual =$isValid;
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if test superior operator is working
|
|
||||||
*
|
|
||||||
* @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function testMatchingConditionSuperiorEquals()
|
|
||||||
{
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
|
||||||
$stubFacade = $this->generateAdapterStub(401, 'EUR');
|
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => 400.00,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR');
|
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$isValid = $condition1->isMatching();
|
|
||||||
|
|
||||||
$expected = true;
|
|
||||||
$actual =$isValid;
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if test superior operator is working
|
|
||||||
*
|
|
||||||
* @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function testMatchingConditionSuperiorEquals2()
|
|
||||||
{
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
|
||||||
$stubFacade = $this->generateAdapterStub(400, 'EUR');
|
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => 400.00,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR');
|
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$isValid = $condition1->isMatching();
|
|
||||||
|
|
||||||
$expected = true;
|
|
||||||
$actual =$isValid;
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if test superior operator is working
|
|
||||||
*
|
|
||||||
* @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function testNotMatchingConditionSuperiorEquals()
|
|
||||||
{
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
|
||||||
$stubFacade = $this->generateAdapterStub(399, 'EUR');
|
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => 400.00,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR');
|
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$isValid = $condition1->isMatching();
|
|
||||||
|
|
||||||
$expected = false;
|
|
||||||
$actual =$isValid;
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if test superior operator is working
|
|
||||||
*
|
|
||||||
* @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function testMatchingConditionSuperior()
|
|
||||||
{
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
|
||||||
$stubFacade = $this->generateAdapterStub(401, 'EUR');
|
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => 400.00,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR');
|
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$isValid = $condition1->isMatching();
|
|
||||||
|
|
||||||
$expected = true;
|
|
||||||
$actual =$isValid;
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if test superior operator is working
|
|
||||||
*
|
|
||||||
* @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function testNotMatchingConditionSuperior()
|
|
||||||
{
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
|
||||||
$stubFacade = $this->generateAdapterStub(399, 'EUR');
|
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => 400.00,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR');
|
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$isValid = $condition1->isMatching();
|
|
||||||
|
|
||||||
$expected = false;
|
|
||||||
$actual =$isValid;
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check currency is checked
|
|
||||||
*
|
|
||||||
* @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function testMatchingConditionCurrency()
|
|
||||||
{
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
|
||||||
$stubFacade = $this->generateAdapterStub(400, 'EUR');
|
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::EQUAL,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => 400.00,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR');
|
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$isValid = $condition1->isMatching();
|
|
||||||
|
|
||||||
$expected = true;
|
|
||||||
$actual =$isValid;
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check currency is checked
|
|
||||||
*
|
|
||||||
* @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function testNotMatchingConditionCurrency()
|
|
||||||
{
|
|
||||||
/** @var FacadeInterface $stubFacade */
|
|
||||||
$stubFacade = $this->generateAdapterStub(400.00, 'EUR');
|
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($stubFacade);
|
|
||||||
$operators = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::EQUAL,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
|
||||||
);
|
|
||||||
$values = array(
|
|
||||||
MatchForTotalAmountManager::INPUT1 => 400.00,
|
|
||||||
MatchForTotalAmountManager::INPUT2 => 'USD');
|
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
|
||||||
|
|
||||||
$isValid = $condition1->isMatching();
|
|
||||||
|
|
||||||
$expected = false;
|
|
||||||
$actual =$isValid;
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tears down the fixture, for example, closes a network connection.
|
|
||||||
* This method is called after a test is executed.
|
|
||||||
*/
|
|
||||||
protected function tearDown()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,976 @@
|
|||||||
|
<?php
|
||||||
|
/**********************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Thelia */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : info@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it and/or modify */
|
||||||
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
|
/* the Free Software Foundation; either version 3 of the License */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will be useful, */
|
||||||
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
|
/* GNU General Public License for more details. */
|
||||||
|
/* */
|
||||||
|
/* You should have received a copy of the GNU General Public License */
|
||||||
|
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
/* */
|
||||||
|
/**********************************************************************************/
|
||||||
|
|
||||||
|
namespace Thelia\Condition\Implementation;
|
||||||
|
|
||||||
|
use Thelia\Condition\ConditionEvaluator;
|
||||||
|
use Thelia\Condition\ConditionFactory;
|
||||||
|
use Thelia\Condition\Operators;
|
||||||
|
use Thelia\Condition\ConditionCollection;
|
||||||
|
use Thelia\Coupon\FacadeInterface;
|
||||||
|
use Thelia\Exception\InvalidConditionValueException;
|
||||||
|
use Thelia\Model\Currency;
|
||||||
|
use Thelia\Model\CurrencyQuery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by JetBrains PhpStorm.
|
||||||
|
* Date: 8/19/13
|
||||||
|
* Time: 3:24 PM
|
||||||
|
*
|
||||||
|
* Unit Test MatchForTotalAmount Class
|
||||||
|
*
|
||||||
|
* @package Condition
|
||||||
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/** @var FacadeInterface $stubTheliaAdapter */
|
||||||
|
protected $stubTheliaAdapter = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate adapter stub
|
||||||
|
*
|
||||||
|
* @param int $cartTotalPrice Cart total price
|
||||||
|
* @param string $checkoutCurrency Checkout currency
|
||||||
|
*
|
||||||
|
* @return \PHPUnit_Framework_MockObject_MockObject
|
||||||
|
*/
|
||||||
|
public function generateAdapterStub($cartTotalPrice = 400, $checkoutCurrency = 'EUR')
|
||||||
|
{
|
||||||
|
$stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCartTotalPrice')
|
||||||
|
->will($this->returnValue($cartTotalPrice));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCheckoutCurrency')
|
||||||
|
->will($this->returnValue($checkoutCurrency));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getConditionEvaluator')
|
||||||
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
|
$currency1 = new Currency();
|
||||||
|
$currency1->setCode('EUR');
|
||||||
|
$currency2 = new Currency();
|
||||||
|
$currency2->setCode('USD');
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getAvailableCurrencies')
|
||||||
|
->will($this->returnValue(array($currency1, $currency2)));
|
||||||
|
|
||||||
|
return $stubFacade;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up the fixture, for example, opens a network connection.
|
||||||
|
* This method is called before a test is executed.
|
||||||
|
*/
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if validity test on BackOffice inputs are working
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForTotalAmount::setValidators
|
||||||
|
* @expectedException \Thelia\Exception\InvalidConditionOperatorException
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testInValidBackOfficeInputOperator()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateAdapterStub(399, 'EUR');
|
||||||
|
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::IN,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => '400',
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$isValid = $condition1->isMatching();
|
||||||
|
|
||||||
|
$expected = true;
|
||||||
|
$actual =$isValid;
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if validity test on BackOffice inputs are working
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForTotalAmount::setValidators
|
||||||
|
* @expectedException \Thelia\Exception\InvalidConditionOperatorException
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testInValidBackOfficeInputOperator2()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateAdapterStub(399, 'EUR');
|
||||||
|
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::INFERIOR
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => '400',
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$isValid = $condition1->isMatching();
|
||||||
|
|
||||||
|
$expected = true;
|
||||||
|
$actual =$isValid;
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if validity test on BackOffice inputs are working
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForTotalAmount::setValidators
|
||||||
|
* @expectedException \Thelia\Exception\InvalidConditionValueException
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testInValidBackOfficeInputValue()
|
||||||
|
{
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$stubFacade = $this->generateAdapterStub(399, 'EUR');
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 'X',
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$isValid = $condition1->isMatching();
|
||||||
|
|
||||||
|
$expected = true;
|
||||||
|
$actual =$isValid;
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if validity test on BackOffice inputs are working
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForTotalAmount::setValidators
|
||||||
|
* @expectedException \Thelia\Exception\InvalidConditionValueException
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testInValidBackOfficeInputValue2()
|
||||||
|
{
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$stubFacade = $this->generateAdapterStub(399, 'EUR');
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'FLA');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$isValid = $condition1->isMatching();
|
||||||
|
|
||||||
|
$expected = true;
|
||||||
|
$actual =$isValid;
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if test inferior operator is working
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testMatchingConditionInferior()
|
||||||
|
{
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$stubFacade = $this->generateAdapterStub(399, 'EUR');
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::INFERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$isValid = $condition1->isMatching();
|
||||||
|
|
||||||
|
$expected = true;
|
||||||
|
$actual =$isValid;
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if test inferior operator is working
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testNotMatchingConditionInferior()
|
||||||
|
{
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$stubFacade = $this->generateAdapterStub(400, 'EUR');
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::INFERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$isValid = $condition1->isMatching();
|
||||||
|
|
||||||
|
$expected = false;
|
||||||
|
$actual =$isValid;
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if test inferior operator is working
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testMatchingConditionInferiorEquals()
|
||||||
|
{
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$stubFacade = $this->generateAdapterStub(400, 'EUR');
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::INFERIOR_OR_EQUAL,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$isValid = $condition1->isMatching();
|
||||||
|
|
||||||
|
$expected = true;
|
||||||
|
$actual =$isValid;
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if test inferior operator is working
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testMatchingConditionInferiorEquals2()
|
||||||
|
{
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$stubFacade = $this->generateAdapterStub(399, 'EUR');
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::INFERIOR_OR_EQUAL,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$isValid = $condition1->isMatching();
|
||||||
|
|
||||||
|
$expected = true;
|
||||||
|
$actual =$isValid;
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if test inferior operator is working
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testNotMatchingConditionInferiorEquals()
|
||||||
|
{
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$stubFacade = $this->generateAdapterStub(401, 'EUR');
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::INFERIOR_OR_EQUAL,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$isValid = $condition1->isMatching();
|
||||||
|
|
||||||
|
$expected = false;
|
||||||
|
$actual =$isValid;
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if test equals operator is working
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testMatchingConditionEqual()
|
||||||
|
{
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$stubFacade = $this->generateAdapterStub(400, 'EUR');
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::EQUAL,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$isValid = $condition1->isMatching();
|
||||||
|
|
||||||
|
$expected = true;
|
||||||
|
$actual =$isValid;
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if test equals operator is working
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testNotMatchingConditionEqual()
|
||||||
|
{
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$stubFacade = $this->generateAdapterStub(399, 'EUR');
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::EQUAL,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$isValid = $condition1->isMatching();
|
||||||
|
|
||||||
|
$expected = false;
|
||||||
|
$actual =$isValid;
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if test superior operator is working
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testMatchingConditionSuperiorEquals()
|
||||||
|
{
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$stubFacade = $this->generateAdapterStub(401, 'EUR');
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR_OR_EQUAL,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$isValid = $condition1->isMatching();
|
||||||
|
|
||||||
|
$expected = true;
|
||||||
|
$actual =$isValid;
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if test superior operator is working
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testMatchingConditionSuperiorEquals2()
|
||||||
|
{
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$stubFacade = $this->generateAdapterStub(400, 'EUR');
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR_OR_EQUAL,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$isValid = $condition1->isMatching();
|
||||||
|
|
||||||
|
$expected = true;
|
||||||
|
$actual =$isValid;
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if test superior operator is working
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testNotMatchingConditionSuperiorEquals()
|
||||||
|
{
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$stubFacade = $this->generateAdapterStub(399, 'EUR');
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR_OR_EQUAL,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$isValid = $condition1->isMatching();
|
||||||
|
|
||||||
|
$expected = false;
|
||||||
|
$actual =$isValid;
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if test superior operator is working
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testMatchingConditionSuperior()
|
||||||
|
{
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$stubFacade = $this->generateAdapterStub(401, 'EUR');
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$isValid = $condition1->isMatching();
|
||||||
|
|
||||||
|
$expected = true;
|
||||||
|
$actual =$isValid;
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if test superior operator is working
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testNotMatchingConditionSuperior()
|
||||||
|
{
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$stubFacade = $this->generateAdapterStub(399, 'EUR');
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$isValid = $condition1->isMatching();
|
||||||
|
|
||||||
|
$expected = false;
|
||||||
|
$actual =$isValid;
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check currency is checked
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testMatchingConditionCurrency()
|
||||||
|
{
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$stubFacade = $this->generateAdapterStub(400, 'EUR');
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::EQUAL,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$isValid = $condition1->isMatching();
|
||||||
|
|
||||||
|
$expected = true;
|
||||||
|
$actual =$isValid;
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check currency is checked
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testNotMatchingConditionCurrency()
|
||||||
|
{
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$stubFacade = $this->generateAdapterStub(400.00, 'EUR');
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::EQUAL,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'USD');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$isValid = $condition1->isMatching();
|
||||||
|
|
||||||
|
$expected = false;
|
||||||
|
$actual =$isValid;
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check unknown currency
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\ConditionAbstract::isCurrencyValid
|
||||||
|
* @expectedException \Thelia\Exception\InvalidConditionValueException
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testUnknownCurrencyCode()
|
||||||
|
{
|
||||||
|
$stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getTranslator')
|
||||||
|
->will($this->returnValue($stubTranslator));
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getConditionEvaluator')
|
||||||
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
|
$currencies = CurrencyQuery::create();
|
||||||
|
$currencies = $currencies->find();
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getAvailableCurrencies')
|
||||||
|
->will($this->returnValue($currencies));
|
||||||
|
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::EQUAL,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'UNK');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
|
||||||
|
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('get')
|
||||||
|
->will($this->returnValue($condition1));
|
||||||
|
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('has')
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getContainer')
|
||||||
|
->will($this->returnValue($stubContainer));
|
||||||
|
|
||||||
|
$conditionFactory = new ConditionFactory($stubContainer);
|
||||||
|
|
||||||
|
$collection = new ConditionCollection();
|
||||||
|
$collection->add($condition1);
|
||||||
|
|
||||||
|
$serialized = $conditionFactory->serializeConditionCollection($collection);
|
||||||
|
$unserialized = $conditionFactory->unserializeConditionCollection($serialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check invalid currency
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\ConditionAbstract::isPriceValid
|
||||||
|
* @expectedException \Thelia\Exception\InvalidConditionValueException
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testInvalidCurrencyValue()
|
||||||
|
{
|
||||||
|
$stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getTranslator')
|
||||||
|
->will($this->returnValue($stubTranslator));
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getConditionEvaluator')
|
||||||
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
|
$currencies = CurrencyQuery::create();
|
||||||
|
$currencies = $currencies->find();
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getAvailableCurrencies')
|
||||||
|
->will($this->returnValue($currencies));
|
||||||
|
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::EQUAL,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 'notfloat',
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
|
||||||
|
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('get')
|
||||||
|
->will($this->returnValue($condition1));
|
||||||
|
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('has')
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getContainer')
|
||||||
|
->will($this->returnValue($stubContainer));
|
||||||
|
|
||||||
|
$conditionFactory = new ConditionFactory($stubContainer);
|
||||||
|
|
||||||
|
$collection = new ConditionCollection();
|
||||||
|
$collection->add($condition1);
|
||||||
|
|
||||||
|
$serialized = $conditionFactory->serializeConditionCollection($collection);
|
||||||
|
$unserialized = $conditionFactory->unserializeConditionCollection($serialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check invalid currency
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\ConditionAbstract::isPriceValid
|
||||||
|
* @expectedException \Thelia\Exception\InvalidConditionValueException
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testPriceAsZero()
|
||||||
|
{
|
||||||
|
$stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getTranslator')
|
||||||
|
->will($this->returnValue($stubTranslator));
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getConditionEvaluator')
|
||||||
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
|
$currencies = CurrencyQuery::create();
|
||||||
|
$currencies = $currencies->find();
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getAvailableCurrencies')
|
||||||
|
->will($this->returnValue($currencies));
|
||||||
|
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::EQUAL,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 0.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
|
||||||
|
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('get')
|
||||||
|
->will($this->returnValue($condition1));
|
||||||
|
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('has')
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getContainer')
|
||||||
|
->will($this->returnValue($stubContainer));
|
||||||
|
|
||||||
|
$conditionFactory = new ConditionFactory($stubContainer);
|
||||||
|
|
||||||
|
$collection = new ConditionCollection();
|
||||||
|
$collection->add($condition1);
|
||||||
|
|
||||||
|
$serialized = $conditionFactory->serializeConditionCollection($collection);
|
||||||
|
$unserialized = $conditionFactory->unserializeConditionCollection($serialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate adapter stub
|
||||||
|
*
|
||||||
|
* @param int $cartTotalPrice Cart total price
|
||||||
|
* @param string $checkoutCurrency Checkout currency
|
||||||
|
* @param string $i18nOutput Output from each translation
|
||||||
|
*
|
||||||
|
* @return \PHPUnit_Framework_MockObject_MockObject
|
||||||
|
*/
|
||||||
|
public function generateFacadeStub($cartTotalPrice = 400, $checkoutCurrency = 'EUR', $i18nOutput = '')
|
||||||
|
{
|
||||||
|
$stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCartTotalPrice')
|
||||||
|
->will($this->returnValue($cartTotalPrice));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCheckoutCurrency')
|
||||||
|
->will($this->returnValue($checkoutCurrency));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getConditionEvaluator')
|
||||||
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
|
$stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubTranslator->expects($this->any())
|
||||||
|
->method('trans')
|
||||||
|
->will($this->returnValue($i18nOutput));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getTranslator')
|
||||||
|
->will($this->returnValue($stubTranslator));
|
||||||
|
|
||||||
|
$currency1 = new Currency();
|
||||||
|
$currency1->setCode('EUR');
|
||||||
|
$currency2 = new Currency();
|
||||||
|
$currency2->setCode('USD');
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getAvailableCurrencies')
|
||||||
|
->will($this->returnValue(array($currency1, $currency2)));
|
||||||
|
|
||||||
|
return $stubFacade;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check getName i18n
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForTotalAmount::getName
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testGetName()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub(399, 'EUR', 'Cart total amount');
|
||||||
|
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
|
||||||
|
$actual = $condition1->getName();
|
||||||
|
$expected = 'Cart total amount';
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check tooltip i18n
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForTotalAmount::getToolTip
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testGetToolTip()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub(399, 'EUR', 'If cart total amount is <strong>%operator%</strong> %amount% %currency%');
|
||||||
|
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::EQUAL,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$actual = $condition1->getToolTip();
|
||||||
|
$expected = 'If cart total amount is <strong>%operator%</strong> %amount% %currency%';
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check validator
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForTotalAmount::generateInputs
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testGetValidator()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub(399, 'EUR', 'Price');
|
||||||
|
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::EQUAL,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR');
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$actual = $condition1->getValidators();
|
||||||
|
|
||||||
|
$validators = array(
|
||||||
|
'inputs' => array(
|
||||||
|
MatchForTotalAmount::INPUT1 => array(
|
||||||
|
'title' => 'Price',
|
||||||
|
'availableOperators' => array(
|
||||||
|
'<' => 'Price',
|
||||||
|
'<=' => 'Price',
|
||||||
|
'==' => 'Price',
|
||||||
|
'>=' => 'Price',
|
||||||
|
'>' => 'Price'
|
||||||
|
),
|
||||||
|
'availableValues' => '',
|
||||||
|
'type' => 'text',
|
||||||
|
'class' => 'form-control',
|
||||||
|
'value' => '',
|
||||||
|
'selectedOperator' => ''
|
||||||
|
),
|
||||||
|
MatchForTotalAmount::INPUT2 => array(
|
||||||
|
'title' => 'Price',
|
||||||
|
'availableOperators' => array('==' => 'Price'),
|
||||||
|
'availableValues' => array(
|
||||||
|
'EUR' => '€',
|
||||||
|
'USD' => '$',
|
||||||
|
'GBP' => '£',
|
||||||
|
),
|
||||||
|
'type' => 'select',
|
||||||
|
'class' => 'form-control',
|
||||||
|
'value' => '',
|
||||||
|
'selectedOperator' => Operators::EQUAL
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'setOperators' => array(
|
||||||
|
'price' => '==',
|
||||||
|
'currency' => '=='
|
||||||
|
),
|
||||||
|
'setValues' => array(
|
||||||
|
'price' => 400,
|
||||||
|
'currency' => 'EUR'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$expected = $validators;
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tears down the fixture, for example, closes a network connection.
|
||||||
|
* This method is called after a test is executed.
|
||||||
|
*/
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -33,13 +33,13 @@ use Thelia\Coupon\FacadeInterface;
|
|||||||
* Date: 8/19/13
|
* Date: 8/19/13
|
||||||
* Time: 3:24 PM
|
* Time: 3:24 PM
|
||||||
*
|
*
|
||||||
* Unit Test MatchForXArticlesManager Class
|
* Unit Test MatchForXArticles Class
|
||||||
*
|
*
|
||||||
* @package Constraint
|
* @package Constraint
|
||||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
class MatchForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,7 +54,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* Check if validity test on BackOffice inputs are working
|
* Check if validity test on BackOffice inputs are working
|
||||||
*
|
*
|
||||||
* @covers Thelia\Condition\Implementation\MatchForXArticlesManager::setValidators
|
* @covers Thelia\Condition\Implementation\MatchForXArticles::setValidators
|
||||||
* @expectedException \Thelia\Exception\InvalidConditionOperatorException
|
* @expectedException \Thelia\Exception\InvalidConditionOperatorException
|
||||||
*/
|
*/
|
||||||
public function testInValidBackOfficeInputOperator()
|
public function testInValidBackOfficeInputOperator()
|
||||||
@@ -72,12 +72,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
->method('getConditionEvaluator')
|
->method('getConditionEvaluator')
|
||||||
->will($this->returnValue(new ConditionEvaluator()));
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
$condition1 = new MatchForXArticlesManager($stubFacade);
|
$condition1 = new MatchForXArticles($stubFacade);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForXArticlesManager::INPUT1 => Operators::IN
|
MatchForXArticles::INPUT1 => Operators::IN
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForXArticlesManager::INPUT1 => 5
|
MatchForXArticles::INPUT1 => 5
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* Check if validity test on BackOffice inputs are working
|
* Check if validity test on BackOffice inputs are working
|
||||||
*
|
*
|
||||||
* @covers Thelia\Condition\Implementation\MatchForXArticlesManager::setValidators
|
* @covers Thelia\Condition\Implementation\MatchForXArticles::setValidators
|
||||||
* @expectedException \Thelia\Exception\InvalidConditionValueException
|
* @expectedException \Thelia\Exception\InvalidConditionValueException
|
||||||
*/
|
*/
|
||||||
public function testInValidBackOfficeInputValue()
|
public function testInValidBackOfficeInputValue()
|
||||||
@@ -108,12 +108,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
->method('getConditionEvaluator')
|
->method('getConditionEvaluator')
|
||||||
->will($this->returnValue(new ConditionEvaluator()));
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
$condition1 = new MatchForXArticlesManager($stubFacade);
|
$condition1 = new MatchForXArticles($stubFacade);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR
|
MatchForXArticles::INPUT1 => Operators::SUPERIOR
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForXArticlesManager::INPUT1 => 'X'
|
MatchForXArticles::INPUT1 => 'X'
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* Check if test inferior operator is working
|
* Check if test inferior operator is working
|
||||||
*
|
*
|
||||||
* @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching
|
* @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function testMatchingRuleInferior()
|
public function testMatchingRuleInferior()
|
||||||
@@ -144,12 +144,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
->method('getConditionEvaluator')
|
->method('getConditionEvaluator')
|
||||||
->will($this->returnValue(new ConditionEvaluator()));
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
$condition1 = new MatchForXArticlesManager($stubFacade);
|
$condition1 = new MatchForXArticles($stubFacade);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForXArticlesManager::INPUT1 => Operators::INFERIOR
|
MatchForXArticles::INPUT1 => Operators::INFERIOR
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForXArticlesManager::INPUT1 => 5
|
MatchForXArticles::INPUT1 => 5
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* Check if test inferior operator is working
|
* Check if test inferior operator is working
|
||||||
*
|
*
|
||||||
* @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching
|
* @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function testNotMatchingRuleInferior()
|
public function testNotMatchingRuleInferior()
|
||||||
@@ -180,12 +180,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
->method('getConditionEvaluator')
|
->method('getConditionEvaluator')
|
||||||
->will($this->returnValue(new ConditionEvaluator()));
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
$condition1 = new MatchForXArticlesManager($stubFacade);
|
$condition1 = new MatchForXArticles($stubFacade);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForXArticlesManager::INPUT1 => Operators::INFERIOR
|
MatchForXArticles::INPUT1 => Operators::INFERIOR
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForXArticlesManager::INPUT1 => 4,
|
MatchForXArticles::INPUT1 => 4,
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* Check if test inferior operator is working
|
* Check if test inferior operator is working
|
||||||
*
|
*
|
||||||
* @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching
|
* @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function testMatchingRuleInferiorEquals()
|
public function testMatchingRuleInferiorEquals()
|
||||||
@@ -216,12 +216,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
->method('getConditionEvaluator')
|
->method('getConditionEvaluator')
|
||||||
->will($this->returnValue(new ConditionEvaluator()));
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
$condition1 = new MatchForXArticlesManager($stubFacade);
|
$condition1 = new MatchForXArticles($stubFacade);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForXArticlesManager::INPUT1 => Operators::INFERIOR_OR_EQUAL,
|
MatchForXArticles::INPUT1 => Operators::INFERIOR_OR_EQUAL,
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForXArticlesManager::INPUT1 => 5,
|
MatchForXArticles::INPUT1 => 5,
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
@@ -235,7 +235,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* Check if test inferior operator is working
|
* Check if test inferior operator is working
|
||||||
*
|
*
|
||||||
* @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching
|
* @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function testMatchingRuleInferiorEquals2()
|
public function testMatchingRuleInferiorEquals2()
|
||||||
@@ -252,12 +252,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
->method('getConditionEvaluator')
|
->method('getConditionEvaluator')
|
||||||
->will($this->returnValue(new ConditionEvaluator()));
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
$condition1 = new MatchForXArticlesManager($stubFacade);
|
$condition1 = new MatchForXArticles($stubFacade);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForXArticlesManager::INPUT1 => Operators::INFERIOR_OR_EQUAL
|
MatchForXArticles::INPUT1 => Operators::INFERIOR_OR_EQUAL
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForXArticlesManager::INPUT1 => 4
|
MatchForXArticles::INPUT1 => 4
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
@@ -271,7 +271,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* Check if test inferior operator is working
|
* Check if test inferior operator is working
|
||||||
*
|
*
|
||||||
* @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching
|
* @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function testNotMatchingRuleInferiorEquals()
|
public function testNotMatchingRuleInferiorEquals()
|
||||||
@@ -288,12 +288,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
->method('getConditionEvaluator')
|
->method('getConditionEvaluator')
|
||||||
->will($this->returnValue(new ConditionEvaluator()));
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
$condition1 = new MatchForXArticlesManager($stubFacade);
|
$condition1 = new MatchForXArticles($stubFacade);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForXArticlesManager::INPUT1 => Operators::INFERIOR_OR_EQUAL
|
MatchForXArticles::INPUT1 => Operators::INFERIOR_OR_EQUAL
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForXArticlesManager::INPUT1 => 3
|
MatchForXArticles::INPUT1 => 3
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
@@ -307,7 +307,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* Check if test equals operator is working
|
* Check if test equals operator is working
|
||||||
*
|
*
|
||||||
* @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching
|
* @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function testMatchingRuleEqual()
|
public function testMatchingRuleEqual()
|
||||||
@@ -324,12 +324,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
->method('getConditionEvaluator')
|
->method('getConditionEvaluator')
|
||||||
->will($this->returnValue(new ConditionEvaluator()));
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
$condition1 = new MatchForXArticlesManager($stubFacade);
|
$condition1 = new MatchForXArticles($stubFacade);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForXArticlesManager::INPUT1 => Operators::EQUAL
|
MatchForXArticles::INPUT1 => Operators::EQUAL
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForXArticlesManager::INPUT1 => 4
|
MatchForXArticles::INPUT1 => 4
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
@@ -343,7 +343,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* Check if test equals operator is working
|
* Check if test equals operator is working
|
||||||
*
|
*
|
||||||
* @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching
|
* @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function testNotMatchingRuleEqual()
|
public function testNotMatchingRuleEqual()
|
||||||
@@ -360,12 +360,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
->method('getConditionEvaluator')
|
->method('getConditionEvaluator')
|
||||||
->will($this->returnValue(new ConditionEvaluator()));
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
$condition1 = new MatchForXArticlesManager($stubFacade);
|
$condition1 = new MatchForXArticles($stubFacade);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForXArticlesManager::INPUT1 => Operators::EQUAL
|
MatchForXArticles::INPUT1 => Operators::EQUAL
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForXArticlesManager::INPUT1 => 5
|
MatchForXArticles::INPUT1 => 5
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
@@ -379,7 +379,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* Check if test superior operator is working
|
* Check if test superior operator is working
|
||||||
*
|
*
|
||||||
* @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching
|
* @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function testMatchingRuleSuperiorEquals()
|
public function testMatchingRuleSuperiorEquals()
|
||||||
@@ -396,12 +396,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
->method('getConditionEvaluator')
|
->method('getConditionEvaluator')
|
||||||
->will($this->returnValue(new ConditionEvaluator()));
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
$condition1 = new MatchForXArticlesManager($stubFacade);
|
$condition1 = new MatchForXArticles($stubFacade);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL
|
MatchForXArticles::INPUT1 => Operators::SUPERIOR_OR_EQUAL
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForXArticlesManager::INPUT1 => 4
|
MatchForXArticles::INPUT1 => 4
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
@@ -415,7 +415,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* Check if test superior operator is working
|
* Check if test superior operator is working
|
||||||
*
|
*
|
||||||
* @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching
|
* @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function testMatchingRuleSuperiorEquals2()
|
public function testMatchingRuleSuperiorEquals2()
|
||||||
@@ -432,12 +432,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
->method('getConditionEvaluator')
|
->method('getConditionEvaluator')
|
||||||
->will($this->returnValue(new ConditionEvaluator()));
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
$condition1 = new MatchForXArticlesManager($stubFacade);
|
$condition1 = new MatchForXArticles($stubFacade);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL
|
MatchForXArticles::INPUT1 => Operators::SUPERIOR_OR_EQUAL
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForXArticlesManager::INPUT1 => 3
|
MatchForXArticles::INPUT1 => 3
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
@@ -451,7 +451,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* Check if test superior operator is working
|
* Check if test superior operator is working
|
||||||
*
|
*
|
||||||
* @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching
|
* @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function testNotMatchingRuleSuperiorEquals()
|
public function testNotMatchingRuleSuperiorEquals()
|
||||||
@@ -468,12 +468,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
->method('getConditionEvaluator')
|
->method('getConditionEvaluator')
|
||||||
->will($this->returnValue(new ConditionEvaluator()));
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
$condition1 = new MatchForXArticlesManager($stubFacade);
|
$condition1 = new MatchForXArticles($stubFacade);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL
|
MatchForXArticles::INPUT1 => Operators::SUPERIOR_OR_EQUAL
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForXArticlesManager::INPUT1 => 5
|
MatchForXArticles::INPUT1 => 5
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
@@ -487,7 +487,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* Check if test superior operator is working
|
* Check if test superior operator is working
|
||||||
*
|
*
|
||||||
* @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching
|
* @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function testMatchingRuleSuperior()
|
public function testMatchingRuleSuperior()
|
||||||
@@ -504,12 +504,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
->method('getConditionEvaluator')
|
->method('getConditionEvaluator')
|
||||||
->will($this->returnValue(new ConditionEvaluator()));
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
$condition1 = new MatchForXArticlesManager($stubFacade);
|
$condition1 = new MatchForXArticles($stubFacade);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR
|
MatchForXArticles::INPUT1 => Operators::SUPERIOR
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForXArticlesManager::INPUT1 => 3
|
MatchForXArticles::INPUT1 => 3
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
@@ -523,7 +523,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* Check if test superior operator is working
|
* Check if test superior operator is working
|
||||||
*
|
*
|
||||||
* @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching
|
* @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function testNotMatchingRuleSuperior()
|
public function testNotMatchingRuleSuperior()
|
||||||
@@ -540,12 +540,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
->method('getConditionEvaluator')
|
->method('getConditionEvaluator')
|
||||||
->will($this->returnValue(new ConditionEvaluator()));
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
$condition1 = new MatchForXArticlesManager($stubFacade);
|
$condition1 = new MatchForXArticles($stubFacade);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR
|
MatchForXArticles::INPUT1 => Operators::SUPERIOR
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForXArticlesManager::INPUT1 => 4
|
MatchForXArticles::INPUT1 => 4
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
@@ -570,12 +570,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
->method('getConditionEvaluator')
|
->method('getConditionEvaluator')
|
||||||
->will($this->returnValue(new ConditionEvaluator()));
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
$condition1 = new MatchForXArticlesManager($stubFacade);
|
$condition1 = new MatchForXArticles($stubFacade);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR
|
MatchForXArticles::INPUT1 => Operators::SUPERIOR
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForXArticlesManager::INPUT1 => 4
|
MatchForXArticles::INPUT1 => 4
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
@@ -606,17 +606,17 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
->method('getConditionEvaluator')
|
->method('getConditionEvaluator')
|
||||||
->will($this->returnValue(new ConditionEvaluator()));
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
$condition1 = new MatchForXArticlesManager($stubFacade);
|
$condition1 = new MatchForXArticles($stubFacade);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR
|
MatchForXArticles::INPUT1 => Operators::SUPERIOR
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForXArticlesManager::INPUT1 => 4
|
MatchForXArticles::INPUT1 => 4
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
$expected = array(
|
$expected = array(
|
||||||
MatchForXArticlesManager::INPUT1 => array(
|
MatchForXArticles::INPUT1 => array(
|
||||||
Operators::INFERIOR,
|
Operators::INFERIOR,
|
||||||
Operators::INFERIOR_OR_EQUAL,
|
Operators::INFERIOR_OR_EQUAL,
|
||||||
Operators::EQUAL,
|
Operators::EQUAL,
|
||||||
@@ -630,6 +630,142 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate adapter stub
|
||||||
|
*
|
||||||
|
* @param int $cartTotalPrice Cart total price
|
||||||
|
* @param string $checkoutCurrency Checkout currency
|
||||||
|
* @param string $i18nOutput Output from each translation
|
||||||
|
*
|
||||||
|
* @return \PHPUnit_Framework_MockObject_MockObject
|
||||||
|
*/
|
||||||
|
public function generateFacadeStub($cartTotalPrice = 400, $checkoutCurrency = 'EUR', $i18nOutput = '')
|
||||||
|
{
|
||||||
|
$stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCartTotalPrice')
|
||||||
|
->will($this->returnValue($cartTotalPrice));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCheckoutCurrency')
|
||||||
|
->will($this->returnValue($checkoutCurrency));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getConditionEvaluator')
|
||||||
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
|
$stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubTranslator->expects($this->any())
|
||||||
|
->method('trans')
|
||||||
|
->will($this->returnValue($i18nOutput));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getTranslator')
|
||||||
|
->will($this->returnValue($stubTranslator));
|
||||||
|
|
||||||
|
return $stubFacade;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check getName i18n
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForXArticles::getName
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testGetName()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub(399, 'EUR', 'Number of articles in cart');
|
||||||
|
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$condition1 = new MatchForXArticles($stubFacade);
|
||||||
|
|
||||||
|
$actual = $condition1->getName();
|
||||||
|
$expected = 'Number of articles in cart';
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check tooltip i18n
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForXArticles::getToolTip
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testGetToolTip()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub(399, 'EUR', 'If cart products quantity is <strong>superior to</strong> 4');
|
||||||
|
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$condition1 = new MatchForXArticles($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForXArticles::INPUT1 => Operators::SUPERIOR
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForXArticles::INPUT1 => 4
|
||||||
|
);
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$actual = $condition1->getToolTip();
|
||||||
|
$expected = 'If cart products quantity is <strong>superior to</strong> 4';
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check validator
|
||||||
|
*
|
||||||
|
* @covers Thelia\Condition\Implementation\MatchForXArticles::generateInputs
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testGetValidator()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub(399, 'EUR', 'Price');
|
||||||
|
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$condition1 = new MatchForXArticles($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForXArticles::INPUT1 => Operators::SUPERIOR
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForXArticles::INPUT1 => 4
|
||||||
|
);
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$actual = $condition1->getValidators();
|
||||||
|
|
||||||
|
$validators = array(
|
||||||
|
'inputs' => array(
|
||||||
|
MatchForXArticles::INPUT1 => array(
|
||||||
|
'title' => 'Price',
|
||||||
|
'availableOperators' => array(
|
||||||
|
'<' => 'Price',
|
||||||
|
'<=' => 'Price',
|
||||||
|
'==' => 'Price',
|
||||||
|
'>=' => 'Price',
|
||||||
|
'>' => 'Price'
|
||||||
|
),
|
||||||
|
'type' => 'text',
|
||||||
|
'class' => 'form-control',
|
||||||
|
'value' => '',
|
||||||
|
'selectedOperator' => ''
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'setOperators' => array(
|
||||||
|
'quantity' => '>'
|
||||||
|
),
|
||||||
|
'setValues' => array(
|
||||||
|
'quantity' => 4
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$expected = $validators;
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tears down the fixture, for example, closes a network connection.
|
* Tears down the fixture, for example, closes a network connection.
|
||||||
* This method is called after a test is executed.
|
* This method is called after a test is executed.
|
||||||
272
core/lib/Thelia/Tests/Coupon/BaseFacadeTest.php
Normal file
@@ -0,0 +1,272 @@
|
|||||||
|
<?php
|
||||||
|
/**********************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Thelia */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : info@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it and/or modify */
|
||||||
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
|
/* the Free Software Foundation; either version 3 of the License */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will be useful, */
|
||||||
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
|
/* GNU General Public License for more details. */
|
||||||
|
/* */
|
||||||
|
/* You should have received a copy of the GNU General Public License */
|
||||||
|
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
/* */
|
||||||
|
/**********************************************************************************/
|
||||||
|
|
||||||
|
namespace Thelia\Coupon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by JetBrains PhpStorm.
|
||||||
|
* Date: 8/19/13
|
||||||
|
* Time: 3:24 PM
|
||||||
|
*
|
||||||
|
* Unit Test BaseFacade Class
|
||||||
|
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-11-17 at 18:59:24.
|
||||||
|
*
|
||||||
|
* @package Coupon
|
||||||
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class BaseFacadeTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up the fixture, for example, opens a network connection.
|
||||||
|
* This method is called before a test is executed.
|
||||||
|
*/
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tears down the fixture, for example, closes a network connection.
|
||||||
|
* This method is called after a test is executed.
|
||||||
|
*/
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\BaseFacade::getCart
|
||||||
|
* @todo Implement testGetCart().
|
||||||
|
*/
|
||||||
|
public function testGetCart()
|
||||||
|
{
|
||||||
|
// Remove the following lines when you implement this test.
|
||||||
|
$this->markTestIncomplete(
|
||||||
|
'This test has not been implemented yet.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\BaseFacade::getDeliveryAddress
|
||||||
|
* @todo Implement testGetDeliveryAddress().
|
||||||
|
*/
|
||||||
|
public function testGetDeliveryAddress()
|
||||||
|
{
|
||||||
|
// Remove the following lines when you implement this test.
|
||||||
|
$this->markTestIncomplete(
|
||||||
|
'This test has not been implemented yet.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\BaseFacade::getCustomer
|
||||||
|
* @todo Implement testGetCustomer().
|
||||||
|
*/
|
||||||
|
public function testGetCustomer()
|
||||||
|
{
|
||||||
|
// Remove the following lines when you implement this test.
|
||||||
|
$this->markTestIncomplete(
|
||||||
|
'This test has not been implemented yet.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\BaseFacade::getCheckoutTotalPrice
|
||||||
|
* @todo Implement testGetCheckoutTotalPrice().
|
||||||
|
*/
|
||||||
|
public function testGetCheckoutTotalPrice()
|
||||||
|
{
|
||||||
|
// Remove the following lines when you implement this test.
|
||||||
|
$this->markTestIncomplete(
|
||||||
|
'This test has not been implemented yet.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\BaseFacade::getCheckoutPostagePrice
|
||||||
|
* @todo Implement testGetCheckoutPostagePrice().
|
||||||
|
*/
|
||||||
|
public function testGetCheckoutPostagePrice()
|
||||||
|
{
|
||||||
|
// Remove the following lines when you implement this test.
|
||||||
|
$this->markTestIncomplete(
|
||||||
|
'This test has not been implemented yet.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\BaseFacade::getCartTotalPrice
|
||||||
|
* @todo Implement testGetCartTotalPrice().
|
||||||
|
*/
|
||||||
|
public function testGetCartTotalPrice()
|
||||||
|
{
|
||||||
|
// Remove the following lines when you implement this test.
|
||||||
|
$this->markTestIncomplete(
|
||||||
|
'This test has not been implemented yet.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\BaseFacade::getCheckoutCurrency
|
||||||
|
* @todo Implement testGetCheckoutCurrency().
|
||||||
|
*/
|
||||||
|
public function testGetCheckoutCurrency()
|
||||||
|
{
|
||||||
|
// Remove the following lines when you implement this test.
|
||||||
|
$this->markTestIncomplete(
|
||||||
|
'This test has not been implemented yet.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\BaseFacade::getNbArticlesInCart
|
||||||
|
* @todo Implement testGetNbArticlesInCart().
|
||||||
|
*/
|
||||||
|
public function testGetNbArticlesInCart()
|
||||||
|
{
|
||||||
|
// Remove the following lines when you implement this test.
|
||||||
|
$this->markTestIncomplete(
|
||||||
|
'This test has not been implemented yet.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\BaseFacade::getCurrentCoupons
|
||||||
|
* @todo Implement testGetCurrentCoupons().
|
||||||
|
*/
|
||||||
|
public function testGetCurrentCoupons()
|
||||||
|
{
|
||||||
|
// Remove the following lines when you implement this test.
|
||||||
|
$this->markTestIncomplete(
|
||||||
|
'This test has not been implemented yet.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\BaseFacade::findOneCouponByCode
|
||||||
|
* @todo Implement testFindOneCouponByCode().
|
||||||
|
*/
|
||||||
|
public function testFindOneCouponByCode()
|
||||||
|
{
|
||||||
|
// Remove the following lines when you implement this test.
|
||||||
|
$this->markTestIncomplete(
|
||||||
|
'This test has not been implemented yet.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\BaseFacade::getContainer
|
||||||
|
* @todo Implement testGetContainer().
|
||||||
|
*/
|
||||||
|
public function testGetContainer()
|
||||||
|
{
|
||||||
|
// Remove the following lines when you implement this test.
|
||||||
|
$this->markTestIncomplete(
|
||||||
|
'This test has not been implemented yet.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\BaseFacade::getTranslator
|
||||||
|
* @todo Implement testGetTranslator().
|
||||||
|
*/
|
||||||
|
public function testGetTranslator()
|
||||||
|
{
|
||||||
|
// Remove the following lines when you implement this test.
|
||||||
|
$this->markTestIncomplete(
|
||||||
|
'This test has not been implemented yet.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\BaseFacade::getMainCurrency
|
||||||
|
* @todo Implement testGetMainCurrency().
|
||||||
|
*/
|
||||||
|
public function testGetMainCurrency()
|
||||||
|
{
|
||||||
|
// Remove the following lines when you implement this test.
|
||||||
|
$this->markTestIncomplete(
|
||||||
|
'This test has not been implemented yet.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\BaseFacade::getRequest
|
||||||
|
* @todo Implement testGetRequest().
|
||||||
|
*/
|
||||||
|
public function testGetRequest()
|
||||||
|
{
|
||||||
|
// Remove the following lines when you implement this test.
|
||||||
|
$this->markTestIncomplete(
|
||||||
|
'This test has not been implemented yet.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\BaseFacade::getConditionEvaluator
|
||||||
|
* @todo Implement testGetConditionEvaluator().
|
||||||
|
*/
|
||||||
|
public function testGetConditionEvaluator()
|
||||||
|
{
|
||||||
|
// Remove the following lines when you implement this test.
|
||||||
|
$this->markTestIncomplete(
|
||||||
|
'This test has not been implemented yet.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\BaseFacade::getAvailableCurrencies
|
||||||
|
* @todo Implement testGetAvailableCurrencies().
|
||||||
|
*/
|
||||||
|
public function testGetAvailableCurrencies()
|
||||||
|
{
|
||||||
|
// Remove the following lines when you implement this test.
|
||||||
|
$this->markTestIncomplete(
|
||||||
|
'This test has not been implemented yet.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\BaseFacade::getDispatcher
|
||||||
|
* @todo Implement testGetDispatcher().
|
||||||
|
*/
|
||||||
|
public function testGetDispatcher()
|
||||||
|
{
|
||||||
|
// Remove the following lines when you implement this test.
|
||||||
|
$this->markTestIncomplete(
|
||||||
|
'This test has not been implemented yet.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\BaseFacade::getCartFromTrait
|
||||||
|
* @todo Implement testGetCartFromTrait().
|
||||||
|
*/
|
||||||
|
public function testGetCartFromTrait()
|
||||||
|
{
|
||||||
|
// Remove the following lines when you implement this test.
|
||||||
|
$this->markTestIncomplete(
|
||||||
|
'This test has not been implemented yet.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
405
core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php
Normal file
@@ -0,0 +1,405 @@
|
|||||||
|
<?php
|
||||||
|
/**********************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Thelia */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : info@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it and/or modify */
|
||||||
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
|
/* the Free Software Foundation; either version 3 of the License */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will be useful, */
|
||||||
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
|
/* GNU General Public License for more details. */
|
||||||
|
/* */
|
||||||
|
/* You should have received a copy of the GNU General Public License */
|
||||||
|
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
/* */
|
||||||
|
/**********************************************************************************/
|
||||||
|
|
||||||
|
namespace Thelia\Coupon;
|
||||||
|
use Thelia\Condition\ConditionCollection;
|
||||||
|
use Thelia\Condition\ConditionEvaluator;
|
||||||
|
use Thelia\Condition\ConditionFactory;
|
||||||
|
use Thelia\Condition\Implementation\MatchForTotalAmount;
|
||||||
|
use Thelia\Condition\Operators;
|
||||||
|
use Thelia\Coupon\Type\RemoveXAmount;
|
||||||
|
use Thelia\Model\Coupon;
|
||||||
|
use Thelia\Model\CurrencyQuery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by JetBrains PhpStorm.
|
||||||
|
* Date: 8/19/13
|
||||||
|
* Time: 3:24 PM
|
||||||
|
*
|
||||||
|
* Unit Test CouponFactory Class
|
||||||
|
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-11-17 at 18:59:24.
|
||||||
|
*
|
||||||
|
* @package Coupon
|
||||||
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class CouponFactoryTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up the fixture, for example, opens a network connection.
|
||||||
|
* This method is called before a test is executed.
|
||||||
|
*/
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate adapter stub
|
||||||
|
*
|
||||||
|
* @param int $cartTotalPrice Cart total price
|
||||||
|
* @param string $checkoutCurrency Checkout currency
|
||||||
|
* @param string $i18nOutput Output from each translation
|
||||||
|
*
|
||||||
|
* @return \PHPUnit_Framework_MockObject_MockObject
|
||||||
|
*/
|
||||||
|
public function generateFacadeStub($cartTotalPrice = 400, $checkoutCurrency = 'EUR', $i18nOutput = '')
|
||||||
|
{
|
||||||
|
$stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$currencies = CurrencyQuery::create();
|
||||||
|
$currencies = $currencies->find();
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getAvailableCurrencies')
|
||||||
|
->will($this->returnValue($currencies));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCartTotalPrice')
|
||||||
|
->will($this->returnValue($cartTotalPrice));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCheckoutCurrency')
|
||||||
|
->will($this->returnValue($checkoutCurrency));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getConditionEvaluator')
|
||||||
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
|
$stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubTranslator->expects($this->any())
|
||||||
|
->method('trans')
|
||||||
|
->will($this->returnValue($i18nOutput));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getTranslator')
|
||||||
|
->will($this->returnValue($stubTranslator));
|
||||||
|
|
||||||
|
return $stubFacade;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a valid Coupon model
|
||||||
|
*/
|
||||||
|
public function generateCouponModel($facade, ConditionFactory $conditionFactory)
|
||||||
|
{
|
||||||
|
// Coupons
|
||||||
|
$coupon1 = new Coupon();
|
||||||
|
$coupon1->setCode('XMAS');
|
||||||
|
$coupon1->setType('thelia.coupon.type.remove_x_amount');
|
||||||
|
$coupon1->setTitle('Christmas coupon');
|
||||||
|
$coupon1->setShortDescription('Coupon for Christmas removing 10€ if your total checkout is more than 40€');
|
||||||
|
$coupon1->setDescription('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras at luctus tellus. Integer turpis mauris, aliquet vitae risus tristique, pellentesque vestibulum urna. Vestibulum sodales laoreet lectus dictum suscipit. Praesent vulputate, sem id varius condimentum, quam magna tempor elit, quis venenatis ligula nulla eget libero. Cras egestas euismod tellus, id pharetra leo suscipit quis. Donec lacinia ac lacus et ultricies. Nunc in porttitor neque. Proin at quam congue, consectetur orci sed, congue nulla. Nulla eleifend nunc ligula, nec pharetra elit tempus quis. Vivamus vel mauris sed est dictum blandit. Maecenas blandit dapibus velit ut sollicitudin. In in euismod mauris, consequat viverra magna. Cras velit velit, sollicitudin commodo tortor gravida, tempus varius nulla.
|
||||||
|
|
||||||
|
Donec rhoncus leo mauris, id porttitor ante luctus tempus. Curabitur quis augue feugiat, ullamcorper mauris ac, interdum mi. Quisque aliquam lorem vitae felis lobortis, id interdum turpis mattis. Vestibulum diam massa, ornare congue blandit quis, facilisis at nisl. In tortor metus, venenatis non arcu nec, sollicitudin ornare nisl. Nunc erat risus, varius nec urna at, iaculis lacinia elit. Aenean ut felis tempus, tincidunt odio non, sagittis nisl. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec vitae hendrerit elit. Nunc sit amet gravida risus, euismod lobortis massa. Nam a erat mauris. Nam a malesuada lorem. Nulla id accumsan dolor, sed rhoncus tellus. Quisque dictum felis sed leo auctor, at volutpat lectus viverra. Morbi rutrum, est ac aliquam imperdiet, nibh sem sagittis justo, ac mattis magna lacus eu nulla.
|
||||||
|
|
||||||
|
Duis interdum lectus nulla, nec pellentesque sapien condimentum at. Suspendisse potenti. Sed eu purus tellus. Nunc quis rhoncus metus. Fusce vitae tellus enim. Interdum et malesuada fames ac ante ipsum primis in faucibus. Etiam tempor porttitor erat vitae iaculis. Sed est elit, consequat non ornare vitae, vehicula eget lectus. Etiam consequat sapien mauris, eget consectetur magna imperdiet eget. Nunc sollicitudin luctus velit, in commodo nulla adipiscing fermentum. Fusce nisi sapien, posuere vitae metus sit amet, facilisis sollicitudin dui. Fusce ultricies auctor enim sit amet iaculis. Morbi at vestibulum enim, eget adipiscing eros.
|
||||||
|
|
||||||
|
Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentesque elit erat, lacinia sed semper ac, sagittis vel elit. Nam eu convallis est. Curabitur rhoncus odio vitae consectetur pellentesque. Nam vitae arcu nec ante scelerisque dignissim vel nec neque. Suspendisse augue nulla, mollis eget dui et, tempor facilisis erat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac diam ipsum. Donec convallis dui ultricies velit auctor, non lobortis nulla ultrices. Morbi vitae dignissim ante, sit amet lobortis tortor. Nunc dapibus condimentum augue, in molestie neque congue non.
|
||||||
|
|
||||||
|
Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.');
|
||||||
|
$coupon1->setAmount(10.00);
|
||||||
|
$coupon1->setIsUsed(true);
|
||||||
|
$coupon1->setIsEnabled(true);
|
||||||
|
$date = new \DateTime();
|
||||||
|
$coupon1->setExpirationDate($date->setTimestamp(strtotime("today + 3 months")));
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($facade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 40.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
|
);
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$condition2 = new MatchForTotalAmount($facade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::INFERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
|
);
|
||||||
|
$condition2->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$conditions = new ConditionCollection();
|
||||||
|
$conditions->add($condition1);
|
||||||
|
$conditions->add($condition2);
|
||||||
|
|
||||||
|
$serializedConditions = $conditionFactory->serializeConditionCollection($conditions);
|
||||||
|
$coupon1->setSerializedConditions($serializedConditions);
|
||||||
|
|
||||||
|
|
||||||
|
$coupon1->setMaxUsage(40);
|
||||||
|
$coupon1->setIsCumulative(true);
|
||||||
|
$coupon1->setIsRemovingPostage(false);
|
||||||
|
$coupon1->setIsAvailableOnSpecialOffers(true);
|
||||||
|
|
||||||
|
return $coupon1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tears down the fixture, for example, closes a network connection.
|
||||||
|
* This method is called after a test is executed.
|
||||||
|
*/
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\CouponFactory::buildCouponFromCode
|
||||||
|
*/
|
||||||
|
public function testBuildCouponFromCode()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub();
|
||||||
|
|
||||||
|
$stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container');
|
||||||
|
|
||||||
|
$conditionFactory = new ConditionFactory($stubContainer);
|
||||||
|
$couponModel = $this->generateCouponModel($stubFacade, $conditionFactory);
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('findOneCouponByCode')
|
||||||
|
->will($this->returnValue($couponModel));
|
||||||
|
|
||||||
|
$couponManager = new RemoveXAmount($stubFacade);
|
||||||
|
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 40.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
|
);
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$condition2 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::INFERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
|
);
|
||||||
|
$condition2->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$conditions = new ConditionCollection();
|
||||||
|
$conditions->add($condition1);
|
||||||
|
$conditions->add($condition2);
|
||||||
|
$stubConditionFactory = $this->getMockBuilder('\Thelia\Condition\ConditionFactory')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubConditionFactory->expects($this->any())
|
||||||
|
->method('unserializeConditionCollection')
|
||||||
|
->will($this->returnValue($conditions));
|
||||||
|
|
||||||
|
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('get')
|
||||||
|
->will($this->onConsecutiveCalls($stubFacade, $couponManager, $stubConditionFactory));
|
||||||
|
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('has')
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$factory = new CouponFactory($stubContainer);
|
||||||
|
$expected = $couponManager;
|
||||||
|
$actual = $factory->buildCouponFromCode('XMAS');
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\CouponFactory::buildCouponFromCode
|
||||||
|
*/
|
||||||
|
public function testBuildCouponFromCodeUnknownCode()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub();
|
||||||
|
|
||||||
|
$stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container');
|
||||||
|
|
||||||
|
$conditionFactory = new ConditionFactory($stubContainer);
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('findOneCouponByCode')
|
||||||
|
->will($this->returnValue(null));
|
||||||
|
|
||||||
|
$couponManager = new RemoveXAmount($stubFacade);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('get')
|
||||||
|
->will($this->onConsecutiveCalls($stubFacade, $couponManager));
|
||||||
|
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('has')
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$factory = new CouponFactory($stubContainer);
|
||||||
|
$actual = $factory->buildCouponFromCode('XMAS');
|
||||||
|
$expected = false;
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $actual, 'CouponFactory->buildCouponFromCode should return false if the given code is unknown');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\CouponFactory::buildCouponFromCode
|
||||||
|
* @expectedException \Thelia\Exception\CouponExpiredException
|
||||||
|
*/
|
||||||
|
public function testBuildCouponFromCodeExpiredCoupon()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub();
|
||||||
|
|
||||||
|
$stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container');
|
||||||
|
|
||||||
|
$conditionFactory = new ConditionFactory($stubContainer);
|
||||||
|
$couponModel = $this->generateCouponModel($stubFacade, $conditionFactory);
|
||||||
|
$date = new \DateTime();
|
||||||
|
$couponModel->setExpirationDate($date->setTimestamp(strtotime("today - 3 months")));
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('findOneCouponByCode')
|
||||||
|
->will($this->returnValue($couponModel));
|
||||||
|
|
||||||
|
$couponManager = new RemoveXAmount($stubFacade);
|
||||||
|
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 40.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
|
);
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$condition2 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::INFERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
|
);
|
||||||
|
$condition2->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$conditions = new ConditionCollection();
|
||||||
|
$conditions->add($condition1);
|
||||||
|
$conditions->add($condition2);
|
||||||
|
$stubConditionFactory = $this->getMockBuilder('\Thelia\Condition\ConditionFactory')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubConditionFactory->expects($this->any())
|
||||||
|
->method('unserializeConditionCollection')
|
||||||
|
->will($this->returnValue($conditions));
|
||||||
|
|
||||||
|
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('get')
|
||||||
|
->will($this->onConsecutiveCalls($stubFacade, $couponManager, $stubConditionFactory));
|
||||||
|
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('has')
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$factory = new CouponFactory($stubContainer);
|
||||||
|
$actual = $factory->buildCouponFromCode('XMAS');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\CouponFactory::buildCouponFromCode
|
||||||
|
* @expectedException \Thelia\Exception\InvalidConditionException
|
||||||
|
*/
|
||||||
|
public function testBuildCouponFromCodeNoConditionCoupon()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub();
|
||||||
|
|
||||||
|
$stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container');
|
||||||
|
|
||||||
|
$conditionFactory = new ConditionFactory($stubContainer);
|
||||||
|
$couponModel = $this->generateCouponModel($stubFacade, $conditionFactory);
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('findOneCouponByCode')
|
||||||
|
->will($this->returnValue($couponModel));
|
||||||
|
|
||||||
|
$couponManager = new RemoveXAmount($stubFacade);
|
||||||
|
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 40.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
|
);
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$condition2 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::INFERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
|
);
|
||||||
|
$condition2->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$conditions = new ConditionCollection();
|
||||||
|
$stubConditionFactory = $this->getMockBuilder('\Thelia\Condition\ConditionFactory')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubConditionFactory->expects($this->any())
|
||||||
|
->method('unserializeConditionCollection')
|
||||||
|
->will($this->returnValue($conditions));
|
||||||
|
|
||||||
|
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('get')
|
||||||
|
->will($this->onConsecutiveCalls($stubFacade, $couponManager, $stubConditionFactory));
|
||||||
|
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('has')
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$factory = new CouponFactory($stubContainer);
|
||||||
|
$actual = $factory->buildCouponFromCode('XMAS');
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
580
core/lib/Thelia/Tests/Coupon/CouponManagerTest.php
Normal file
@@ -0,0 +1,580 @@
|
|||||||
|
<?php
|
||||||
|
/**********************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Thelia */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : info@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it and/or modify */
|
||||||
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
|
/* the Free Software Foundation; either version 3 of the License */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will be useful, */
|
||||||
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
|
/* GNU General Public License for more details. */
|
||||||
|
/* */
|
||||||
|
/* You should have received a copy of the GNU General Public License */
|
||||||
|
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
/* */
|
||||||
|
/**********************************************************************************/
|
||||||
|
|
||||||
|
namespace Thelia\Coupon;
|
||||||
|
use Thelia\Condition\ConditionCollection;
|
||||||
|
use Thelia\Condition\ConditionEvaluator;
|
||||||
|
use Thelia\Condition\ConditionFactory;
|
||||||
|
use Thelia\Condition\Implementation\MatchForTotalAmount;
|
||||||
|
use Thelia\Condition\Operators;
|
||||||
|
use Thelia\Coupon\Type\RemoveXAmount;
|
||||||
|
use Thelia\Model\Coupon;
|
||||||
|
use Thelia\Model\CurrencyQuery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by JetBrains PhpStorm.
|
||||||
|
* Date: 8/19/13
|
||||||
|
* Time: 3:24 PM
|
||||||
|
*
|
||||||
|
* Unit Test CouponManager Class
|
||||||
|
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-11-17 at 18:59:24.
|
||||||
|
*
|
||||||
|
* @package Coupon
|
||||||
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class CouponManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up the fixture, for example, opens a network connection.
|
||||||
|
* This method is called before a test is executed.
|
||||||
|
*/
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tears down the fixture, for example, closes a network connection.
|
||||||
|
* This method is called after a test is executed.
|
||||||
|
*/
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a valid Coupon model
|
||||||
|
*/
|
||||||
|
public function generateCouponModel($facade, ConditionFactory $conditionFactory)
|
||||||
|
{
|
||||||
|
// Coupons
|
||||||
|
$coupon1 = new Coupon();
|
||||||
|
$coupon1->setCode('XMAS');
|
||||||
|
$coupon1->setType('thelia.coupon.type.remove_x_amount');
|
||||||
|
$coupon1->setTitle('Christmas coupon');
|
||||||
|
$coupon1->setShortDescription('Coupon for Christmas removing 10€ if your total checkout is more than 40€');
|
||||||
|
$coupon1->setDescription('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras at luctus tellus. Integer turpis mauris, aliquet vitae risus tristique, pellentesque vestibulum urna. Vestibulum sodales laoreet lectus dictum suscipit. Praesent vulputate, sem id varius condimentum, quam magna tempor elit, quis venenatis ligula nulla eget libero. Cras egestas euismod tellus, id pharetra leo suscipit quis. Donec lacinia ac lacus et ultricies. Nunc in porttitor neque. Proin at quam congue, consectetur orci sed, congue nulla. Nulla eleifend nunc ligula, nec pharetra elit tempus quis. Vivamus vel mauris sed est dictum blandit. Maecenas blandit dapibus velit ut sollicitudin. In in euismod mauris, consequat viverra magna. Cras velit velit, sollicitudin commodo tortor gravida, tempus varius nulla.
|
||||||
|
|
||||||
|
Donec rhoncus leo mauris, id porttitor ante luctus tempus. Curabitur quis augue feugiat, ullamcorper mauris ac, interdum mi. Quisque aliquam lorem vitae felis lobortis, id interdum turpis mattis. Vestibulum diam massa, ornare congue blandit quis, facilisis at nisl. In tortor metus, venenatis non arcu nec, sollicitudin ornare nisl. Nunc erat risus, varius nec urna at, iaculis lacinia elit. Aenean ut felis tempus, tincidunt odio non, sagittis nisl. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec vitae hendrerit elit. Nunc sit amet gravida risus, euismod lobortis massa. Nam a erat mauris. Nam a malesuada lorem. Nulla id accumsan dolor, sed rhoncus tellus. Quisque dictum felis sed leo auctor, at volutpat lectus viverra. Morbi rutrum, est ac aliquam imperdiet, nibh sem sagittis justo, ac mattis magna lacus eu nulla.
|
||||||
|
|
||||||
|
Duis interdum lectus nulla, nec pellentesque sapien condimentum at. Suspendisse potenti. Sed eu purus tellus. Nunc quis rhoncus metus. Fusce vitae tellus enim. Interdum et malesuada fames ac ante ipsum primis in faucibus. Etiam tempor porttitor erat vitae iaculis. Sed est elit, consequat non ornare vitae, vehicula eget lectus. Etiam consequat sapien mauris, eget consectetur magna imperdiet eget. Nunc sollicitudin luctus velit, in commodo nulla adipiscing fermentum. Fusce nisi sapien, posuere vitae metus sit amet, facilisis sollicitudin dui. Fusce ultricies auctor enim sit amet iaculis. Morbi at vestibulum enim, eget adipiscing eros.
|
||||||
|
|
||||||
|
Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentesque elit erat, lacinia sed semper ac, sagittis vel elit. Nam eu convallis est. Curabitur rhoncus odio vitae consectetur pellentesque. Nam vitae arcu nec ante scelerisque dignissim vel nec neque. Suspendisse augue nulla, mollis eget dui et, tempor facilisis erat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac diam ipsum. Donec convallis dui ultricies velit auctor, non lobortis nulla ultrices. Morbi vitae dignissim ante, sit amet lobortis tortor. Nunc dapibus condimentum augue, in molestie neque congue non.
|
||||||
|
|
||||||
|
Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.');
|
||||||
|
$coupon1->setAmount(10.00);
|
||||||
|
$coupon1->setIsUsed(true);
|
||||||
|
$coupon1->setIsEnabled(true);
|
||||||
|
$date = new \DateTime();
|
||||||
|
$coupon1->setExpirationDate($date->setTimestamp(strtotime("today + 3 months")));
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($facade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 40.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
|
);
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$condition2 = new MatchForTotalAmount($facade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::INFERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
|
);
|
||||||
|
$condition2->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$conditions = new ConditionCollection();
|
||||||
|
$conditions->add($condition1);
|
||||||
|
$conditions->add($condition2);
|
||||||
|
|
||||||
|
$serializedConditions = $conditionFactory->serializeConditionCollection($conditions);
|
||||||
|
$coupon1->setSerializedConditions($serializedConditions);
|
||||||
|
|
||||||
|
|
||||||
|
$coupon1->setMaxUsage(40);
|
||||||
|
$coupon1->setIsCumulative(true);
|
||||||
|
$coupon1->setIsRemovingPostage(true);
|
||||||
|
$coupon1->setIsAvailableOnSpecialOffers(true);
|
||||||
|
|
||||||
|
return $coupon1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\CouponManager::getDiscount
|
||||||
|
* @covers Thelia\Coupon\CouponManager::isCouponRemovingPostage
|
||||||
|
* @covers Thelia\Coupon\CouponManager::sortCoupons
|
||||||
|
* @covers Thelia\Coupon\CouponManager::getEffect
|
||||||
|
*/
|
||||||
|
public function testGetDiscountCumulativeRemovingPostage()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub();
|
||||||
|
$stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container');
|
||||||
|
|
||||||
|
$conditionFactory = new ConditionFactory($stubContainer);
|
||||||
|
|
||||||
|
$conditions = new ConditionCollection();
|
||||||
|
$stubConditionFactory = $this->getMockBuilder('\Thelia\Condition\ConditionFactory')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubConditionFactory->expects($this->any())
|
||||||
|
->method('unserializeConditionCollection')
|
||||||
|
->will($this->returnValue($conditions));
|
||||||
|
|
||||||
|
$couponManager = new RemoveXAmount($stubFacade);
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('get')
|
||||||
|
->will($this->onConsecutiveCalls($stubFacade, $couponManager, $stubConditionFactory, clone $couponManager, $stubConditionFactory, $stubFacade));
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('has')
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$couponFactory = new CouponFactory($stubContainer);
|
||||||
|
$model1 = $this->generateCouponModel($stubFacade, $conditionFactory);
|
||||||
|
$model1->setAmount(21.00);
|
||||||
|
$coupon1 = $couponFactory->buildCouponFromModel($model1);
|
||||||
|
|
||||||
|
$model2 = $this->generateCouponModel($stubFacade, $conditionFactory);
|
||||||
|
$model2->setCode('XMAS2')->setIsRemovingPostage(true)->setAmount(21.50);
|
||||||
|
$coupon2 = $couponFactory->buildCouponFromModel($model2);
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCurrentCoupons')
|
||||||
|
->will($this->returnValue(array($coupon1, $coupon2)));
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCheckoutPostagePrice')
|
||||||
|
->will($this->returnValue(8.30));
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCartTotalPrice')
|
||||||
|
->will($this->returnValue(122.53));
|
||||||
|
|
||||||
|
$couponManager = new CouponManager($stubContainer);
|
||||||
|
$couponManager->addAvailableCoupon($coupon1);
|
||||||
|
$couponManager->addAvailableCoupon($coupon2);
|
||||||
|
$actual = $couponManager->getDiscount();
|
||||||
|
$expected = 50.80;
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\CouponManager::getDiscount
|
||||||
|
* @covers Thelia\Coupon\CouponManager::isCouponRemovingPostage
|
||||||
|
* @covers Thelia\Coupon\CouponManager::sortCoupons
|
||||||
|
* @covers Thelia\Coupon\CouponManager::getEffect
|
||||||
|
*/
|
||||||
|
public function testGetDiscountNonCumulativeNotRemovingPostage()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub();
|
||||||
|
$stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container');
|
||||||
|
|
||||||
|
$conditionFactory = new ConditionFactory($stubContainer);
|
||||||
|
|
||||||
|
$conditions = new ConditionCollection();
|
||||||
|
$stubConditionFactory = $this->getMockBuilder('\Thelia\Condition\ConditionFactory')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubConditionFactory->expects($this->any())
|
||||||
|
->method('unserializeConditionCollection')
|
||||||
|
->will($this->returnValue($conditions));
|
||||||
|
|
||||||
|
$couponManager = new RemoveXAmount($stubFacade);
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('get')
|
||||||
|
->will($this->onConsecutiveCalls($stubFacade, $couponManager, $stubConditionFactory, clone $couponManager, $stubConditionFactory, $stubFacade));
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('has')
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$couponFactory = new CouponFactory($stubContainer);
|
||||||
|
$model1 = $this->generateCouponModel($stubFacade, $conditionFactory);
|
||||||
|
$model1->setAmount(21.00);
|
||||||
|
$coupon1 = $couponFactory->buildCouponFromModel($model1);
|
||||||
|
|
||||||
|
$model2 = $this->generateCouponModel($stubFacade, $conditionFactory);
|
||||||
|
$model2->setCode('XMAS2')->setIsRemovingPostage(false)->setAmount(21.50)->setIsCumulative(false);
|
||||||
|
$coupon2 = $couponFactory->buildCouponFromModel($model2);
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCurrentCoupons')
|
||||||
|
->will($this->returnValue(array($coupon1, $coupon2)));
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCheckoutPostagePrice')
|
||||||
|
->will($this->returnValue(8.30));
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCartTotalPrice')
|
||||||
|
->will($this->returnValue(122.53));
|
||||||
|
|
||||||
|
$couponManager = new CouponManager($stubContainer);
|
||||||
|
$couponManager->addAvailableCoupon($coupon1);
|
||||||
|
$couponManager->addAvailableCoupon($coupon2);
|
||||||
|
$actual = $couponManager->getDiscount();
|
||||||
|
$expected = 21.50;
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\CouponManager::getDiscount
|
||||||
|
* @covers Thelia\Coupon\CouponManager::isCouponRemovingPostage
|
||||||
|
* @covers Thelia\Coupon\CouponManager::sortCoupons
|
||||||
|
* @covers Thelia\Coupon\CouponManager::getEffect
|
||||||
|
*/
|
||||||
|
public function testGetDiscountGreaterThanCartAmount()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub(12.25);
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCheckoutPostagePrice')
|
||||||
|
->will($this->returnValue(8.30));
|
||||||
|
|
||||||
|
$stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container');
|
||||||
|
|
||||||
|
$conditionFactory = new ConditionFactory($stubContainer);
|
||||||
|
|
||||||
|
$conditions = new ConditionCollection();
|
||||||
|
$stubConditionFactory = $this->getMockBuilder('\Thelia\Condition\ConditionFactory')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubConditionFactory->expects($this->any())
|
||||||
|
->method('unserializeConditionCollection')
|
||||||
|
->will($this->returnValue($conditions));
|
||||||
|
|
||||||
|
$couponManager = new RemoveXAmount($stubFacade);
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('get')
|
||||||
|
->will($this->onConsecutiveCalls($stubFacade, $couponManager, $stubConditionFactory, clone $couponManager, $stubConditionFactory, $stubFacade));
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('has')
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$couponFactory = new CouponFactory($stubContainer);
|
||||||
|
$model1 = $this->generateCouponModel($stubFacade, $conditionFactory);
|
||||||
|
$model1->setAmount(21.00);
|
||||||
|
$coupon1 = $couponFactory->buildCouponFromModel($model1);
|
||||||
|
|
||||||
|
$model2 = $this->generateCouponModel($stubFacade, $conditionFactory);
|
||||||
|
$model2->setCode('XMAS2')->setIsRemovingPostage(false)->setAmount(21.50)->setIsCumulative(false);
|
||||||
|
$coupon2 = $couponFactory->buildCouponFromModel($model2);
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCurrentCoupons')
|
||||||
|
->will($this->returnValue(array($coupon1, $coupon2)));
|
||||||
|
|
||||||
|
$couponManager = new CouponManager($stubContainer);
|
||||||
|
$couponManager->addAvailableCoupon($coupon1);
|
||||||
|
$couponManager->addAvailableCoupon($coupon2);
|
||||||
|
$actual = $couponManager->getDiscount();
|
||||||
|
$expected = 12.25;
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\CouponManager::addAvailableCoupon
|
||||||
|
* @covers Thelia\Coupon\CouponManager::getAvailableCoupons
|
||||||
|
*/
|
||||||
|
public function testGetAvailableCoupons()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub();
|
||||||
|
$stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container');
|
||||||
|
|
||||||
|
$conditionFactory = new ConditionFactory($stubContainer);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCurrentCoupons')
|
||||||
|
->will($this->returnValue(array()));
|
||||||
|
|
||||||
|
$conditions = new ConditionCollection();
|
||||||
|
$stubConditionFactory = $this->getMockBuilder('\Thelia\Condition\ConditionFactory')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubConditionFactory->expects($this->any())
|
||||||
|
->method('unserializeConditionCollection')
|
||||||
|
->will($this->returnValue($conditions));
|
||||||
|
|
||||||
|
$couponManager = new RemoveXAmount($stubFacade);
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('get')
|
||||||
|
->will($this->onConsecutiveCalls($stubFacade, $couponManager, $stubConditionFactory, $stubFacade));
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('has')
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$couponFactory = new CouponFactory($stubContainer);
|
||||||
|
$model1 = $this->generateCouponModel($stubFacade, $conditionFactory);
|
||||||
|
$coupon1 = $couponFactory->buildCouponFromModel($model1);
|
||||||
|
$coupon2 = clone $coupon1;
|
||||||
|
|
||||||
|
|
||||||
|
$couponManager = new CouponManager($stubContainer);
|
||||||
|
$couponManager->addAvailableCoupon($coupon1);
|
||||||
|
$couponManager->addAvailableCoupon($coupon2);
|
||||||
|
$actual = $couponManager->getAvailableCoupons();
|
||||||
|
$expected = array($coupon1, $coupon2);
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\CouponManager::addAvailableCondition
|
||||||
|
* @covers Thelia\Coupon\CouponManager::getAvailableConditions
|
||||||
|
*/
|
||||||
|
public function testGetAvailableConditions()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub();
|
||||||
|
$stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container');
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 40.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
|
);
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$condition2 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::INFERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
|
);
|
||||||
|
$condition2->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$conditions = new ConditionCollection();
|
||||||
|
$conditions->add($condition1);
|
||||||
|
$conditions->add($condition2);
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCurrentCoupons')
|
||||||
|
->will($this->returnValue(array()));
|
||||||
|
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('get')
|
||||||
|
->will($this->onConsecutiveCalls($stubFacade));
|
||||||
|
|
||||||
|
|
||||||
|
$couponManager = new CouponManager($stubContainer);
|
||||||
|
$couponManager->addAvailableCondition($condition1);
|
||||||
|
$couponManager->addAvailableCondition($condition2);
|
||||||
|
$actual = $couponManager->getAvailableConditions();
|
||||||
|
$expected = array($condition1, $condition2);
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\CouponManager::decrementQuantity
|
||||||
|
*/
|
||||||
|
public function testDecrementeQuantity()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub();
|
||||||
|
$stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container');
|
||||||
|
|
||||||
|
$coupon = new RemoveXAmount($stubFacade);
|
||||||
|
$date = new \DateTime();
|
||||||
|
$coupon->set($stubFacade, 'XMAS', '', '', '', 21.00, true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) );
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 40.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
|
);
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$condition2 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::INFERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
|
);
|
||||||
|
$condition2->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$conditions = new ConditionCollection();
|
||||||
|
$conditions->add($condition1);
|
||||||
|
$conditions->add($condition2);
|
||||||
|
$coupon->setConditions($conditions);
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCurrentCoupons')
|
||||||
|
->will($this->returnValue(array($coupon)));
|
||||||
|
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('get')
|
||||||
|
->will($this->onConsecutiveCalls($stubFacade));
|
||||||
|
|
||||||
|
|
||||||
|
$couponManager = new CouponManager($stubContainer);
|
||||||
|
|
||||||
|
|
||||||
|
$stubModel = $this->getMockBuilder('\Thelia\Model\Coupon')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubModel->expects($this->any())
|
||||||
|
->method('getMaxUsage')
|
||||||
|
->will($this->returnValue(21));
|
||||||
|
$stubModel->expects($this->any())
|
||||||
|
->method('setMaxUsage')
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$actual = $couponManager->decrementQuantity($stubModel);
|
||||||
|
$expected = 20;
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\CouponManager::decrementQuantity
|
||||||
|
*/
|
||||||
|
public function testDecrementeQuantityIllimited()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub();
|
||||||
|
$stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container');
|
||||||
|
|
||||||
|
$coupon = new RemoveXAmount($stubFacade);
|
||||||
|
$date = new \DateTime();
|
||||||
|
$coupon->set($stubFacade, 'XMAS', '', '', '', 21.00, true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) );
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 40.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
|
);
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$condition2 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::INFERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
|
);
|
||||||
|
$condition2->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$conditions = new ConditionCollection();
|
||||||
|
$conditions->add($condition1);
|
||||||
|
$conditions->add($condition2);
|
||||||
|
$coupon->setConditions($conditions);
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCurrentCoupons')
|
||||||
|
->will($this->returnValue(array($coupon)));
|
||||||
|
|
||||||
|
$stubContainer->expects($this->any())
|
||||||
|
->method('get')
|
||||||
|
->will($this->onConsecutiveCalls($stubFacade));
|
||||||
|
|
||||||
|
|
||||||
|
$couponManager = new CouponManager($stubContainer);
|
||||||
|
|
||||||
|
|
||||||
|
$stubModel = $this->getMockBuilder('\Thelia\Model\Coupon')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubModel->expects($this->any())
|
||||||
|
->method('getMaxUsage')
|
||||||
|
->will($this->returnValue(-1));
|
||||||
|
$stubModel->expects($this->any())
|
||||||
|
->method('setMaxUsage')
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$actual = $couponManager->decrementQuantity($stubModel);
|
||||||
|
$expected = -1;
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate adapter stub
|
||||||
|
*
|
||||||
|
* @param int $cartTotalPrice Cart total price
|
||||||
|
* @param string $checkoutCurrency Checkout currency
|
||||||
|
* @param string $i18nOutput Output from each translation
|
||||||
|
*
|
||||||
|
* @return \PHPUnit_Framework_MockObject_MockObject
|
||||||
|
*/
|
||||||
|
public function generateFacadeStub($cartTotalPrice = 400, $checkoutCurrency = 'EUR', $i18nOutput = '')
|
||||||
|
{
|
||||||
|
$stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$currencies = CurrencyQuery::create();
|
||||||
|
$currencies = $currencies->find();
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getAvailableCurrencies')
|
||||||
|
->will($this->returnValue($currencies));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCartTotalPrice')
|
||||||
|
->will($this->returnValue($cartTotalPrice));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCheckoutCurrency')
|
||||||
|
->will($this->returnValue($checkoutCurrency));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getConditionEvaluator')
|
||||||
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
|
$stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubTranslator->expects($this->any())
|
||||||
|
->method('trans')
|
||||||
|
->will($this->returnValue($i18nOutput));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getTranslator')
|
||||||
|
->will($this->returnValue($stubTranslator));
|
||||||
|
|
||||||
|
return $stubFacade;
|
||||||
|
}
|
||||||
|
}
|
||||||
214
core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php
Normal file
@@ -0,0 +1,214 @@
|
|||||||
|
<?php
|
||||||
|
/**********************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Thelia */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : info@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it and/or modify */
|
||||||
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
|
/* the Free Software Foundation; either version 3 of the License */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will be useful, */
|
||||||
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
|
/* GNU General Public License for more details. */
|
||||||
|
/* */
|
||||||
|
/* You should have received a copy of the GNU General Public License */
|
||||||
|
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
/* */
|
||||||
|
/**********************************************************************************/
|
||||||
|
|
||||||
|
namespace Thelia\Coupon\Type;
|
||||||
|
use Thelia\Condition\ConditionCollection;
|
||||||
|
use Thelia\Condition\ConditionEvaluator;
|
||||||
|
use Thelia\Condition\Implementation\MatchForTotalAmount;
|
||||||
|
use Thelia\Condition\Operators;
|
||||||
|
use Thelia\Coupon\FacadeInterface;
|
||||||
|
use Thelia\Model\CurrencyQuery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by JetBrains PhpStorm.
|
||||||
|
* Date: 8/19/13
|
||||||
|
* Time: 3:24 PM
|
||||||
|
*
|
||||||
|
* Unit Test RemoveXAmount Class
|
||||||
|
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-11-17 at 18:59:24.
|
||||||
|
*
|
||||||
|
* @package Coupon
|
||||||
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class RemoveXAmountTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up the fixture, for example, opens a network connection.
|
||||||
|
* This method is called before a test is executed.
|
||||||
|
*/
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate adapter stub
|
||||||
|
*
|
||||||
|
* @param int $cartTotalPrice Cart total price
|
||||||
|
* @param string $checkoutCurrency Checkout currency
|
||||||
|
* @param string $i18nOutput Output from each translation
|
||||||
|
*
|
||||||
|
* @return \PHPUnit_Framework_MockObject_MockObject
|
||||||
|
*/
|
||||||
|
public function generateFacadeStub($cartTotalPrice = 400, $checkoutCurrency = 'EUR', $i18nOutput = '')
|
||||||
|
{
|
||||||
|
$stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$currencies = CurrencyQuery::create();
|
||||||
|
$currencies = $currencies->find();
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getAvailableCurrencies')
|
||||||
|
->will($this->returnValue($currencies));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCartTotalPrice')
|
||||||
|
->will($this->returnValue($cartTotalPrice));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCheckoutCurrency')
|
||||||
|
->will($this->returnValue($checkoutCurrency));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getConditionEvaluator')
|
||||||
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
|
$stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubTranslator->expects($this->any())
|
||||||
|
->method('trans')
|
||||||
|
->will($this->returnValue($i18nOutput));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getTranslator')
|
||||||
|
->will($this->returnValue($stubTranslator));
|
||||||
|
|
||||||
|
return $stubFacade;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\Type\RemoveXAmount::set
|
||||||
|
* @covers Thelia\Coupon\Type\CouponAbstract::getCode
|
||||||
|
* @covers Thelia\Coupon\Type\RemoveXAmount::getTitle
|
||||||
|
* @covers Thelia\Coupon\Type\RemoveXAmount::getShortDescription
|
||||||
|
* @covers Thelia\Coupon\Type\RemoveXAmount::getDescription
|
||||||
|
* @covers Thelia\Coupon\Type\RemoveXAmount::isCumulative
|
||||||
|
* @covers Thelia\Coupon\Type\RemoveXAmount::isRemovingPostage
|
||||||
|
* @covers Thelia\Coupon\Type\RemoveXAmount::isAvailableOnSpecialOffers
|
||||||
|
* @covers Thelia\Coupon\Type\RemoveXAmount::isEnabled
|
||||||
|
* @covers Thelia\Coupon\Type\RemoveXAmount::getMaxUsage
|
||||||
|
* @covers Thelia\Coupon\Type\RemoveXAmount::getExpirationDate
|
||||||
|
* @covers Thelia\Coupon\Type\RemoveXAmount::setConditions
|
||||||
|
*/
|
||||||
|
public function testSet()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub();
|
||||||
|
|
||||||
|
$coupon = new RemoveXAmount($stubFacade);
|
||||||
|
$date = new \DateTime();
|
||||||
|
$description = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras at luctus tellus. Integer turpis mauris, aliquet vitae risus tristique, pellentesque vestibulum urna. Vestibulum sodales laoreet lectus dictum suscipit. Praesent vulputate, sem id varius condimentum, quam magna tempor elit, quis venenatis ligula nulla eget libero. Cras egestas euismod tellus, id pharetra leo suscipit quis. Donec lacinia ac lacus et ultricies. Nunc in porttitor neque. Proin at quam congue, consectetur orci sed, congue nulla. Nulla eleifend nunc ligula, nec pharetra elit tempus quis. Vivamus vel mauris sed est dictum blandit. Maecenas blandit dapibus velit ut sollicitudin. In in euismod mauris, consequat viverra magna. Cras velit velit, sollicitudin commodo tortor gravida, tempus varius nulla.
|
||||||
|
|
||||||
|
Donec rhoncus leo mauris, id porttitor ante luctus tempus. Curabitur quis augue feugiat, ullamcorper mauris ac, interdum mi. Quisque aliquam lorem vitae felis lobortis, id interdum turpis mattis. Vestibulum diam massa, ornare congue blandit quis, facilisis at nisl. In tortor metus, venenatis non arcu nec, sollicitudin ornare nisl. Nunc erat risus, varius nec urna at, iaculis lacinia elit. Aenean ut felis tempus, tincidunt odio non, sagittis nisl. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec vitae hendrerit elit. Nunc sit amet gravida risus, euismod lobortis massa. Nam a erat mauris. Nam a malesuada lorem. Nulla id accumsan dolor, sed rhoncus tellus. Quisque dictum felis sed leo auctor, at volutpat lectus viverra. Morbi rutrum, est ac aliquam imperdiet, nibh sem sagittis justo, ac mattis magna lacus eu nulla.
|
||||||
|
|
||||||
|
Duis interdum lectus nulla, nec pellentesque sapien condimentum at. Suspendisse potenti. Sed eu purus tellus. Nunc quis rhoncus metus. Fusce vitae tellus enim. Interdum et malesuada fames ac ante ipsum primis in faucibus. Etiam tempor porttitor erat vitae iaculis. Sed est elit, consequat non ornare vitae, vehicula eget lectus. Etiam consequat sapien mauris, eget consectetur magna imperdiet eget. Nunc sollicitudin luctus velit, in commodo nulla adipiscing fermentum. Fusce nisi sapien, posuere vitae metus sit amet, facilisis sollicitudin dui. Fusce ultricies auctor enim sit amet iaculis. Morbi at vestibulum enim, eget adipiscing eros.
|
||||||
|
|
||||||
|
Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentesque elit erat, lacinia sed semper ac, sagittis vel elit. Nam eu convallis est. Curabitur rhoncus odio vitae consectetur pellentesque. Nam vitae arcu nec ante scelerisque dignissim vel nec neque. Suspendisse augue nulla, mollis eget dui et, tempor facilisis erat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac diam ipsum. Donec convallis dui ultricies velit auctor, non lobortis nulla ultrices. Morbi vitae dignissim ante, sit amet lobortis tortor. Nunc dapibus condimentum augue, in molestie neque congue non.
|
||||||
|
|
||||||
|
Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.';
|
||||||
|
|
||||||
|
$coupon->set($stubFacade, 'XMAS', 'XMAS Coupon', 'Coupon for Springbreak removing 10€ if you have a cart between 40.00€ and 400.00€ (excluded)', $description, 10.00, true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) );
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 40.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
|
);
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$condition2 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::INFERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
|
);
|
||||||
|
$condition2->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$conditions = new ConditionCollection();
|
||||||
|
$conditions->add($condition1);
|
||||||
|
$conditions->add($condition2);
|
||||||
|
$coupon->setConditions($conditions);
|
||||||
|
|
||||||
|
$this->assertEquals('XMAS', $coupon->getCode());
|
||||||
|
$this->assertEquals('XMAS Coupon', $coupon->getTitle());
|
||||||
|
$this->assertEquals('Coupon for Springbreak removing 10€ if you have a cart between 40.00€ and 400.00€ (excluded)', $coupon->getShortDescription());
|
||||||
|
$this->assertEquals($description, $coupon->getDescription());
|
||||||
|
$this->assertEquals(true, $coupon->isCumulative());
|
||||||
|
$this->assertEquals(true, $coupon->isRemovingPostage());
|
||||||
|
$this->assertEquals(true, $coupon->isAvailableOnSpecialOffers());
|
||||||
|
$this->assertEquals(true, $coupon->isEnabled());
|
||||||
|
|
||||||
|
$this->assertEquals(254, $coupon->getMaxUsage());
|
||||||
|
$this->assertEquals($date, $coupon->getExpirationDate());
|
||||||
|
|
||||||
|
$this->assertEquals(10.00, $coupon->exec());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\Type\RemoveXAmount::getName
|
||||||
|
*/
|
||||||
|
public function testGetName()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub(399, 'EUR', 'Remove X amount to total cart');
|
||||||
|
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$coupon = new RemoveXAmount($stubFacade);
|
||||||
|
|
||||||
|
$actual = $coupon->getName();
|
||||||
|
$expected = 'Remove X amount to total cart';
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\Type\RemoveXAmount::getToolTip
|
||||||
|
*/
|
||||||
|
public function testGetToolTip()
|
||||||
|
{
|
||||||
|
$tooltip = 'This coupon will remove the entered amount to the customer total checkout. If the discount is superior to the total checkout price the customer will only pay the postage. Unless if the coupon is set to remove postage too.';
|
||||||
|
$stubFacade = $this->generateFacadeStub(399, 'EUR', $tooltip);
|
||||||
|
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$coupon = new RemoveXAmount($stubFacade);
|
||||||
|
|
||||||
|
$actual = $coupon->getToolTip();
|
||||||
|
$expected = $tooltip;
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tears down the fixture, for example, closes a network connection.
|
||||||
|
* This method is called after a test is executed.
|
||||||
|
*/
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
204
core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php
Normal file
@@ -0,0 +1,204 @@
|
|||||||
|
<?php
|
||||||
|
/**********************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Thelia */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : info@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it and/or modify */
|
||||||
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
|
/* the Free Software Foundation; either version 3 of the License */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will be useful, */
|
||||||
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
|
/* GNU General Public License for more details. */
|
||||||
|
/* */
|
||||||
|
/* You should have received a copy of the GNU General Public License */
|
||||||
|
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
/* */
|
||||||
|
/**********************************************************************************/
|
||||||
|
|
||||||
|
namespace Thelia\Coupon\Type;
|
||||||
|
use Thelia\Condition\ConditionCollection;
|
||||||
|
use Thelia\Condition\ConditionEvaluator;
|
||||||
|
use Thelia\Condition\Implementation\MatchForTotalAmount;
|
||||||
|
use Thelia\Condition\Operators;
|
||||||
|
use Thelia\Coupon\FacadeInterface;
|
||||||
|
use Thelia\Model\CurrencyQuery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by JetBrains PhpStorm.
|
||||||
|
* Date: 8/19/13
|
||||||
|
* Time: 3:24 PM
|
||||||
|
*
|
||||||
|
* Unit Test RemoveXPercent Class
|
||||||
|
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-11-17 at 18:59:24.
|
||||||
|
*
|
||||||
|
* @package Coupon
|
||||||
|
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class RemoveXPercentTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up the fixture, for example, opens a network connection.
|
||||||
|
* This method is called before a test is executed.
|
||||||
|
*/
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate adapter stub
|
||||||
|
*
|
||||||
|
* @param int $cartTotalPrice Cart total price
|
||||||
|
* @param string $checkoutCurrency Checkout currency
|
||||||
|
* @param string $i18nOutput Output from each translation
|
||||||
|
*
|
||||||
|
* @return \PHPUnit_Framework_MockObject_MockObject
|
||||||
|
*/
|
||||||
|
public function generateFacadeStub($cartTotalPrice = 400, $checkoutCurrency = 'EUR', $i18nOutput = '')
|
||||||
|
{
|
||||||
|
$stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$currencies = CurrencyQuery::create();
|
||||||
|
$currencies = $currencies->find();
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getAvailableCurrencies')
|
||||||
|
->will($this->returnValue($currencies));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCartTotalPrice')
|
||||||
|
->will($this->returnValue($cartTotalPrice));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getCheckoutCurrency')
|
||||||
|
->will($this->returnValue($checkoutCurrency));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getConditionEvaluator')
|
||||||
|
->will($this->returnValue(new ConditionEvaluator()));
|
||||||
|
|
||||||
|
$stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$stubTranslator->expects($this->any())
|
||||||
|
->method('trans')
|
||||||
|
->will($this->returnValue($i18nOutput));
|
||||||
|
|
||||||
|
$stubFacade->expects($this->any())
|
||||||
|
->method('getTranslator')
|
||||||
|
->will($this->returnValue($stubTranslator));
|
||||||
|
|
||||||
|
return $stubFacade;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\Type\RemoveXPercent::set
|
||||||
|
* @covers Thelia\Coupon\Type\RemoveXPercent::exec
|
||||||
|
*/
|
||||||
|
public function testSet()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub();
|
||||||
|
|
||||||
|
$coupon = new RemoveXPercent($stubFacade);
|
||||||
|
$date = new \DateTime();
|
||||||
|
$description = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras at luctus tellus. Integer turpis mauris, aliquet vitae risus tristique, pellentesque vestibulum urna. Vestibulum sodales laoreet lectus dictum suscipit. Praesent vulputate, sem id varius condimentum, quam magna tempor elit, quis venenatis ligula nulla eget libero. Cras egestas euismod tellus, id pharetra leo suscipit quis. Donec lacinia ac lacus et ultricies. Nunc in porttitor neque. Proin at quam congue, consectetur orci sed, congue nulla. Nulla eleifend nunc ligula, nec pharetra elit tempus quis. Vivamus vel mauris sed est dictum blandit. Maecenas blandit dapibus velit ut sollicitudin. In in euismod mauris, consequat viverra magna. Cras velit velit, sollicitudin commodo tortor gravida, tempus varius nulla.
|
||||||
|
|
||||||
|
Donec rhoncus leo mauris, id porttitor ante luctus tempus. Curabitur quis augue feugiat, ullamcorper mauris ac, interdum mi. Quisque aliquam lorem vitae felis lobortis, id interdum turpis mattis. Vestibulum diam massa, ornare congue blandit quis, facilisis at nisl. In tortor metus, venenatis non arcu nec, sollicitudin ornare nisl. Nunc erat risus, varius nec urna at, iaculis lacinia elit. Aenean ut felis tempus, tincidunt odio non, sagittis nisl. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec vitae hendrerit elit. Nunc sit amet gravida risus, euismod lobortis massa. Nam a erat mauris. Nam a malesuada lorem. Nulla id accumsan dolor, sed rhoncus tellus. Quisque dictum felis sed leo auctor, at volutpat lectus viverra. Morbi rutrum, est ac aliquam imperdiet, nibh sem sagittis justo, ac mattis magna lacus eu nulla.
|
||||||
|
|
||||||
|
Duis interdum lectus nulla, nec pellentesque sapien condimentum at. Suspendisse potenti. Sed eu purus tellus. Nunc quis rhoncus metus. Fusce vitae tellus enim. Interdum et malesuada fames ac ante ipsum primis in faucibus. Etiam tempor porttitor erat vitae iaculis. Sed est elit, consequat non ornare vitae, vehicula eget lectus. Etiam consequat sapien mauris, eget consectetur magna imperdiet eget. Nunc sollicitudin luctus velit, in commodo nulla adipiscing fermentum. Fusce nisi sapien, posuere vitae metus sit amet, facilisis sollicitudin dui. Fusce ultricies auctor enim sit amet iaculis. Morbi at vestibulum enim, eget adipiscing eros.
|
||||||
|
|
||||||
|
Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentesque elit erat, lacinia sed semper ac, sagittis vel elit. Nam eu convallis est. Curabitur rhoncus odio vitae consectetur pellentesque. Nam vitae arcu nec ante scelerisque dignissim vel nec neque. Suspendisse augue nulla, mollis eget dui et, tempor facilisis erat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac diam ipsum. Donec convallis dui ultricies velit auctor, non lobortis nulla ultrices. Morbi vitae dignissim ante, sit amet lobortis tortor. Nunc dapibus condimentum augue, in molestie neque congue non.
|
||||||
|
|
||||||
|
Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.';
|
||||||
|
|
||||||
|
$coupon->set($stubFacade, 'XMAS', 'XMAS Coupon', 'Coupon for Springbreak removing 10% if you have a cart between 40.00€ and 400.00€ (excluded)', $description, 10.00, true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) );
|
||||||
|
|
||||||
|
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 40.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
|
);
|
||||||
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$condition2 = new MatchForTotalAmount($stubFacade);
|
||||||
|
$operators = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => Operators::INFERIOR,
|
||||||
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
|
);
|
||||||
|
$values = array(
|
||||||
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
|
);
|
||||||
|
$condition2->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
|
$conditions = new ConditionCollection();
|
||||||
|
$conditions->add($condition1);
|
||||||
|
$conditions->add($condition2);
|
||||||
|
$coupon->setConditions($conditions);
|
||||||
|
|
||||||
|
$this->assertEquals('XMAS', $coupon->getCode());
|
||||||
|
$this->assertEquals('XMAS Coupon', $coupon->getTitle());
|
||||||
|
$this->assertEquals('Coupon for Springbreak removing 10% if you have a cart between 40.00€ and 400.00€ (excluded)', $coupon->getShortDescription());
|
||||||
|
$this->assertEquals($description, $coupon->getDescription());
|
||||||
|
$this->assertEquals(true, $coupon->isCumulative());
|
||||||
|
$this->assertEquals(true, $coupon->isRemovingPostage());
|
||||||
|
$this->assertEquals(true, $coupon->isAvailableOnSpecialOffers());
|
||||||
|
$this->assertEquals(true, $coupon->isEnabled());
|
||||||
|
|
||||||
|
$this->assertEquals(254, $coupon->getMaxUsage());
|
||||||
|
$this->assertEquals($date, $coupon->getExpirationDate());
|
||||||
|
|
||||||
|
$this->assertEquals(40.00, $coupon->exec());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\Type\RemoveXPercent::getName
|
||||||
|
*/
|
||||||
|
public function testGetName()
|
||||||
|
{
|
||||||
|
$stubFacade = $this->generateFacadeStub(399, 'EUR', 'Remove X percent to total cart');
|
||||||
|
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$coupon = new RemoveXPercent($stubFacade);
|
||||||
|
|
||||||
|
$actual = $coupon->getName();
|
||||||
|
$expected = 'Remove X percent to total cart';
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Thelia\Coupon\Type\RemoveXPercent::getToolTip
|
||||||
|
*/
|
||||||
|
public function testGetToolTip()
|
||||||
|
{
|
||||||
|
$tooltip = 'This coupon will remove the entered percentage to the customer total checkout. If the discount is superior to the total checkout price the customer will only pay the postage. Unless if the coupon is set to remove postage too.';
|
||||||
|
$stubFacade = $this->generateFacadeStub(399, 'EUR', $tooltip);
|
||||||
|
|
||||||
|
/** @var FacadeInterface $stubFacade */
|
||||||
|
$coupon = new RemoveXPercent($stubFacade);
|
||||||
|
|
||||||
|
$actual = $coupon->getToolTip();
|
||||||
|
$expected = $tooltip;
|
||||||
|
$this->assertEquals($expected, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tears down the fixture, for example, closes a network connection.
|
||||||
|
* This method is called after a test is executed.
|
||||||
|
*/
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -286,7 +286,7 @@ class URL
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Genenerate the file part of a rewriten URL from a given baseString, using a view, a view id and a locale
|
* Genenerate the file part of a rewritten URL from a given baseString, using a view, a view id and a locale
|
||||||
*
|
*
|
||||||
* @param $view
|
* @param $view
|
||||||
* @param $viewId
|
* @param $viewId
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Thelia\Condition\ConditionFactory;
|
use Thelia\Condition\ConditionFactory;
|
||||||
use Thelia\Condition\Implementation\MatchForEveryoneManager;
|
use Thelia\Condition\Implementation\MatchForEveryone;
|
||||||
use Thelia\Condition\Implementation\MatchForTotalAmountManager;
|
use Thelia\Condition\Implementation\MatchForTotalAmount;
|
||||||
use Thelia\Condition\Implementation\MatchForXArticlesManager;
|
use Thelia\Condition\Implementation\MatchForXArticles;
|
||||||
use Thelia\Condition\Operators;
|
use Thelia\Condition\Operators;
|
||||||
use Thelia\Coupon\FacadeInterface;
|
use Thelia\Coupon\FacadeInterface;
|
||||||
use Thelia\Coupon\ConditionCollection;
|
use Thelia\Condition\ConditionCollection;
|
||||||
|
|
||||||
|
|
||||||
require __DIR__ . '/../core/bootstrap.php';
|
require __DIR__ . '/../core/bootstrap.php';
|
||||||
@@ -646,7 +646,7 @@ function generateCouponFixtures(\Thelia\Core\Thelia $thelia)
|
|||||||
/** @var $container ContainerInterface Service Container */
|
/** @var $container ContainerInterface Service Container */
|
||||||
$container = $thelia->getContainer();
|
$container = $thelia->getContainer();
|
||||||
/** @var FacadeInterface $adapter */
|
/** @var FacadeInterface $adapter */
|
||||||
$adapter = $container->get('thelia.adapter');
|
$adapter = $container->get('thelia.facade');
|
||||||
|
|
||||||
// Coupons
|
// Coupons
|
||||||
$coupon1 = new Thelia\Model\Coupon();
|
$coupon1 = new Thelia\Model\Coupon();
|
||||||
@@ -669,25 +669,25 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
|
|||||||
$date = new \DateTime();
|
$date = new \DateTime();
|
||||||
$coupon1->setExpirationDate($date->setTimestamp(strtotime("today + 3 months")));
|
$coupon1->setExpirationDate($date->setTimestamp(strtotime("today + 3 months")));
|
||||||
|
|
||||||
$condition1 = new MatchForTotalAmountManager($adapter);
|
$condition1 = new MatchForTotalAmount($adapter);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
|
MatchForTotalAmount::INPUT1 => Operators::SUPERIOR,
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForTotalAmountManager::INPUT1 => 40.00,
|
MatchForTotalAmount::INPUT1 => 40.00,
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR'
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
$condition2 = new MatchForTotalAmountManager($adapter);
|
$condition2 = new MatchForTotalAmount($adapter);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR,
|
MatchForTotalAmount::INPUT1 => Operators::INFERIOR,
|
||||||
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
|
MatchForTotalAmount::INPUT2 => Operators::EQUAL
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForTotalAmountManager::INPUT1 => 400.00,
|
MatchForTotalAmount::INPUT1 => 400.00,
|
||||||
MatchForTotalAmountManager::INPUT2 => 'EUR'
|
MatchForTotalAmount::INPUT2 => 'EUR'
|
||||||
);
|
);
|
||||||
$condition2->setValidatorsFromForm($operators, $values);
|
$condition2->setValidatorsFromForm($operators, $values);
|
||||||
|
|
||||||
@@ -727,12 +727,12 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
|
|||||||
$date = new \DateTime();
|
$date = new \DateTime();
|
||||||
$coupon2->setExpirationDate($date->setTimestamp(strtotime("today + 1 months")));
|
$coupon2->setExpirationDate($date->setTimestamp(strtotime("today + 1 months")));
|
||||||
|
|
||||||
$condition1 = new MatchForXArticlesManager($adapter);
|
$condition1 = new MatchForXArticles($adapter);
|
||||||
$operators = array(
|
$operators = array(
|
||||||
MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR,
|
MatchForXArticles::INPUT1 => Operators::SUPERIOR,
|
||||||
);
|
);
|
||||||
$values = array(
|
$values = array(
|
||||||
MatchForXArticlesManager::INPUT1 => 4,
|
MatchForXArticles::INPUT1 => 4,
|
||||||
);
|
);
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
$conditions = new ConditionCollection();
|
$conditions = new ConditionCollection();
|
||||||
@@ -771,7 +771,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
|
|||||||
$date = new \DateTime();
|
$date = new \DateTime();
|
||||||
$coupon3->setExpirationDate($date->setTimestamp(strtotime("today + 2 months")));
|
$coupon3->setExpirationDate($date->setTimestamp(strtotime("today + 2 months")));
|
||||||
|
|
||||||
$condition1 = new MatchForEveryoneManager($adapter);
|
$condition1 = new MatchForEveryone($adapter);
|
||||||
$operators = array();
|
$operators = array();
|
||||||
$values = array();
|
$values = array();
|
||||||
$condition1->setValidatorsFromForm($operators, $values);
|
$condition1->setValidatorsFromForm($operators, $values);
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Thelia\Condition\ConditionFactory;
|
use Thelia\Condition\Implementation\MatchForTotalAmount;
|
||||||
use Thelia\Condition\Implementation\MatchForEveryoneManager;
|
use Thelia\Condition\Implementation\MatchForXArticles;
|
||||||
use Thelia\Condition\Implementation\MatchForTotalAmountManager;
|
|
||||||
use Thelia\Condition\Implementation\MatchForXArticlesManager;
|
|
||||||
use Thelia\Condition\Operators;
|
use Thelia\Condition\Operators;
|
||||||
use Thelia\Coupon\AdapterInterface;
|
|
||||||
use Thelia\Coupon\ConditionCollection;
|
|
||||||
|
|
||||||
|
|
||||||
require __DIR__ . '/../core/bootstrap.php';
|
require __DIR__ . '/../core/bootstrap.php';
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
/* */
|
/* */
|
||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
|
|
||||||
use Thelia\Condition\Implementation\MatchForTotalAmountManager;
|
use Thelia\Condition\Implementation\MatchForTotalAmount;
|
||||||
use Thelia\Condition\Implementation\MatchForXArticlesManager;
|
use Thelia\Condition\Implementation\MatchForXArticles;
|
||||||
|
|
||||||
|
|
||||||
require __DIR__ . '/../core/bootstrap.php';
|
require __DIR__ . '/../core/bootstrap.php';
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
use Thelia\Condition\Implementation\MatchForTotalAmountManager;
|
use Thelia\Condition\Implementation\MatchForTotalAmount;
|
||||||
use Thelia\Condition\Implementation\MatchForXArticlesManager;
|
use Thelia\Condition\Implementation\MatchForXArticles;
|
||||||
use Imagine\Image\Point;
|
use Imagine\Image\Point;
|
||||||
|
|
||||||
require __DIR__ . '/../core/bootstrap.php';
|
require __DIR__ . '/../core/bootstrap.php';
|
||||||
|
|||||||
@@ -183,7 +183,6 @@ return array(
|
|||||||
'Images' => 'Images',
|
'Images' => 'Images',
|
||||||
'Documents' => 'Documents',
|
'Documents' => 'Documents',
|
||||||
'Rewritten URL' => 'Rewritten URL',
|
'Rewritten URL' => 'Rewritten URL',
|
||||||
'Rewriten URL' => 'Rewriten URL',
|
|
||||||
'Top level' => 'Top level',
|
'Top level' => 'Top level',
|
||||||
'Visibility' => 'Visibility',
|
'Visibility' => 'Visibility',
|
||||||
'Category created on %date_create. Last modification: %date_change' => 'Category created on %date_create. Last modification: %date_change',
|
'Category created on %date_create. Last modification: %date_change' => 'Category created on %date_create. Last modification: %date_change',
|
||||||
|
|||||||
@@ -308,9 +308,7 @@ return array (
|
|||||||
'Conclusion' => '',
|
'Conclusion' => '',
|
||||||
'A short post-description information' => '',
|
'A short post-description information' => '',
|
||||||
'Short conclusion' => '',
|
'Short conclusion' => '',
|
||||||
'Rewriten URL *' => '',
|
|
||||||
'Rewritten URL' => '',
|
'Rewritten URL' => '',
|
||||||
'Rewriten URL' => '',
|
|
||||||
'Parent category *' => '',
|
'Parent category *' => '',
|
||||||
'Top level' => '',
|
'Top level' => '',
|
||||||
'Visibility' => '',
|
'Visibility' => '',
|
||||||
|
|||||||
@@ -1,39 +1,121 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'Page not found' => 'Page non trouvée',
|
'No' => 'Non',
|
||||||
'The server returned a "404 Not Found"' => 'Le serveur à retourné l\'erreur "404 non trouvé"',
|
'Yes' => 'Oui',
|
||||||
'The page you\'ve requested was not found. Please check the page address, and try again.' => 'La page que vous avez demandé n\'est pas disponible.',
|
'Send files' => 'Envoyer les fichiers',
|
||||||
'Thelia Back Office' => 'Thelia Back Office',
|
'Drop files to upload' => 'Déposez les fichiers à envoyer sur le serveur',
|
||||||
'Version %ver' => 'Version %ver',
|
'Browse files' => 'Sélectionner les fichiers',
|
||||||
'View site' => 'Voir le site',
|
'Can\'t load documents, please refresh this page.' => 'Échec lors du chargement du document, veuillez réessayer',
|
||||||
'View shop' => 'Voir la boutique',
|
'OK' => 'OK',
|
||||||
'Profil' => 'Profile',
|
'Edit information in %lng' => 'Modifier les information en %Ing',
|
||||||
'Close administation session' => 'Quitter l\'interface d\'administration',
|
'Edit prices in %curr' => 'Modifier les prix en %curr',
|
||||||
'Logout' => 'Se déconnecter',
|
'Save' => ' Enregistrer',
|
||||||
|
'Save and close' => 'Enregistrer et fermer',
|
||||||
|
'Close' => 'Fermer',
|
||||||
|
'Product reference' => 'Référence produit',
|
||||||
|
'Rewritten URL' => 'URL réécrite',
|
||||||
|
'Top level' => 'Niveau racine',
|
||||||
|
'You can attach this product to more categories in the details tab.' => 'Vous pouvez lier ce produit à plus de catégories dans l\'onglet détail.',
|
||||||
|
'Visibility' => 'Visibilité',
|
||||||
|
'Product created on %date_create. Last modification: %date_change' => 'Produit créé le %date_create. Dernière modification : %date_change ',
|
||||||
|
'Cancel' => 'Annuler',
|
||||||
'Home' => 'Accueil',
|
'Home' => 'Accueil',
|
||||||
'Customers' => 'Clients',
|
|
||||||
'Orders' => 'Commandes',
|
|
||||||
'All orders' => 'Toutes les commandes',
|
|
||||||
'Catalog' => 'Catalogue',
|
|
||||||
'Folders' => 'Dossier',
|
'Folders' => 'Dossier',
|
||||||
'Coupons' => 'Codes Promo',
|
'Editing %fold' => 'Modification de %fold',
|
||||||
|
'Edit this folder' => 'Modifier ce dossier',
|
||||||
|
'(edit)' => '(modifier)',
|
||||||
|
'Editing %title' => 'Modifier %title',
|
||||||
|
'Can\'t load images, please refresh this page.' => 'Échec lors du chargement de l\'image, veuillez réessayer',
|
||||||
|
'classic modules' => 'module classique',
|
||||||
|
'Name' => 'Nom',
|
||||||
|
'Description' => 'Description',
|
||||||
|
'Enable/Disable' => 'Activer/Désactiver',
|
||||||
|
'Actions' => 'Actions',
|
||||||
|
'Deactivate %title module' => 'Désactiver le module %title',
|
||||||
|
'deactivation' => 'désactivation',
|
||||||
|
'activate %title module' => 'activer le module %title',
|
||||||
|
'activation' => 'activation',
|
||||||
|
'Configure this module' => 'Configurer ce module',
|
||||||
|
'Configure' => 'Configurer',
|
||||||
|
'Read the documentation of this module' => 'Lire la documentation de ce module',
|
||||||
|
'Edit this module' => 'Modifier ce module',
|
||||||
|
'Delete this module' => 'Supprimer ce module',
|
||||||
|
'Title' => 'Civilité',
|
||||||
|
'A short description, used when a summary or an introduction is required' => 'Une courte description, utilisé si un résumé ou une introduction est nécessaire',
|
||||||
|
'Short description' => 'Courte description',
|
||||||
|
'The detailed description.' => 'Description détaillée',
|
||||||
|
'A short post-description information' => 'Une courte post-description',
|
||||||
|
'Short conclusion' => 'Courte conclusion',
|
||||||
|
'Confirmation' => 'Confirmation',
|
||||||
|
'Do you really want to delete this element ?' => 'Voulez-vous vraiment supprimer cet élément ?',
|
||||||
|
'Confirm' => 'Je confirme',
|
||||||
|
'Please retry' => 'Merci de réessayer',
|
||||||
|
'There is no documents attached to this %type.' => 'Il n\'y a aucune document lié à ce %type',
|
||||||
|
'Update this image' => 'Mettre à jour cette image',
|
||||||
|
'There is no images attached to this %type.' => 'Il n\'y a pas d\'image liée à ce %type',
|
||||||
|
'Additional Folders' => 'Dossier additionnels',
|
||||||
|
'Select a folder...' => 'Choisissez un dossier de contenu...',
|
||||||
|
' (default)' => '(défaut)',
|
||||||
|
'Select a folder and click (+) to add it to the additional folder list' => 'Sélectionnez un dossier et cliquez (+) pour l\'ajouter à la liste des dossiers additionnel',
|
||||||
|
'No Folders found' => 'Aucun dossier trouvé',
|
||||||
|
'ID' => 'ID',
|
||||||
|
'Folder title' => 'Titre du dossier',
|
||||||
|
'Remove the product from this category' => 'Supprimer le produit de cette catégorie',
|
||||||
|
'This product doesn\'t belong to any additional folder.' => 'Ce produit n\'appartient à aucun dossier additionnel',
|
||||||
|
'Select a tax tule' => 'Sélectionnez une règle de taxes',
|
||||||
|
'Details' => 'Détails',
|
||||||
|
'Product EAN Code' => 'Code EAN du produit',
|
||||||
|
'Product weight' => 'Poids du produit',
|
||||||
|
'Kg' => 'Kg',
|
||||||
|
'Current quantity' => 'Quantité actuelle',
|
||||||
|
'Promotion' => 'Promotion',
|
||||||
|
'Product price' => 'Prix du produit',
|
||||||
|
'Combination builder' => 'Constructeur de combinaison',
|
||||||
|
'Add a new combination' => 'Ajouter une nouvelle combinaison',
|
||||||
|
'Reference' => 'Reference',
|
||||||
|
'EAN Code' => 'Code EAN',
|
||||||
|
'Quantity' => 'Quantité',
|
||||||
|
'Weight<br />(Kg)' => 'Poids<br />(Kg) ',
|
||||||
|
'Default' => 'Défaut',
|
||||||
|
'Sale' => 'Vente',
|
||||||
|
'New' => 'Nouveau',
|
||||||
|
'Delete this combination' => 'Supprimer cette combinaison',
|
||||||
|
'Attribute' => 'Attribut',
|
||||||
|
'Select an attribute...' => 'Sélectionnez un attribut',
|
||||||
|
'Select an attribute and click (+) to view available values' => 'Sélectionnez un attribut et cliquez (+) afin de voir les valeurs disponibles',
|
||||||
|
'Attribute values' => 'Valeur des attributs',
|
||||||
|
'Remove selected values' => 'Supprimer la valeur sélectionnée',
|
||||||
|
'Create a new combination' => 'Créer une nouvelle combinaison',
|
||||||
|
'Create this combination' => 'Créer cette combinaison',
|
||||||
|
'Delete a combination' => 'Supprimer une combinaison',
|
||||||
|
'Do you really want to delete this combination ?' => 'Voulez-vous vraiment supprimer cette combinaison ?',
|
||||||
|
'Combination reference' => 'Référence de la combinaison',
|
||||||
|
'Create combinations' => 'Créer des combinaisons',
|
||||||
|
'Company' => 'Entreprise',
|
||||||
|
'Firstname' => 'Prénom',
|
||||||
|
'Lastname' => 'Nom',
|
||||||
|
'Address' => 'Adresse',
|
||||||
|
'Additional address' => 'Adresse complémentaire',
|
||||||
|
'Zip code' => 'Code postal',
|
||||||
|
'City' => 'Ville',
|
||||||
|
'Phone number' => 'Numéro de téléphone',
|
||||||
|
'Cellular phone number' => 'Numéro de téléphone portable',
|
||||||
|
'Catalog' => 'Catalogue',
|
||||||
|
'Editing %cat' => 'Edition de %cat',
|
||||||
|
'Edit this category' => 'Editer cette catégorie',
|
||||||
|
'Thelia Shipping configuration' => 'Configuration des livraison Thelia',
|
||||||
'Configuration' => 'Configuration',
|
'Configuration' => 'Configuration',
|
||||||
'Modules' => 'Modules',
|
'Shipping configuration' => 'Configuration du transport',
|
||||||
'Search' => 'Recherche',
|
'Add a new shipping configuration' => 'Ajouter une nouvelle configuration de livraison',
|
||||||
'Thelia, the open source e-commerce solution' => 'Thelia, solution e-commerce libre',
|
'Change this shipping configuration' => 'Modifier cette configuration de livraison',
|
||||||
'© Thelia 2013' => '© Thelia 2013',
|
'Delete this shipping configuration' => 'Supprimer cette configuration de livraison',
|
||||||
'Published by OpenStudio' => 'Edité par OpenStudio',
|
'Create coupon' => 'Créer un code promo',
|
||||||
'Thelia support forum' => 'Communauté Thelia',
|
'Coupon' => 'Code promo',
|
||||||
'Thelia contributions' => 'Contributions Thelia',
|
'Create' => 'Créer',
|
||||||
'Thelia Mailing System' => 'Configuration des envois de mails',
|
'Coupons : ' => 'Codes promo',
|
||||||
'Administration logs' => 'Gestion des logs',
|
'Create a new coupon' => 'Créer un nouveau code promo',
|
||||||
'Show logs' => 'Voir les loge',
|
'Files manager' => 'Gestionnaire de fichier',
|
||||||
'Period' => 'Période',
|
|
||||||
'From' => 'De',
|
|
||||||
'To' => 'A',
|
|
||||||
'Administrators' => 'Administrateurs',
|
|
||||||
'Resources' => 'Ressources',
|
|
||||||
'Back-office users' => 'Utilisateurs du back-office',
|
'Back-office users' => 'Utilisateurs du back-office',
|
||||||
'Taxes' => 'Taxes',
|
'Taxes' => 'Taxes',
|
||||||
'Create a new administrator' => 'Créer un nouvel administrateur',
|
'Create a new administrator' => 'Créer un nouvel administrateur',
|
||||||
@@ -41,15 +123,12 @@ return array(
|
|||||||
'First Name' => 'Prénom',
|
'First Name' => 'Prénom',
|
||||||
'Last Name' => 'Nom',
|
'Last Name' => 'Nom',
|
||||||
'Profile' => 'Profile',
|
'Profile' => 'Profile',
|
||||||
'Actions' => 'Actions',
|
|
||||||
'Superadministrator' => 'Super-administrateur',
|
'Superadministrator' => 'Super-administrateur',
|
||||||
'Change this administrator' => 'Modifier cet administrateur',
|
'Change this administrator' => 'Modifier cet administrateur',
|
||||||
'Delete this administrator' => 'Supprimer cet administrateur',
|
'Delete this administrator' => 'Supprimer cet administrateur',
|
||||||
'FirstName' => 'Prénom',
|
'FirstName' => 'Prénom',
|
||||||
'LastName' => 'Nom',
|
'LastName' => 'Nom',
|
||||||
'Password' => 'Mot de passe',
|
'Password' => 'Mot de passe',
|
||||||
'Create' => 'Créer',
|
|
||||||
'Cancel' => 'Annuler',
|
|
||||||
'Leave empty to keep current password' => 'Laisser ce champ vide pour ne pas modifier le mot de passe',
|
'Leave empty to keep current password' => 'Laisser ce champ vide pour ne pas modifier le mot de passe',
|
||||||
'Update a new administrator' => 'Modifier cet administrateur',
|
'Update a new administrator' => 'Modifier cet administrateur',
|
||||||
'Update' => 'Mettre à jour',
|
'Update' => 'Mettre à jour',
|
||||||
@@ -57,182 +136,45 @@ return array(
|
|||||||
'Do you really want to delete this administrator ?' => 'Confirmez-vous la suppression de cet adminisrateur ?',
|
'Do you really want to delete this administrator ?' => 'Confirmez-vous la suppression de cet adminisrateur ?',
|
||||||
'You can\'t delete this administrator' => 'Vous ne pouvez pas supprimer cet administrateur',
|
'You can\'t delete this administrator' => 'Vous ne pouvez pas supprimer cet administrateur',
|
||||||
'They are some administrator which are linked to this administrator. Please edit/remove them before deleting this administrator.' => 'Cet administrateur est lié avec un ou plusieurs autres administrateurs. Supprimez ou modifiez ces administrateur d\'abord.',
|
'They are some administrator which are linked to this administrator. Please edit/remove them before deleting this administrator.' => 'Cet administrateur est lié avec un ou plusieurs autres administrateurs. Supprimez ou modifiez ces administrateur d\'abord.',
|
||||||
'Label' => 'Libellé',
|
'Edit a document' => 'Modifier un document',
|
||||||
'Company' => 'Entreprise',
|
'Document' => 'Document',
|
||||||
'Edit a language' => 'Modifier une langue',
|
'Editing document "%name"' => 'En cours de modification du document "%name"',
|
||||||
'Edit this language' => 'Modifier cette langue',
|
'Edit document "%name"' => 'Modifier le document "%name"',
|
||||||
'Current product template' => 'Gabarit de produit actuel',
|
|
||||||
'Do not use a product template' => 'Ne pas utiliser de gabarit',
|
|
||||||
'Apply' => 'Appliquer',
|
|
||||||
'Product Attributes' => 'Déclinaisons du produit',
|
|
||||||
'ID' => 'ID',
|
|
||||||
'Attribute Name' => 'Nom de la déclinaison',
|
|
||||||
'This product template does not contains any features' => 'Ce gabarit de produit ne comporte aucune caractéristique',
|
|
||||||
'Product Features' => 'Caractéristiques du produit',
|
|
||||||
'Feature Name' => 'Nom de la caractéristique',
|
|
||||||
'Feature value for this product' => 'Valeur de la caractéristique',
|
|
||||||
'Use Ctrl+click to select more than one value. You can also <a href="#" class="clear_feature_value" data-id="%id">clear selected values</a>.' => 'Utilisez Ctrl+clic pour choisir plus d\'une valeur. Vous pouvez aussi <a href="#" class="clear_feature_value" data-id="%id">tout désélectionner</a>.',
|
|
||||||
'Enter here the feature value as free text' => 'Indiquez ici la valeur de la caractéristique',
|
|
||||||
'Feature value' => 'Valeur de la caractéristique',
|
|
||||||
'Related content' => 'Contenu associé',
|
|
||||||
'You can attach here some content to this product' => 'Attachez ici un ou plusieurs contenus à ce produit',
|
|
||||||
'Select a folder...' => 'Choisissez un dossier de contenu...',
|
|
||||||
'Select a folder to get its content' => 'Choisissez un dossier de contenu pour lister ses contenus',
|
|
||||||
'Select a folder content...' => 'Choisissez un dossier de contenu...',
|
|
||||||
'Select a content and click (+) to add it to this product' => 'Chosiissez un contenu, et cliquez [+] pour l\'attacher au produit',
|
|
||||||
'No available content in this folder' => 'Ce dossier est vide de contenus',
|
|
||||||
'No folders found' => 'Aucun dossier n\'a été trouvé.',
|
|
||||||
'Content title' => 'Titre du contenu',
|
|
||||||
'Position' => 'Position',
|
|
||||||
'Delete this content' => 'Supprimer ce contenu',
|
|
||||||
'Category title' => 'Titre de la catégorie',
|
|
||||||
'Enter new category position' => 'Classement de la catégorie ',
|
|
||||||
'Lire la suite' => 'Lire la suite',
|
|
||||||
'Value' => 'Valeur',
|
|
||||||
'Title' => 'Civilité',
|
|
||||||
'Product attributes' => 'Attributs produit',
|
|
||||||
'Categories' => 'Catégories',
|
|
||||||
'Top level categories' => 'Catégories de niveau 1 ',
|
|
||||||
'Add a new category' => 'Ajouter une catégorie',
|
|
||||||
'Online' => 'En ligne',
|
|
||||||
'Browse this category' => 'Parcourir cette catégorie',
|
|
||||||
'Edit this category' => 'Editer cette catégorie',
|
|
||||||
'Delete this category and all its contents' => 'Supprimer cette catégorie et tout ce qu\'elle contient ? ',
|
|
||||||
'This category has no sub-categories. To create a new one, click the + button above.' => 'Cette catégorie n\'a pas de sous-catégorie. Pour en créer une nouvelle, cliquez sur le bouton + ci-dessus.',
|
|
||||||
'This category has no sub-categories.' => 'Cette catégorie n\'a pas de sous-catégorie.',
|
|
||||||
'Top level Products' => 'Produits mis en avant',
|
|
||||||
'Add a new product' => 'Ajouter un nouveau produit',
|
|
||||||
'Reference' => 'Reference',
|
|
||||||
'Product title' => 'Titre du produit',
|
|
||||||
'This category doesn\'t contains any products. To add a new product, <strong>click the + button</strong> above.' => 'Cette catégorie n\'a aucun produit. Pour créer un nouveau product, <strong>cliques sur le bouton +</strong> ci-dessus. ',
|
|
||||||
'Name' => 'Nom',
|
|
||||||
'Enter here the category name in the default language (%title)' => 'Entrer ici le nom de la catégorie dans la langue par défaut (%title)',
|
|
||||||
'Create a new category' => 'Créer une catégorie',
|
|
||||||
'Create this category' => 'Créer cette catégorie',
|
|
||||||
'Enter here the product reference' => 'Entrez ici la nouvelle référence produit',
|
|
||||||
'Enter here the product name in the default language (%title)' => 'Entrez ici le nom du produit dans la langue par défaut (%title)',
|
|
||||||
'Product price' => 'Prix du produit',
|
|
||||||
'Enter here the product price in the default currency (%title)' => 'ntrez ici le prix du produit dans la langue par défaut (%title)',
|
|
||||||
'Select a tax tule' => 'Sélectionnez une règle de taxes',
|
|
||||||
'Select here the tax applicable to this product' => 'Sélectionnez ici la taxe applicable sur ce produit',
|
|
||||||
'Product weight' => 'Poids du produit',
|
|
||||||
'Kg' => 'Kg',
|
|
||||||
'Enter here the product weight, in Kilogrammes' => 'Entrez ici le poids du produit, en Kilogrammes',
|
|
||||||
'Create a new product' => 'Créer un nouveau produit',
|
|
||||||
'Create this product' => 'Créer ce produit',
|
|
||||||
'Delete category' => 'Supprimer cette catégorie',
|
|
||||||
'Do you really want to delete this category and all its content ?' => 'Voulez-vous vraiment supprimer cette catégorie et tout ce qu\'elle contient ?',
|
|
||||||
'Delete product' => 'Supprimer ce produit',
|
|
||||||
'Do you really want to delete this product ?' => 'Voulez-vous vraiment supprimer ce produit ?',
|
|
||||||
'Enter new product position' => 'Classement du produit',
|
|
||||||
'Edit category' => 'Editer la catégorie',
|
|
||||||
'Edit category %title' => 'Editer le titre de la catégorie : %title',
|
|
||||||
'Thelia configuration' => 'Configuration thelia',
|
|
||||||
'Product catalog configuration' => 'Configuration du catalogue produit',
|
|
||||||
'Product templates' => 'Template produit',
|
|
||||||
'Product features' => 'Caractéristiques produit',
|
|
||||||
'Mailing templates' => 'Template e-mail',
|
|
||||||
'Currencies' => 'Monnaie',
|
|
||||||
'Taxes rules' => 'Règles de taxes',
|
|
||||||
'Shipping configuration' => 'Configuration du transport',
|
|
||||||
'Countries' => 'Pays',
|
|
||||||
'Shipping zones' => 'Zones de livraison',
|
|
||||||
'System parameters' => 'Paramètres système ',
|
|
||||||
'System variables' => 'Gestion des variables',
|
|
||||||
'Administration profiles' => 'Gestion des administrateurs',
|
|
||||||
'Languages & URLs' => 'Langues et URLs',
|
|
||||||
'Mailing system' => 'Envoi des e-mails',
|
|
||||||
'System logs' => 'Journal des logs',
|
|
||||||
'And' => 'Et',
|
|
||||||
'Edit' => 'Editer',
|
|
||||||
'Delete' => 'Supprimer',
|
|
||||||
'Code :' => 'Code',
|
|
||||||
'code' => 'code',
|
|
||||||
'Title :' => 'Titre',
|
|
||||||
'title' => 'titre',
|
|
||||||
'Is enabled' => 'Est valide',
|
|
||||||
'Is available on special offers' => 'Est valide sur les offres promotionnelles',
|
|
||||||
'Is cumulative' => 'Est cumulable',
|
|
||||||
'Is removing postage' => 'Offre les frais de port',
|
|
||||||
'Expiration date :' => 'Date de fin de validité',
|
|
||||||
'yyyy-mm-dd' => 'jjjj--mm--aa',
|
|
||||||
'Is unlimited' => 'Est illimité',
|
|
||||||
'Max usage :' => 'Utilisations max',
|
|
||||||
'max usage' => 'utilisations max',
|
|
||||||
'Type :' => 'Type',
|
|
||||||
'Please select a coupon type' => 'Merci d\'entrer le type de code',
|
|
||||||
'Amount :' => 'Montant',
|
|
||||||
'14.50' => '14.50',
|
|
||||||
'Short description :' => 'Description courte',
|
|
||||||
'short description' => 'description court',
|
|
||||||
'Long description :' => 'Description longue',
|
|
||||||
'long description' => 'description longue',
|
|
||||||
'Save your modifications' => 'Enregistrer les modifications',
|
|
||||||
'Conditions' => 'Conditions',
|
|
||||||
'Save this condition' => 'Enregistrer cette condition',
|
|
||||||
'Condition\'s category :' => 'Type de condition',
|
|
||||||
'Please select a condition category' => 'Merci d\'entrer le type de condition',
|
|
||||||
'Coupon' => 'Code promo',
|
|
||||||
'Coupons : ' => 'Codes promo',
|
|
||||||
'Create a new coupon' => 'Créer un nouveau code promo',
|
|
||||||
'Browse' => 'Parcourir',
|
|
||||||
'List' => 'Liste',
|
|
||||||
'Enabled coupons' => 'Codes promo disponibles',
|
|
||||||
'Code' => 'Code',
|
|
||||||
'Days before expiration' => 'Jours de validité',
|
|
||||||
'Usage left' => 'Utilisation restante',
|
|
||||||
'Unlimited' => 'Illimité',
|
|
||||||
'Disabled coupons' => 'Codes désactivés',
|
|
||||||
'Expiration date' => 'Date de fin',
|
|
||||||
'Amount' => 'Montant',
|
|
||||||
'Update coupon' => 'Mettre à jour le code',
|
|
||||||
'Please retry' => 'Merci de réessayer',
|
|
||||||
'Please select another condition' => 'Merci de sélectionner une autre condition',
|
|
||||||
'Edit a customer' => 'Editer un client',
|
|
||||||
'Editing customer "%name"' => 'Edition du client "%name"',
|
|
||||||
'Customer informations' => 'Informations client',
|
|
||||||
'Firstname' => 'Prénom',
|
|
||||||
'Lastname' => 'Nom',
|
|
||||||
'Default address' => 'Adresse par défaut',
|
|
||||||
'Address' => 'Adresse',
|
|
||||||
'Additional address' => 'Adresse complémentaire',
|
|
||||||
'Zip code' => 'Code postal',
|
|
||||||
'City' => 'Ville',
|
|
||||||
'Other addresses' => 'Autres adresses',
|
|
||||||
'Add a new address' => 'Ajouter une nouvelle adresse',
|
|
||||||
'Phone' => 'Téléphone',
|
|
||||||
'Edit this address' => 'Editer cette adresse',
|
|
||||||
'Use this address by default' => 'Utiliser comme adresse par défaut',
|
|
||||||
'Delete this customer and all his orders' => 'Supprimer ce client et toutes ses commandes',
|
|
||||||
'orders for this customer' => 'commandes pour ce client',
|
|
||||||
'Order n°' => 'Commande n° ',
|
|
||||||
'Date & Hour' => 'Date et heure',
|
|
||||||
'Status' => 'Etat',
|
|
||||||
'Create this address' => 'Créer cette adresse',
|
|
||||||
'Use address by default' => 'Utiliser comme adresse par défaut',
|
|
||||||
'Do you really want to use this address by default ?' => 'Voulez-vous vraiment utiliser cette adresse comme adresse par défaut ?',
|
|
||||||
'Delete address' => 'Supprimer cette adresse',
|
|
||||||
'Do you really want to delete this address ?' => 'Voulez-vous vraiment supprimer cette adresse ?',
|
|
||||||
'Customer' => 'Client',
|
|
||||||
'Customers list' => 'Liste des clients',
|
|
||||||
'Add a new Customer' => 'Ajouter un client',
|
|
||||||
'Edit this customer' => 'Modifier ce client',
|
|
||||||
'Send a mail to this customer' => 'Contacter ce client par mail',
|
|
||||||
'Email address' => 'Adresse e-mail',
|
|
||||||
'Create a new customer' => 'Ajouter un client',
|
|
||||||
'Create this customer' => 'Ajouter ce client',
|
|
||||||
'Delete customer' => 'Supprimer ce client',
|
|
||||||
'Do you really want to delete this customer ?' => 'Voulez-vous supprimer ce client ? ',
|
|
||||||
'Back' => 'Retour',
|
'Back' => 'Retour',
|
||||||
'Save' => ' Enregistrer',
|
'Document informations' => 'Informations sur le document',
|
||||||
'Description' => 'Description',
|
'File' => 'Fichier',
|
||||||
|
'Post Scriptum' => 'Post-scriptum',
|
||||||
|
'Thelia System Variables' => 'Variables Thelia',
|
||||||
|
'System variables' => 'Gestion des variables',
|
||||||
|
'Thelia system variables' => 'Variables Thelia',
|
||||||
|
'Add a new variable' => 'Ajouter une variable',
|
||||||
|
'Save chages' => 'Enregistrer les modifications',
|
||||||
|
'Save changes' => 'Enregistrer les modifications',
|
||||||
|
'Purpose' => 'Objet',
|
||||||
|
'Value' => 'Valeur',
|
||||||
|
'Action' => 'Action',
|
||||||
|
'Change this variable' => 'Modifier cette variable',
|
||||||
|
'Cancel changes and revert to original value' => 'Annuler les modifications et revenir à la version antérieure',
|
||||||
|
'Delete this variable' => 'Supprimer cette variable',
|
||||||
|
'This variable could not be changed.' => 'Cette variable ne peut pas être modifiée',
|
||||||
|
'Variable name' => 'Nom de la variable',
|
||||||
|
'Variable value' => 'Valeur de la variable',
|
||||||
|
'Variable purpose' => 'Objet de la variable',
|
||||||
|
'Enter here the category name in the default language (%title)' => 'Entrer ici le nom de la catégorie dans la langue par défaut (%title)',
|
||||||
|
'Create a new variable' => 'Créer une nouvelle variable',
|
||||||
|
'Create this variable' => 'Ajouter cette variable',
|
||||||
|
'Delete a variable' => 'Supprimer une variable',
|
||||||
|
'Do you really want to delete this variable ?' => 'Voulez-vous vraiment supprimer cette variable ?',
|
||||||
'Back-office home' => 'Accueil administration',
|
'Back-office home' => 'Accueil administration',
|
||||||
'Dashboard' => 'Tableau de bord',
|
'Dashboard' => 'Tableau de bord',
|
||||||
'Sales' => 'Ventes',
|
'Sales' => 'Ventes',
|
||||||
'New customers' => 'Nouveaux clients',
|
'New customers' => 'Nouveaux clients',
|
||||||
|
'Orders' => 'Commandes',
|
||||||
'First orders' => 'Premières commandes',
|
'First orders' => 'Premières commandes',
|
||||||
'Aborted orders' => 'Paniers abandonnés',
|
'Aborted orders' => 'Paniers abandonnés',
|
||||||
'Shop Informations' => 'Informations sur le magasin',
|
'Shop Informations' => 'Informations sur le magasin',
|
||||||
|
'Customers' => 'Clients',
|
||||||
|
'Categories' => 'Catégories',
|
||||||
'Products' => 'Produits',
|
'Products' => 'Produits',
|
||||||
'Online products' => 'Produits en ligne',
|
'Online products' => 'Produits en ligne',
|
||||||
'Offline products' => 'Produits hors ligne',
|
'Offline products' => 'Produits hors ligne',
|
||||||
@@ -251,31 +193,146 @@ return array(
|
|||||||
'Latest version available' => 'Dernière version disponible',
|
'Latest version available' => 'Dernière version disponible',
|
||||||
'News' => 'Actualités',
|
'News' => 'Actualités',
|
||||||
'Click here' => 'Cliquez ici',
|
'Click here' => 'Cliquez ici',
|
||||||
'Editing %cat' => 'Edition de %cat',
|
'Edit a customer' => 'Editer un client',
|
||||||
'No' => 'Non',
|
'Editing customer "%name"' => 'Edition du client "%name"',
|
||||||
'Yes' => 'Oui',
|
'Customer informations' => 'Informations client',
|
||||||
'OK' => 'OK',
|
'Default address' => 'Adresse par défaut',
|
||||||
'Save and close' => 'Enregistrer et fermer',
|
'Other addresses' => 'Autres adresses',
|
||||||
'Quantity' => 'Quantité',
|
'Add a new address' => 'Ajouter une nouvelle adresse',
|
||||||
'deactivate' => 'désactiver',
|
'Phone' => 'Téléphone',
|
||||||
'en_US' => 'en_US',
|
'Cellular phone' => 'Téléphone portable',
|
||||||
'd-m-Y' => 'j-m-A',
|
'Edit this address' => 'Editer cette adresse',
|
||||||
|
'Use this address by default' => 'Utiliser comme adresse par défaut',
|
||||||
|
'Delete this customer and all his orders' => 'Supprimer ce client et toutes ses commandes',
|
||||||
|
'orders for this customer' => 'commandes pour ce client',
|
||||||
|
'Order n°' => 'Commande n° ',
|
||||||
|
'Date & Hour' => 'Date et heure',
|
||||||
|
'Amount' => 'Montant',
|
||||||
|
'Status' => 'Etat',
|
||||||
|
'Create a customer address' => 'Créer une adresse client',
|
||||||
|
'Create this address' => 'Créer cette adresse',
|
||||||
|
'Edit a customer address' => 'Modifier une adresse client',
|
||||||
|
'Save this address' => 'Sauvegarder cette adresse',
|
||||||
|
'Use address by default' => 'Utiliser comme adresse par défaut',
|
||||||
|
'Do you really want to use this address by default ?' => 'Voulez-vous vraiment utiliser cette adresse comme adresse par défaut ?',
|
||||||
|
'Delete address' => 'Supprimer cette adresse',
|
||||||
|
'Do you really want to delete this address ?' => 'Voulez-vous vraiment supprimer cette adresse ?',
|
||||||
|
'Edit content' => 'Modifier le contenu',
|
||||||
|
'Edit content %title' => 'Modifier le contenu %title',
|
||||||
|
'Edit previous content' => 'Modifier le contenu précèdent',
|
||||||
|
'Preview folder page' => 'Aperçu de la page dossier',
|
||||||
|
'Edit next content' => 'Modifier le prochain contenu',
|
||||||
|
'General description' => 'Description générale',
|
||||||
|
'Associations' => 'Associations',
|
||||||
|
'Images' => 'Images',
|
||||||
|
'Documents' => 'Documents',
|
||||||
|
'Modules' => 'Modules',
|
||||||
|
'Remove associated folder' => 'Supprimer le dossier associé',
|
||||||
|
'Edit a tax rule' => 'Modifier une règle de taxe',
|
||||||
|
'Taxes rules' => 'Règles de taxes',
|
||||||
|
'Editing tax rule' => 'En cours de modification d\'une règle de taxe',
|
||||||
|
'Manage taxes' => 'Gérer les taxes',
|
||||||
|
'Choose a country' => 'Choisissez un pays',
|
||||||
|
'Countries that have the same tax rule' => 'Pays ayant les mêmes règles de taxe',
|
||||||
|
'NONE' => 'AUCUN',
|
||||||
|
'Add tax to this group' => 'Ajouter une taxe à ce groupe',
|
||||||
|
'Apply' => 'Appliquer',
|
||||||
|
'uncheck all' => 'Tous décocher',
|
||||||
|
'Edit tax rule taxes' => 'Modifier une règle de taxe',
|
||||||
|
'Welcome' => 'Bienvenue',
|
||||||
|
'Thelia Back Office' => 'Thelia Back Office',
|
||||||
'Username' => 'Nom d\'utilisateur',
|
'Username' => 'Nom d\'utilisateur',
|
||||||
'Host :' => 'Host',
|
'Loading Thelia lastest news...' => 'Chargement des dernières nouvelles sur Thelia',
|
||||||
'Host' => 'Host',
|
'Related content' => 'Contenu associé',
|
||||||
'Port :' => 'Port',
|
'You can attach here some content to this product' => 'Attachez ici un ou plusieurs contenus à ce produit',
|
||||||
'Port' => 'Port',
|
'Select a folder to get its content' => 'Choisissez un dossier de contenu pour lister ses contenus',
|
||||||
'Username :' => 'Nom d\'utilisateur',
|
'Select a folder content...' => 'Choisissez un dossier de contenu...',
|
||||||
'Password :' => 'Mot de passe',
|
'Select a content and click (+) to add it to this product' => 'Chosiissez un contenu, et cliquez [+] pour l\'attacher au produit',
|
||||||
'Source IP :' => 'IP source',
|
'No available content in this folder' => 'Ce dossier est vide de contenus',
|
||||||
'Source IP' => 'IP source',
|
'No folders found' => 'Aucun dossier n\'a été trouvé.',
|
||||||
'Variable name' => 'Nom de la variable',
|
'Content title' => 'Titre du contenu',
|
||||||
'Purpose' => 'Objet',
|
'Position' => 'Position',
|
||||||
|
'Delete this content' => 'Supprimer ce contenu',
|
||||||
|
'This product contains no contents' => 'Ce produit ne contient aucun contenu',
|
||||||
|
'Product accessories' => 'Accessoires produit',
|
||||||
|
'Select a category...' => 'Sélectionnez une catégorie...',
|
||||||
|
'Select a product...' => 'Sélectionnez un produit',
|
||||||
|
'No categories found' => 'Aucune catégorie trouvée',
|
||||||
|
'Accessory title' => 'Titre de l\'accessoire',
|
||||||
|
'Delete this accessory' => 'Supprimer cet accessoire',
|
||||||
|
'Additional categories' => 'Catégorie additionnelle',
|
||||||
|
'Category title' => 'Titre de la catégorie',
|
||||||
|
'Remove related content' => 'Supprimer le contenu lié',
|
||||||
|
'Do you really want to remove this related content from the product ?' => 'Voulez-vous vraiment enlever ce contenu lié de ce produit ?',
|
||||||
|
'Remove an accessory' => 'Enlever un accessoire',
|
||||||
|
'Do you really want to remove this accessory from the product ?' => 'Voulez-vous vraiment enlever cet accessoire de ce produit ?',
|
||||||
|
'Remove from category' => 'Enlever de la catégorie',
|
||||||
|
'Do you really want to remove the product from this category ?' => 'Voulez-vous vraiment enlever ce produit de cette catégorie ?',
|
||||||
|
'Enter new category position' => 'Classement de la catégorie ',
|
||||||
|
'Lire la suite' => 'Lire la suite',
|
||||||
|
'Attribute title' => 'Titre de l\'attribut',
|
||||||
|
'Delete this attribute' => 'Supprimer cet attribut',
|
||||||
|
'This template contains no attributes' => 'Ce template ne contient aucun attribut',
|
||||||
|
'Remove attribute' => 'Enlever l\'attribut',
|
||||||
|
'Do you really want to remove this attribute from the template ?' => 'Voulez-vous vraiment enlever cet attribut de ce template ?',
|
||||||
|
'Label' => 'Libellé',
|
||||||
|
'Edit a language' => 'Modifier une langue',
|
||||||
|
'Edit this language' => 'Modifier cette langue',
|
||||||
|
'Current product template' => 'Gabarit de produit actuel',
|
||||||
|
'Do not use a product template' => 'Ne pas utiliser de gabarit',
|
||||||
|
'Product Attributes' => 'Déclinaisons du produit',
|
||||||
|
'Attribute Name' => 'Nom de la déclinaison',
|
||||||
|
'This product template does not contains any features' => 'Ce gabarit de produit ne comporte aucune caractéristique',
|
||||||
|
'Product Features' => 'Caractéristiques du produit',
|
||||||
|
'Feature Name' => 'Nom de la caractéristique',
|
||||||
|
'Feature value for this product' => 'Valeur de la caractéristique',
|
||||||
|
'Use Ctrl+click to select more than one value. You can also <a href="#" class="clear_feature_value" data-id="%id">clear selected values</a>.' => 'Utilisez Ctrl+clic pour choisir plus d\'une valeur. Vous pouvez aussi <a href="#" class="clear_feature_value" data-id="%id">tout désélectionner</a>.',
|
||||||
|
'Enter here the feature value as free text' => 'Indiquez ici la valeur de la caractéristique',
|
||||||
|
'Feature value' => 'Valeur de la caractéristique',
|
||||||
|
'Currencies' => 'Monnaie',
|
||||||
|
'Update rates' => 'Mettre à jour les taux',
|
||||||
|
'Add a new currency' => 'Ajouter une devise',
|
||||||
|
'ISO 4217 Code' => 'Code ISO 4217',
|
||||||
|
'Symbol' => 'Symbole',
|
||||||
|
'Rate in €' => 'Taux en € ',
|
||||||
|
'Change this currency' => 'Modifier cette devise',
|
||||||
|
'Delete this currency' => 'Supprimer cette devise',
|
||||||
|
'Currency name' => 'Nom de la devise',
|
||||||
|
'ISO 4217 code' => 'Code ISO 4217',
|
||||||
|
'Code' => 'Code',
|
||||||
|
'Currency symbol' => 'Symbole de la devise',
|
||||||
|
'Currency rate' => 'Taux de la devise',
|
||||||
|
'Create a new currency' => 'Créer une nouvelle devise',
|
||||||
|
'Create this currency' => 'Créer cette devise',
|
||||||
|
'Delete currency' => 'Supprimer la devise',
|
||||||
|
'Edit an attribute' => 'Modifier un attribut',
|
||||||
|
'Attributes' => 'Attributs',
|
||||||
|
'Delete this value' => 'Supprimer cette valeur',
|
||||||
|
'Create this value' => 'Créer cette valeur',
|
||||||
|
'Edit category' => 'Editer la catégorie',
|
||||||
|
'Edit category %title' => 'Editer le titre de la catégorie : %title',
|
||||||
|
'Edit previous category' => 'Modifier la catégorie précédente',
|
||||||
|
'Preview category page' => 'Aperçu de la page catégorie',
|
||||||
|
'Edit next category' => 'Modifier la catégorie suivante',
|
||||||
|
'Search' => 'Recherche',
|
||||||
|
'Customer' => 'Client',
|
||||||
|
'customer ref' => 'ref client',
|
||||||
|
'company' => 'entreprise',
|
||||||
|
'firstname & lastname' => 'Prénom & nom',
|
||||||
|
'last order' => 'Dernière commande',
|
||||||
|
'order amount' => 'Montant de la commande',
|
||||||
|
'Edit this customer' => 'Modifier ce client',
|
||||||
|
'Send a mail to this customer' => 'Contacter ce client par mail',
|
||||||
|
'Edit this order' => 'Editer cette commande ',
|
||||||
|
'Product' => 'Produit',
|
||||||
|
'Product title' => 'Titre du produit',
|
||||||
|
'Edit folder' => 'Modifier le dossier',
|
||||||
|
'Edit previous folder' => 'Modifier le dossier précèdent',
|
||||||
|
'Edit next folder' => 'Modifier le dossier suivant',
|
||||||
'Edit an order' => 'Editer une commande',
|
'Edit an order' => 'Editer une commande',
|
||||||
'Ordered products' => 'Produits commandés',
|
'Ordered products' => 'Produits commandés',
|
||||||
'Invoice and Delivery' => 'Livraison et facturation',
|
'Invoice and Delivery' => 'Livraison et facturation',
|
||||||
'Cart' => 'Panier',
|
'Cart' => 'Panier',
|
||||||
'Product' => 'Produit',
|
|
||||||
'Unit. price' => 'Prix unitaire',
|
'Unit. price' => 'Prix unitaire',
|
||||||
'Tax' => 'Taxes',
|
'Tax' => 'Taxes',
|
||||||
'Unit taxed price' => 'Prix unitaire TTC',
|
'Unit taxed price' => 'Prix unitaire TTC',
|
||||||
@@ -305,37 +362,249 @@ return array(
|
|||||||
'Edit delivery address' => 'Editer l\'adresse de livraison',
|
'Edit delivery address' => 'Editer l\'adresse de livraison',
|
||||||
'Edit order address' => 'Editer l\'adresse de commande ',
|
'Edit order address' => 'Editer l\'adresse de commande ',
|
||||||
'Confirm changes' => 'Valider les modifications',
|
'Confirm changes' => 'Valider les modifications',
|
||||||
'Edit this order' => 'Editer cette commande ',
|
'Update coupon' => 'Mettre à jour le code',
|
||||||
'Cancel this order' => 'Annuler cette commande',
|
'Please select another condition' => 'Merci de sélectionner une autre condition',
|
||||||
'Delete an order' => 'Supprimer une commande',
|
'Add a new folder' => 'Ajouter une nouveau dossier',
|
||||||
'Do you really want to cancel this order ?' => 'Voulez-vous vraiment sup primer cette commande ? ',
|
'Online' => 'En ligne',
|
||||||
'View' => 'Voir',
|
'Add a new content' => 'Ajouter un nouveau contenu',
|
||||||
'customer ref' => 'ref client',
|
'Edit this content' => 'Modifier ce contenu',
|
||||||
'company' => 'entreprise',
|
'Create a new folder' => 'Ajouter un nouveau dossier',
|
||||||
'firstname & lastname' => 'Prénom & nom',
|
'Create this folder' => 'Créer ce dossier',
|
||||||
'last order' => 'Dernière commande',
|
'Delete folder' => 'Supprimer le dossier',
|
||||||
'order amount' => 'Montant de la commande',
|
'Delete content' => 'Supprimer le contenu',
|
||||||
'Add' => 'Ajouter',
|
|
||||||
'Warning' => 'Attention',
|
|
||||||
'Edit a system variable' => 'Modifier une variable système',
|
'Edit a system variable' => 'Modifier une variable système',
|
||||||
'Editing variable "%name"' => 'Modification de la variable "%name" ',
|
'Editing variable "%name"' => 'Modification de la variable "%name" ',
|
||||||
'Edit variable %name' => 'Modifier de la variable "%name" ',
|
'Edit variable %name' => 'Modifier de la variable "%name" ',
|
||||||
'Variable value' => 'Valeur de la variable',
|
|
||||||
'Variable created on %date_create. Last modification: %date_change' => 'Variable créée le %date_create. Dernière modification: %date_change',
|
'Variable created on %date_create. Last modification: %date_change' => 'Variable créée le %date_create. Dernière modification: %date_change',
|
||||||
'Sorry, variable ID=%id was not found.' => 'Désolé, la variable ID=%id n\'a pas été trouvée.',
|
'Sorry, variable ID=%id was not found.' => 'Désolé, la variable ID=%id n\'a pas été trouvée.',
|
||||||
'Thelia System Variables' => 'Variables Thelia',
|
'Store' => 'Magasin',
|
||||||
'Thelia system variables' => 'Variables Thelia',
|
'Store configuration' => 'Configuration du magasin',
|
||||||
'Add a new variable' => 'Ajouter une variable',
|
'General' => 'Général',
|
||||||
'Save chages' => 'Enregistrer les modifications',
|
'Edit product' => 'Modifier le produit',
|
||||||
'Save changes' => 'Enregistrer les modifications',
|
'Edit previous product' => 'Modifier le produit précèdent',
|
||||||
'Action' => 'Action',
|
'Edit next product' => 'Modifier le produit suivant',
|
||||||
'Change this variable' => 'Modifier cette variable',
|
'Edit a tax' => 'Modifier une taxe',
|
||||||
'Cancel changes and revert to original value' => 'Annuler les modifications et revenir à la version antérieure',
|
'Coupon : ' => 'Code promo',
|
||||||
'Delete this variable' => 'Supprimer cette variable',
|
'Is enabled' => 'Est valide',
|
||||||
'This variable could not be changed.' => 'Cette variable ne peut pas être modifiée',
|
'Expiration date' => 'Date de fin',
|
||||||
'Variable purpose' => 'Objet de la variable',
|
'days left' => 'jours restant',
|
||||||
'Create a new variable' => 'Créer une nouvelle variable',
|
'Usage left' => 'Utilisation restante',
|
||||||
'Create this variable' => 'Ajouter cette variable',
|
'Unlimited' => 'Illimité',
|
||||||
'Delete a variable' => 'Supprimer une variable',
|
'May be cumulative' => 'Pourra être cumulé',
|
||||||
'Do you really want to delete this variable ?' => 'Voulez-vous vraiment supprimer cette variable ?',
|
'Can\'t be cumulative' => 'Ne pourra pas être cumulé',
|
||||||
|
'Will remove postage' => 'Enlèvera les frais de port',
|
||||||
|
'Won\'t remove postage' => 'N\'enlèvera pas les frais de port',
|
||||||
|
'Will be available on special offers' => 'Sera disponible sur les offres spéciales',
|
||||||
|
'Won\'t be available on special offers' => 'Ne sera pas disponible sur les offres spéciales',
|
||||||
|
'Application field' => 'Champs d\'application',
|
||||||
|
'And' => 'Et',
|
||||||
|
'Edit' => 'Editer',
|
||||||
|
'Do you really want to enable this element ?' => 'Voulez-vous vraiment activer cet élément ?',
|
||||||
|
'Mailing templates' => 'Template e-mail',
|
||||||
|
'Code :' => 'Code',
|
||||||
|
'code' => 'code',
|
||||||
|
'Title :' => 'Titre',
|
||||||
|
'title' => 'titre',
|
||||||
|
'Is available on special offers' => 'Est valide sur les offres promotionnelles',
|
||||||
|
'Is cumulative' => 'Est cumulable',
|
||||||
|
'Is removing postage' => 'Offre les frais de port',
|
||||||
|
'Expiration date :' => 'Date de fin de validité',
|
||||||
|
'yyyy-mm-dd' => 'jjjj--mm--aa',
|
||||||
|
'Is unlimited' => 'Est illimité',
|
||||||
|
'Max usage :' => 'Utilisations max',
|
||||||
|
'max usage' => 'utilisations max',
|
||||||
|
'Type :' => 'Type',
|
||||||
|
'Please select a coupon type' => 'Merci d\'entrer le type de code',
|
||||||
|
'Amount :' => 'Montant',
|
||||||
|
'14.50' => '14.50',
|
||||||
|
'Short description :' => 'Description courte',
|
||||||
|
'short description' => 'description court',
|
||||||
|
'Long description :' => 'Description longue',
|
||||||
|
'long description' => 'description longue',
|
||||||
|
'Save your modifications' => 'Enregistrer les modifications',
|
||||||
|
'Conditions' => 'Conditions',
|
||||||
|
'Save this condition' => 'Enregistrer cette condition',
|
||||||
|
'Condition\'s category :' => 'Type de condition',
|
||||||
|
'Please select a condition category' => 'Merci d\'entrer le type de condition',
|
||||||
|
'Delete' => 'Supprimer',
|
||||||
|
'Thelia Mailing System' => 'Configuration des envois de mails',
|
||||||
|
'Mailing system' => 'Envoi des e-mails',
|
||||||
|
'Host :' => 'Host',
|
||||||
|
'Host' => 'Host',
|
||||||
|
'Port :' => 'Port',
|
||||||
|
'Port' => 'Port',
|
||||||
|
'Username :' => 'Nom d\'utilisateur',
|
||||||
|
'Password :' => 'Mot de passe',
|
||||||
|
'Source IP :' => 'IP source',
|
||||||
|
'Source IP' => 'IP source',
|
||||||
|
'Product attributes' => 'Attributs produit',
|
||||||
|
'Remove from all product templates' => 'Supprimer de tous les templates produits',
|
||||||
|
'Product features' => 'Caractéristiques produit',
|
||||||
|
'taxes' => 'taxes',
|
||||||
|
'and' => 'et',
|
||||||
|
'tax rules' => 'règles de taxe',
|
||||||
|
'Example :' => 'Exemple:',
|
||||||
|
'Create a new tax' => 'Créer une nouvelle taxe',
|
||||||
|
'Change this tax' => 'Modifier cette taxe',
|
||||||
|
'Delete this tax' => 'Supprimer cette taxe',
|
||||||
|
'Delete tax' => 'Supprimer une taxe',
|
||||||
|
'Do you really want to delete this tax ?' => 'Voulez-vous vraiment supprimer cette taxe ?',
|
||||||
|
'Delete tax rule' => 'Supprimer une règle de taxe',
|
||||||
|
'Do you really want to delete this tax rule ?' => 'Voulez-vous vraiment supprimer cette règle de taxe ?',
|
||||||
|
'Administration logs' => 'Gestion des logs',
|
||||||
|
'Show logs' => 'Voir les loge',
|
||||||
|
'Period' => 'Période',
|
||||||
|
'From' => 'De',
|
||||||
|
'To' => 'A',
|
||||||
|
'Administrators' => 'Administrateurs',
|
||||||
|
'Resources' => 'Ressources',
|
||||||
|
'Shipping zones' => 'Zones de livraison',
|
||||||
|
'Add' => 'Ajouter',
|
||||||
|
'Zones' => 'Zones',
|
||||||
|
'Delete this zone' => 'Supprimer cette zone',
|
||||||
|
'Remove zone' => 'Supprimer zone',
|
||||||
|
'Cancel this order' => 'Annuler cette commande',
|
||||||
|
'Delete an order' => 'Supprimer une commande',
|
||||||
|
'Do you really want to cancel this order ?' => 'Voulez-vous vraiment sup primer cette commande ? ',
|
||||||
|
'System Logs' => 'Logs système',
|
||||||
|
'System logs' => 'Journal des logs',
|
||||||
|
'System Logs configuration' => 'Configuration logs système',
|
||||||
|
'General configuration' => 'Configuration générale',
|
||||||
|
'Log lines format' => 'Format des lignes des logs',
|
||||||
|
'File names' => 'Noms du fichier',
|
||||||
|
'IP Addresses' => 'Adresse IP',
|
||||||
|
'Destinations' => 'Destinations',
|
||||||
|
'Edit a profile' => 'Modifier un profile',
|
||||||
|
'Profiles' => 'Profiles',
|
||||||
|
'Postscriptum' => 'Post-scriptum',
|
||||||
|
'Resource' => 'Ressource',
|
||||||
|
'Rights' => 'Droits',
|
||||||
|
'View' => 'Voir',
|
||||||
|
'Manage module rights' => 'Gérer les droits des modules',
|
||||||
|
'Module' => 'Module',
|
||||||
|
'Subject' => 'Sujet',
|
||||||
|
'Thelia Languages' => 'Langages Thelia',
|
||||||
|
'Languages' => 'Langages',
|
||||||
|
'Locale' => 'Locale',
|
||||||
|
'Parameters' => 'Paramètres',
|
||||||
|
'activate' => 'activer',
|
||||||
|
'deactivate' => 'désactiver',
|
||||||
|
'ISO Code' => 'Code ISO',
|
||||||
|
'en_US' => 'en_US',
|
||||||
|
'd-m-Y' => 'j-m-A',
|
||||||
|
'Delete language' => 'Supprimer langage',
|
||||||
|
'Error' => 'Erreur',
|
||||||
|
'Impossible to change default languages. Please contact your administrator or try later' => 'Impossible de changer la langue par défaut. Veuillez contacter votre administrateur ou réessayer plus tard',
|
||||||
|
'An error occured' => 'Une erreur est apparue',
|
||||||
|
'Templates' => 'Template',
|
||||||
|
'Template name' => 'Nom du template',
|
||||||
|
'Page not found' => 'Page non trouvée',
|
||||||
|
'The server returned a "404 Not Found"' => 'Le serveur à retourné l\'erreur "404 non trouvé"',
|
||||||
|
'The page you\'ve requested was not found. Please check the page address, and try again.' => 'La page que vous avez demandé n\'est pas disponible.',
|
||||||
|
'Install a new module' => 'Installer un nouveau module',
|
||||||
|
'Classic modules' => 'Module classique',
|
||||||
|
'Delivery modules' => 'Module de livraison',
|
||||||
|
'Payment modules' => 'Module de paiement',
|
||||||
|
'Delete a module' => 'Supprimer un module',
|
||||||
|
'Do you really want to delete this module ?' => 'Voulez-vous vraiment supprimer ce module ?',
|
||||||
|
'Customers list' => 'Liste des clients',
|
||||||
|
'Add a new Customer' => 'Ajouter un client',
|
||||||
|
'Last name' => 'Nom',
|
||||||
|
'First name' => 'Prénom',
|
||||||
|
'Registration date' => 'Date d\'inscription',
|
||||||
|
'Date of last order' => 'Date du dernier achat',
|
||||||
|
'Last order amount' => 'Montant du dernier achat',
|
||||||
|
'Email address' => 'Adresse e-mail',
|
||||||
|
'Create a new customer' => 'Ajouter un client',
|
||||||
|
'Create this customer' => 'Ajouter ce client',
|
||||||
|
'Delete customer' => 'Supprimer ce client',
|
||||||
|
'Do you really want to delete this customer ?' => 'Voulez-vous supprimer ce client ? ',
|
||||||
|
'Countries' => 'Pays',
|
||||||
|
'Add a new country' => 'Ajouter un pays',
|
||||||
|
'Shop' => 'Magasin',
|
||||||
|
'N° ISO' => 'N° ISO',
|
||||||
|
'Change this country' => 'Modifier ce pays',
|
||||||
|
'Delete this country' => 'Supprimer ce pays',
|
||||||
|
'No country has been created yet. Click the + button to create one.' => 'Aucun pays n\'a encore été créé. Cliquez sur le bouton + pour en créer un.',
|
||||||
|
'Country title' => 'Titre du pays',
|
||||||
|
'Alpha code 2' => 'Code alpha 2',
|
||||||
|
'Alpha code 3' => 'Code alpha 3',
|
||||||
|
'Create a new country' => 'Créer un nouveau pays',
|
||||||
|
'Create this country' => 'Créer ce pays',
|
||||||
|
'Delete country' => 'Supprimer le pays',
|
||||||
|
'Do you really want to delete this country ?' => 'Voulez-vous vraiment supprimer ce pays ?',
|
||||||
|
'Coupons' => 'Codes Promo',
|
||||||
|
'Browse' => 'Parcourir',
|
||||||
|
'List' => 'Liste',
|
||||||
|
'Enabled coupons' => 'Codes promo disponibles',
|
||||||
|
'Days before expiration' => 'Jours de validité',
|
||||||
|
'Disabled coupons' => 'Codes désactivés',
|
||||||
|
'Edit an image' => 'Modifier une image',
|
||||||
|
'Image' => 'Image',
|
||||||
|
'Editing image "%name"' => 'En cours de modification de l\'image "%name"',
|
||||||
|
'Edit image "%name"' => 'Modification de l\'image "%name"',
|
||||||
|
'Preview' => 'Aperçu',
|
||||||
|
'Add this country' => 'Ajouter ce pays',
|
||||||
|
'Remove country' => 'Supprimer le pays',
|
||||||
|
'Do you really want to remove this country ?' => 'Voulez-vous vraiment supprimer ce pays ?',
|
||||||
|
'Edit a country' => 'Modifier un pays',
|
||||||
|
'Country description' => 'Description du pays',
|
||||||
|
'Version %ver' => 'Version %ver',
|
||||||
|
'View site' => 'Voir le site',
|
||||||
|
'View shop' => 'Voir la boutique',
|
||||||
|
'Profil' => 'Profile',
|
||||||
|
'Close administation session' => 'Quitter l\'interface d\'administration',
|
||||||
|
'Logout' => 'Se déconnecter',
|
||||||
|
'All orders' => 'Toutes les commandes',
|
||||||
|
'Thelia, the open source e-commerce solution' => 'Thelia, solution e-commerce libre',
|
||||||
|
'© Thelia 2013' => '© Thelia 2013',
|
||||||
|
'Published by OpenStudio' => 'Edité par OpenStudio',
|
||||||
|
'Thelia support forum' => 'Communauté Thelia',
|
||||||
|
'Thelia contributions' => 'Contributions Thelia',
|
||||||
|
'Thelia configuration' => 'Configuration thelia',
|
||||||
|
'Product catalog configuration' => 'Configuration du catalogue produit',
|
||||||
|
'Product templates' => 'Template produit',
|
||||||
|
'System parameters' => 'Paramètres système ',
|
||||||
|
'Administration profiles' => 'Gestion des administrateurs',
|
||||||
|
'Languages & URLs' => 'Langues et URLs',
|
||||||
|
'Translations' => 'Traductions',
|
||||||
|
'Template title' => 'Titre du template',
|
||||||
|
'Delete template' => 'Supprimer le template',
|
||||||
|
'Do you really want to delete this template ? It will be removed from all products.' => 'Voulez-vous vraiment supprimer ce template ? Il sera supprimer de tous les produits',
|
||||||
|
'Translation' => 'Traduction',
|
||||||
|
'PDF templates' => 'Template du PDF',
|
||||||
|
'Thelia core' => 'Cœur de Thelia',
|
||||||
|
'Warning' => 'Attention',
|
||||||
|
'Profile code' => 'Code du profile',
|
||||||
|
'Delete profile' => 'Supprimer le profile',
|
||||||
|
'Do you really want to delete this profile ?' => 'Voulez-vous vraiment supprimer ce profile ?',
|
||||||
|
'You can\'t delete this profile' => 'Vous ne pouvez supprimer ce produit',
|
||||||
|
'Categories in %cat' => 'Catégories en $cat',
|
||||||
|
'Top level categories' => 'Catégories de niveau 1 ',
|
||||||
|
'Add a new category' => 'Ajouter une catégorie',
|
||||||
|
'Browse this category' => 'Parcourir cette catégorie',
|
||||||
|
'Delete this category and all its contents' => 'Supprimer cette catégorie et tout ce qu\'elle contient ? ',
|
||||||
|
'This category has no sub-categories. To create a new one, click the + button above.' => 'Cette catégorie n\'a pas de sous-catégorie. Pour en créer une nouvelle, cliquez sur le bouton + ci-dessus.',
|
||||||
|
'This category has no sub-categories.' => 'Cette catégorie n\'a pas de sous-catégorie.',
|
||||||
|
'Products in %cat' => 'Produits en %cat',
|
||||||
|
'Top level Products' => 'Produits mis en avant',
|
||||||
|
'Add a new product' => 'Ajouter un nouveau produit',
|
||||||
|
'Delete this product' => 'Supprimer ce produit',
|
||||||
|
'This category doesn\'t contains any products. To add a new product, <strong>click the + button</strong> above.' => 'Cette catégorie n\'a aucun produit. Pour créer un nouveau product, <strong>cliques sur le bouton +</strong> ci-dessus. ',
|
||||||
|
'Create a new category' => 'Créer une catégorie',
|
||||||
|
'Create this category' => 'Créer cette catégorie',
|
||||||
|
'Enter here the product reference' => 'Entrez ici la nouvelle référence produit',
|
||||||
|
'Enter here the product name in the default language (%title)' => 'Entrez ici le nom du produit dans la langue par défaut (%title)',
|
||||||
|
'Enter here the product price in the default currency (%title)' => 'ntrez ici le prix du produit dans la langue par défaut (%title)',
|
||||||
|
'Select here the tax applicable to this product' => 'Sélectionnez ici la taxe applicable sur ce produit',
|
||||||
|
'Enter here the product weight, in Kilogrammes' => 'Entrez ici le poids du produit, en Kilogrammes',
|
||||||
|
'Create a new product' => 'Créer un nouveau produit',
|
||||||
|
'Create this product' => 'Créer ce produit',
|
||||||
|
'Delete category' => 'Supprimer cette catégorie',
|
||||||
|
'Do you really want to delete this category and all its content ?' => 'Voulez-vous vraiment supprimer cette catégorie et tout ce qu\'elle contient ?',
|
||||||
|
'Delete product' => 'Supprimer ce produit',
|
||||||
|
'Do you really want to delete this product ?' => 'Voulez-vous vraiment supprimer ce produit ?',
|
||||||
|
'Enter new product position' => 'Classement du produit',
|
||||||
|
'Thelia Shipping zones' => 'Zones de livraison Thelia',
|
||||||
|
'Change this shipping zone' => 'Changer cette zone de livraison',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -308,9 +308,7 @@ return array (
|
|||||||
'Conclusion' => '',
|
'Conclusion' => '',
|
||||||
'A short post-description information' => '',
|
'A short post-description information' => '',
|
||||||
'Short conclusion' => '',
|
'Short conclusion' => '',
|
||||||
'Rewriten URL *' => '',
|
|
||||||
'Rewritten URL' => '',
|
'Rewritten URL' => '',
|
||||||
'Rewriten URL' => '',
|
|
||||||
'Parent category *' => '',
|
'Parent category *' => '',
|
||||||
'Top level' => '',
|
'Top level' => '',
|
||||||
'Visibility' => '',
|
'Visibility' => '',
|
||||||
|
|||||||
0
templates/backOffice/default/admin-layout.tpl
Normal file → Executable file
0
templates/backOffice/default/administrators.html
Normal file → Executable file
0
templates/backOffice/default/ajax/language-update-modal.html
Normal file → Executable file
0
templates/backOffice/default/ajax/logger.html
Normal file → Executable file
0
templates/backOffice/default/ajax/product-attributes-tab.html
Normal file → Executable file
0
templates/backOffice/default/ajax/product-related-tab.html
Normal file → Executable file
0
templates/backOffice/default/ajax/template-attribute-list.html
Normal file → Executable file
0
templates/backOffice/default/ajax/template-feature-list.html
Normal file → Executable file
0
templates/backOffice/default/assets/img/ajax-loader.gif
Normal file → Executable file
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
0
templates/backOffice/default/assets/img/bg.jpg
Normal file → Executable file
|
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 49 KiB |
0
templates/backOffice/default/assets/img/deconnexion.png
Normal file → Executable file
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
0
templates/backOffice/default/assets/img/header.jpg
Normal file → Executable file
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
0
templates/backOffice/default/assets/img/logo-light.png
Normal file → Executable file
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
0
templates/backOffice/default/assets/img/logo.png
Normal file → Executable file
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
0
templates/backOffice/default/assets/img/top-bar-logo-save.png
Normal file → Executable file
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
0
templates/backOffice/default/assets/img/top-bar-logo.png
Normal file → Executable file
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.1 KiB |
0
templates/backOffice/default/assets/img/top.jpg
Normal file → Executable file
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |