diff --git a/core/lib/Thelia/Action/Coupon.php b/core/lib/Thelia/Action/Coupon.php
index b3086c266..e3a8defbf 100755
--- a/core/lib/Thelia/Action/Coupon.php
+++ b/core/lib/Thelia/Action/Coupon.php
@@ -35,6 +35,7 @@ use Thelia\Coupon\CouponManager;
use Thelia\Coupon\ConditionCollection;
use Thelia\Coupon\Type\CouponInterface;
use Thelia\Model\Coupon as CouponModel;
+use Thelia\Model\CouponQuery;
/**
* Created by JetBrains PhpStorm.
@@ -68,7 +69,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
*/
public function update(CouponCreateOrUpdateEvent $event)
{
- $coupon = $event->getCoupon();
+ $coupon = $event->getCouponModel();
$this->createOrUpdate($coupon, $event);
}
@@ -76,13 +77,13 @@ class Coupon extends BaseAction implements EventSubscriberInterface
/**
* Occurring when a Coupon condition is about to be updated
*
- * @param CouponCreateOrUpdateEvent $event Event creation or update Coupon Rule
+ * @param CouponCreateOrUpdateEvent $event Event creation or update Coupon condition
*/
public function updateCondition(CouponCreateOrUpdateEvent $event)
{
- $coupon = $event->getCoupon();
+ $modelCoupon = $event->getCouponModel();
- $this->createOrUpdateCondition($coupon, $event);
+ $this->createOrUpdateCondition($modelCoupon, $event);
}
/**
@@ -104,6 +105,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
$coupon = $couponFactory->buildCouponFromCode($event->getCode());
$isValid = $coupon->isMatching();
+
if ($isValid) {
/** @var Request $request */
$request = $this->container->get('request');
@@ -119,8 +121,15 @@ class Coupon extends BaseAction implements EventSubscriberInterface
$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
+ $couponQuery = CouponQuery::create();
+ $couponModel = $couponQuery->findOneByCode($coupon->getCode());
+ $couponManager->decrementeQuantity($couponModel);
+
+ $request->getSession()->getCart()->setDiscount($totalDiscount);
- // @todo modify Cart total discount
}
$event->setIsValid($isValid);
@@ -153,7 +162,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
$event->getCode(),
$event->getTitle(),
$event->getAmount(),
- $event->getType(),
+ $event->getServiceId(),
$event->isRemovingPostage(),
$event->getShortDescription(),
$event->getDescription(),
@@ -166,7 +175,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
$event->getLocale()
);
- $event->setCoupon($coupon);
+ $event->setCouponModel($coupon);
}
/**
@@ -188,7 +197,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
$event->getLocale()
);
- $event->setCoupon($coupon);
+ $event->setCouponModel($coupon);
}
/**
diff --git a/core/lib/Thelia/Condition/ConditionFactory.php b/core/lib/Thelia/Condition/ConditionFactory.php
index ff024ecae..3e1c771ee 100644
--- a/core/lib/Thelia/Condition/ConditionFactory.php
+++ b/core/lib/Thelia/Condition/ConditionFactory.php
@@ -24,7 +24,7 @@
namespace Thelia\Condition;
use Symfony\Component\DependencyInjection\ContainerInterface;
-use Thelia\Coupon\AdapterInterface;
+use Thelia\Coupon\FacadeInterface;
use Thelia\Coupon\ConditionCollection;
@@ -44,7 +44,7 @@ class ConditionFactory
/** @var ContainerInterface Service Container */
protected $container = null;
- /** @var AdapterInterface Provide necessary value from Thelia */
+ /** @var FacadeInterface Provide necessary value from Thelia */
protected $adapter;
/** @var array ConditionCollection to process*/
@@ -82,10 +82,6 @@ class ConditionFactory
if ($conditions !== null) {
/** @var $condition ConditionManagerInterface */
foreach ($conditions as $condition) {
- // Remove all condition if the "no condition" condition is found
-// if ($condition->getServiceId() == 'thelia.condition.match_for_everyone') {
-// return base64_encode(json_encode(array($condition->getSerializableRule())));
-// }
$serializableConditions[] = $condition->getSerializableCondition();
}
}
diff --git a/core/lib/Thelia/Condition/ConditionManagerAbstract.php b/core/lib/Thelia/Condition/ConditionManagerAbstract.php
index e5c8aed1a..bf38ef387 100644
--- a/core/lib/Thelia/Condition/ConditionManagerAbstract.php
+++ b/core/lib/Thelia/Condition/ConditionManagerAbstract.php
@@ -25,7 +25,7 @@ namespace Thelia\Condition;
use Symfony\Component\Intl\Exception\NotImplementedException;
use Thelia\Core\Translation\Translator;
-use Thelia\Coupon\AdapterInterface;
+use Thelia\Coupon\FacadeInterface;
use Thelia\Exception\InvalidConditionValueException;
use Thelia\Model\Currency;
use Thelia\Type\FloatType;
@@ -43,10 +43,6 @@ use Thelia\Type\FloatType;
*/
abstract class ConditionManagerAbstract implements ConditionManagerInterface
{
-// /** Operator key in $validators */
-// CONST OPERATOR = 'operator';
-// /** Value key in $validators */
-// CONST VALUE = 'value';
/** @var string Service Id from Resources/config.xml */
protected $serviceId = null;
@@ -57,10 +53,7 @@ abstract class ConditionManagerAbstract implements ConditionManagerInterface
/** @var array Parameters validating parameters against */
protected $validators = array();
-// /** @var array Parameters to be validated */
-// protected $paramsToValidate = array();
-
- /** @var AdapterInterface Provide necessary value from Thelia */
+ /** @var FacadeInterface Provide necessary value from Thelia */
protected $adapter = null;
/** @var Translator Service Translator */
@@ -78,71 +71,15 @@ abstract class ConditionManagerAbstract implements ConditionManagerInterface
/**
* Constructor
*
- * @param AdapterInterface $adapter Service adapter
+ * @param FacadeInterface $adapter Service adapter
*/
- public function __construct(AdapterInterface $adapter)
+ public function __construct(FacadeInterface $adapter)
{
$this->adapter = $adapter;
$this->translator = $adapter->getTranslator();
$this->conditionValidator = $adapter->getConditionEvaluator();
}
-// /**
-// * Check validator relevancy and store them
-// *
-// * @param array $validators Array of RuleValidator
-// * validating $paramsToValidate against
-// *
-// * @return $this
-// * @throws InvalidConditionException
-// */
-// protected function setValidators(array $validators)
-// {
-// foreach ($validators as $validator) {
-// if (!$validator instanceof RuleValidator) {
-// throw new InvalidConditionException(get_class());
-// }
-// if (!in_array($validator->getOperator(), $this->availableOperators)) {
-// throw new InvalidConditionOperatorException(
-// get_class(),
-// $validator->getOperator()
-// );
-// }
-// }
-// $this->validators = $validators;
-//
-// return $this;
-// }
-
-
-
-// /**
-// * Check if the current Checkout matches this condition
-// *
-// * @return bool
-// */
-// public function isMatching()
-// {
-// $this->checkBackOfficeInput();
-// $this->checkCheckoutInput();
-//
-// $isMatching = true;
-// /** @var $validator RuleValidator*/
-// foreach ($this->validators as $param => $validator) {
-// $a = $this->paramsToValidate[$param];
-// $operator = $validator->getOperator();
-// /** @var ComparableInterface, RuleParameterAbstract $b */
-// $b = $validator->getParam();
-//
-// if (!Operators::isValid($a, $operator, $b)) {
-// $isMatching = false;
-// }
-// }
-//
-// return $isMatching;
-//
-// }
-
/**
* Return all available Operators for this Condition
*
@@ -153,37 +90,6 @@ abstract class ConditionManagerAbstract implements ConditionManagerInterface
return $this->availableOperators;
}
-// /**
-// * Check if Operators set for this Rule in the BackOffice are legit
-// *
-// * @throws InvalidConditionOperatorException if Operator is not allowed
-// * @return bool
-// */
-// protected function checkBackOfficeInputsOperators()
-// {
-// /** @var RuleValidator $param */
-// foreach ($this->validators as $key => $param) {
-// $operator = $param->getOperator();
-// if (!isset($operator)
-// ||!in_array($operator, $this->availableOperators)
-// ) {
-// throw new InvalidConditionOperatorException(get_class(), $key);
-// }
-// }
-// return true;
-// }
-
-// /**
-// * Generate current Rule param to be validated from adapter
-// *
-// * @throws \Thelia\Exception\NotImplementedException
-// * @return $this
-// */
-// protected function setParametersToValidate()
-// {
-// throw new \Thelia\Exception\NotImplementedException();
-// }
-
/**
* Return all validators
*
diff --git a/core/lib/Thelia/Condition/ConditionManagerInterface.php b/core/lib/Thelia/Condition/ConditionManagerInterface.php
index 0e7fc99b1..ceda090bf 100644
--- a/core/lib/Thelia/Condition/ConditionManagerInterface.php
+++ b/core/lib/Thelia/Condition/ConditionManagerInterface.php
@@ -24,7 +24,7 @@
namespace Thelia\Condition;
use Thelia\Core\Translation\Translator;
-use Thelia\Coupon\AdapterInterface;
+use Thelia\Coupon\FacadeInterface;
/**
* Created by JetBrains PhpStorm.
@@ -42,9 +42,9 @@ interface ConditionManagerInterface
/**
* Constructor
*
- * @param AdapterInterface $adapter Service adapter
+ * @param FacadeInterface $adapter Service adapter
*/
- function __construct(AdapterInterface $adapter);
+ function __construct(FacadeInterface $adapter);
/**
* Get Rule Service id
@@ -53,20 +53,6 @@ interface ConditionManagerInterface
*/
public function getServiceId();
-// /**
-// * Check if backoffice inputs are relevant or not
-// *
-// * @return bool
-// */
-// public function checkBackOfficeInput();
-
-// /**
-// * Check if Checkout inputs are relevant or not
-// *
-// * @return bool
-// */
-// public function checkCheckoutInput();
-
/**
* Check validators relevancy and store them
*
@@ -78,13 +64,6 @@ interface ConditionManagerInterface
*/
public function setValidatorsFromForm(array $operators, array $values);
-// /**
-// * Check if the current Checkout matches this condition
-// *
-// * @return bool
-// */
-// public function isMatching();
-
/**
* Test if the current application state matches conditions
*
@@ -121,17 +100,6 @@ interface ConditionManagerInterface
*/
public function getValidators();
-// /**
-// * Populate a Condition from a form admin
-// *
-// * @param array $operators Condition Operator set by the Admin
-// * @param array $values Condition Values set by the Admin
-// *
-// * @return bool
-// */
-// public function populateFromForm(array$operators, array $values);
-
-
/**
* Return a serializable Condition
*
diff --git a/core/lib/Thelia/Condition/SerializableCondition.php b/core/lib/Thelia/Condition/SerializableCondition.php
index 426052506..31163cdda 100644
--- a/core/lib/Thelia/Condition/SerializableCondition.php
+++ b/core/lib/Thelia/Condition/SerializableCondition.php
@@ -45,33 +45,4 @@ class SerializableCondition
/** @var array Values set by Admin for this Condition */
public $values = array();
-// /**
-// * Get Operators set by Admin for this Condition
-// *
-// * @return array
-// */
-// public function getOperators()
-// {
-// return $this->operators;
-// }
-//
-// /**
-// * Get Condition Service id
-// *
-// * @return string
-// */
-// public function getConditionServiceId()
-// {
-// return $this->conditionServiceId;
-// }
-//
-// /**
-// * Get Values set by Admin for this Condition
-// *
-// * @return array
-// */
-// public function getValues()
-// {
-// return $this->values;
-// }
}
diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml
index 9e7d86c3d..e04ae7a92 100755
--- a/core/lib/Thelia/Config/Resources/config.xml
+++ b/core/lib/Thelia/Config/Resources/config.xml
@@ -97,6 +97,8 @@
+
+
@@ -307,7 +309,7 @@
-
+
diff --git a/core/lib/Thelia/Config/Resources/routing/front.xml b/core/lib/Thelia/Config/Resources/routing/front.xml
index 3e0c39939..69127d6fc 100755
--- a/core/lib/Thelia/Config/Resources/routing/front.xml
+++ b/core/lib/Thelia/Config/Resources/routing/front.xml
@@ -154,6 +154,11 @@
order-invoice
+
+ Thelia\Controller\Front\CouponController::consumeAction
+ order-invoice
+
+
Thelia\Controller\Front\OrderController::pay
diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php
index 3d5b2d72f..59ef312d5 100755
--- a/core/lib/Thelia/Controller/Admin/CouponController.php
+++ b/core/lib/Thelia/Controller/Admin/CouponController.php
@@ -28,8 +28,6 @@ use Symfony\Component\Routing\Router;
use Thelia\Condition\ConditionFactory;
use Thelia\Condition\ConditionManagerInterface;
use Thelia\Core\Security\Resource\AdminResources;
-use Thelia\Core\Event\Condition\ConditionCreateOrUpdateEvent;
-use Thelia\Core\Event\Coupon\CouponConsumeEvent;
use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Security\AccessManager;
@@ -209,10 +207,7 @@ class CouponController extends BaseAdminController
$conditions = $conditionFactory->unserializeConditionCollection(
$coupon->getSerializedConditions()
);
-var_dump($coupon->getIsEnabled());;
-var_dump($coupon->getIsAvailableOnSpecialOffers());;
-var_dump($coupon->getIsCumulative());;
-var_dump($coupon->getIsRemovingPostage());;
+
$data = array(
'code' => $coupon->getCode(),
'title' => $coupon->getTitle(),
@@ -220,11 +215,11 @@ var_dump($coupon->getIsRemovingPostage());;
'type' => $coupon->getType(),
'shortDescription' => $coupon->getShortDescription(),
'description' => $coupon->getDescription(),
- 'isEnabled' => ($coupon->getIsEnabled() == 1),
+ 'isEnabled' => $coupon->getIsEnabled(),
'expirationDate' => $coupon->getExpirationDate('Y-m-d'),
- 'isAvailableOnSpecialOffers' => ($coupon->getIsAvailableOnSpecialOffers() == 1),
- 'isCumulative' => ($coupon->getIsCumulative() == 1),
- 'isRemovingPostage' => ($coupon->getIsRemovingPostage() == 1),
+ 'isAvailableOnSpecialOffers' => $coupon->getIsAvailableOnSpecialOffers(),
+ 'isCumulative' => $coupon->getIsCumulative(),
+ 'isRemovingPostage' => $coupon->getIsRemovingPostage(),
'maxUsage' => $coupon->getMaxUsage(),
'conditions' => $conditions,
'locale' => $coupon->getLocale(),
@@ -265,7 +260,7 @@ var_dump($coupon->getIsRemovingPostage());;
Router::ABSOLUTE_URL
);
- $args['formAction'] = 'admin/coupon/update' . $couponId;
+ $args['formAction'] = 'admin/coupon/update/' . $couponId;
return $this->render('coupon-update', $args);
}
@@ -335,27 +330,36 @@ var_dump($coupon->getIsRemovingPostage());;
$conditions->add(clone $condition);
}
-// $coupon->setSerializedConditions(
-// $conditionFactory->serializeCouponConditionCollection($conditions)
-// );
-
- $conditionEvent = new ConditionCreateOrUpdateEvent(
- $conditions
+ $couponEvent = new CouponCreateOrUpdateEvent(
+ $coupon->getCode(),
+ $coupon->getTitle(),
+ $coupon->getAmount(),
+ $coupon->getType(),
+ $coupon->getShortDescription(),
+ $coupon->getDescription(),
+ $coupon->getIsEnabled(),
+ $coupon->getExpirationDate(),
+ $coupon->getIsAvailableOnSpecialOffers(),
+ $coupon->getIsCumulative(),
+ $coupon->getIsRemovingPostage(),
+ $coupon->getMaxUsage(),
+ $coupon->getLocale()
);
- $conditionEvent->setCouponModel($coupon);
+ $couponEvent->setCouponModel($coupon);
+ $couponEvent->setConditions($conditions);
$eventToDispatch = TheliaEvents::COUPON_CONDITION_UPDATE;
// Dispatch Event to the Action
$this->dispatch(
$eventToDispatch,
- $conditionEvent
+ $couponEvent
);
$this->adminLogAppend(
sprintf(
'Coupon %s (ID %s) conditions updated',
- $conditionEvent->getCouponModel()->getTitle(),
- $conditionEvent->getCouponModel()->getServiceId()
+ $couponEvent->getCouponModel()->getTitle(),
+ $couponEvent->getCouponModel()->getType()
)
);
@@ -372,31 +376,6 @@ var_dump($coupon->getIsRemovingPostage());;
);
}
- /**
- * Test Coupon consuming
- *
- * @param string $couponCode Coupon code
- *
- * @todo remove (event dispatcher testing purpose)
- *
- */
- public function consumeAction($couponCode)
- {
- // @todo remove (event dispatcher testing purpose)
- $couponConsumeEvent = new CouponConsumeEvent($couponCode);
- $eventToDispatch = TheliaEvents::COUPON_CONSUME;
-
- // Dispatch Event to the Action
- $this->dispatch(
- $eventToDispatch,
- $couponConsumeEvent
- );
-
- var_dump('test', $couponConsumeEvent->getCode(), $couponConsumeEvent->getDiscount(), $couponConsumeEvent->getIsValid());
-
- exit();
- }
-
/**
* Build a Coupon from its form
*
@@ -492,14 +471,14 @@ var_dump($coupon->getIsRemovingPostage());;
sprintf(
'Coupon %s (ID ) ' . $log,
$couponEvent->getTitle(),
- $couponEvent->getCoupon()->getId()
+ $couponEvent->getCouponModel()->getId()
)
);
$this->redirect(
str_replace(
'{id}',
- $couponEvent->getCoupon()->getId(),
+ $couponEvent->getCouponModel()->getId(),
$creationForm->getSuccessUrl()
)
);
@@ -591,26 +570,4 @@ var_dump($coupon->getIsRemovingPostage());;
return $cleanedConditions;
}
-// /**
-// * Validation Condition creation
-// *
-// * @param string $type Condition class type
-// * @param string $operator Condition operator (<, >, =, etc)
-// * @param array $values Condition values
-// *
-// * @return bool
-// */
-// protected function validateConditionsCreation($type, $operator, $values)
-// {
-// /** @var AdapterInterface $adapter */
-// $adapter = $this->container->get('thelia.adapter');
-// $validator = new PriceParam()
-// try {
-// $condition = new AvailableForTotalAmount($adapter, $validators);
-// $condition = new $type($adapter, $validators);
-// } catch (\Exception $e) {
-// return false;
-// }
-// }
-
}
diff --git a/core/lib/Thelia/Controller/Front/CouponController.php b/core/lib/Thelia/Controller/Front/CouponController.php
new file mode 100755
index 000000000..dd0e6d722
--- /dev/null
+++ b/core/lib/Thelia/Controller/Front/CouponController.php
@@ -0,0 +1,95 @@
+. */
+/* */
+/*************************************************************************************/
+namespace Thelia\Controller\Front;
+
+use Propel\Runtime\Exception\PropelException;
+use Thelia\Core\Event\Coupon\CouponConsumeEvent;
+use Thelia\Exception\TheliaProcessException;
+use Thelia\Form\CouponCode;
+use Thelia\Form\Exception\FormValidationException;
+use Thelia\Core\Event\Order\OrderEvent;
+use Thelia\Core\Event\TheliaEvents;
+use Symfony\Component\HttpFoundation\Request;
+use Thelia\Form\OrderDelivery;
+use Thelia\Form\OrderPayment;
+use Thelia\Log\Tlog;
+use Thelia\Model\AddressQuery;
+use Thelia\Model\AreaDeliveryModuleQuery;
+use Thelia\Model\Base\OrderQuery;
+use Thelia\Model\ModuleQuery;
+use Thelia\Model\Order;
+use Thelia\Tools\URL;
+
+/**
+ * Class CouponController
+ * @package Thelia\Controller\Front
+ * @author Guillaume MOREL
+ */
+class CouponController extends BaseFrontController
+{
+
+ /**
+ * Test Coupon consuming
+ */
+ public function consumeAction()
+ {
+ $this->checkAuth();
+ $this->checkCartNotEmpty();
+
+ $message = false;
+ $couponCodeForm = new CouponCode($this->getRequest());
+
+ try {
+ $form = $this->validateForm($couponCodeForm, 'post');
+
+ $couponCode = $form->get('coupon-code')->getData();
+
+ if (null === $couponCode || empty($couponCode)) {
+ $message = true;
+ throw new \Exception('Coupon code can\'t be empty');
+ }
+
+ $couponConsumeEvent = new CouponConsumeEvent($couponCode);
+
+ // Dispatch Event to the Action
+ $this->getDispatcher()->dispatch(TheliaEvents::COUPON_CONSUME, $couponConsumeEvent);
+
+ } catch (FormValidationException $e) {
+ $message = sprintf('Please check your coupon code: %s', $e->getMessage());
+ } catch (PropelException $e) {
+ $this->getParserContext()->setGeneralError($e->getMessage());
+ } catch (\Exception $e) {
+ $message = sprintf('Sorry, an error occurred: %s', $e->getMessage());
+ }
+
+ if ($message !== false) {
+ Tlog::getInstance()->error(sprintf("Error during order delivery process : %s. Exception was %s", $message, $e->getMessage()));
+
+ $couponCodeForm->setErrorMessage($message);
+
+ $this->getParserContext()
+ ->addForm($couponCodeForm)
+ ->setGeneralError($message);
+ }
+ }
+}
diff --git a/core/lib/Thelia/Core/Bundle/TheliaBundle.php b/core/lib/Thelia/Core/Bundle/TheliaBundle.php
index a9704b350..dcdcdd5d2 100755
--- a/core/lib/Thelia/Core/Bundle/TheliaBundle.php
+++ b/core/lib/Thelia/Core/Bundle/TheliaBundle.php
@@ -30,7 +30,7 @@ use Thelia\Core\DependencyInjection\Compiler\RegisterCouponPass;
use Thelia\Core\DependencyInjection\Compiler\RegisterListenersPass;
use Thelia\Core\DependencyInjection\Compiler\RegisterParserPluginPass;
use Thelia\Core\DependencyInjection\Compiler\RegisterRouterPass;
-use Thelia\Core\DependencyInjection\Compiler\RegisterRulePass;
+use Thelia\Core\DependencyInjection\Compiler\RegisterCouponConditionPass;
/**
* First Bundle use in Thelia
@@ -63,8 +63,6 @@ class TheliaBundle extends Bundle
->addCompilerPass(new RegisterParserPluginPass())
->addCompilerPass(new RegisterRouterPass())
->addCompilerPass(new RegisterCouponPass())
- ->addCompilerPass(new RegisterRulePass())
- ;
-
+ ->addCompilerPass(new RegisterCouponConditionPass());
}
}
diff --git a/core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterRulePass.php b/core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterCouponConditionPass.php
similarity index 92%
rename from core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterRulePass.php
rename to core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterCouponConditionPass.php
index dcc54cf8e..7caf79c5e 100755
--- a/core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterRulePass.php
+++ b/core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterCouponConditionPass.php
@@ -35,11 +35,13 @@ use Symfony\Component\DependencyInjection\Reference;
* Class RegisterListenersPass
* Source code come from Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RegisterKernelListenersPass class
*
+ * Register all available Conditions for the coupon module
+ *
* @package Thelia\Core\DependencyInjection\Compiler
* @author Guillaume MOREL
*
*/
-class RegisterRulePass implements CompilerPassInterface
+class RegisterCouponConditionPass implements CompilerPassInterface
{
/**
* You can modify the container here before it is dumped to PHP code.
@@ -55,11 +57,11 @@ class RegisterRulePass implements CompilerPassInterface
}
$couponManager = $container->getDefinition('thelia.coupon.manager');
- $services = $container->findTaggedServiceIds("thelia.coupon.addRule");
+ $services = $container->findTaggedServiceIds("thelia.coupon.addCondition");
- foreach ($services as $id => $rule) {
+ foreach ($services as $id => $condition) {
$couponManager->addMethodCall(
- 'addAvailableRule',
+ 'addAvailableCondition',
array(
new Reference($id)
)
diff --git a/core/lib/Thelia/Core/Event/Condition/ConditionCreateOrUpdateEvent.php b/core/lib/Thelia/Core/Event/Condition/ConditionCreateOrUpdateEvent.php
deleted file mode 100644
index 58fdb10fe..000000000
--- a/core/lib/Thelia/Core/Event/Condition/ConditionCreateOrUpdateEvent.php
+++ /dev/null
@@ -1,106 +0,0 @@
-. */
-/* */
-/**********************************************************************************/
-
-namespace Thelia\Core\Event\Condition;
-
-use Thelia\Core\Event\ActionEvent;
-use Thelia\Coupon\ConditionCollection;
-use Thelia\Coupon\Type\CouponInterface;
-
-/**
- * Created by JetBrains PhpStorm.
- * Date: 8/29/13
- * Time: 3:45 PM
- *
- * Occurring when a Condition is created or updated
- *
- * @package Coupon
- * @author Guillaume MOREL
- *
- */
-class ConditionCreateOrUpdateEvent extends ActionEvent
-{
- /** @var ConditionCollection Array of ConditionManagerInterface */
- protected $conditions = null;
-
- /** @var CouponInterface Coupon model associated with this conditions */
- protected $couponModel = null;
-
- /**
- * Constructor
- *
- * @param ConditionCollection $conditions Array of ConditionManagerInterface
- */
- public function __construct(ConditionCollection $conditions)
- {
- $this->conditions = $conditions;
- }
-
- /**
- * Get Conditions
- *
- * @return null|ConditionCollection Array of ConditionManagerInterface
- */
- public function getConditions()
- {
- return $this->conditions;
- }
-
- /**
- * Set Conditions
- *
- * @param ConditionCollection $conditions Array of ConditionManagerInterface
- *
- * @return $this
- */
- public function setConditions(ConditionCollection $conditions)
- {
- $this->conditions = $conditions;
-
- return $this;
- }
-
- /**
- * Set Coupon Model associated to this condition
- *
- * @param CouponInterface $couponModel Coupon Model
- *
- * @return $this
- */
- public function setCouponModel($couponModel)
- {
- $this->couponModel = $couponModel;
-
- return $this;
- }
-
- /**
- * Get Coupon Model associated to this condition
- *
- * @return null|CouponInterface
- */
- public function getCouponModel()
- {
- return $this->couponModel;
- }
-}
diff --git a/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php b/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php
index 3dfca3d4a..f890fd8cd 100644
--- a/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php
+++ b/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php
@@ -31,7 +31,7 @@ use Thelia\Model\Coupon;
* Date: 8/29/13
* Time: 3:45 PM
*
- * Occurring when a Coupon is created
+ * Occurring when a Coupon is created or updated
*
* @package Coupon
* @author Guillaume MOREL
@@ -76,10 +76,10 @@ class CouponCreateOrUpdateEvent extends ActionEvent
protected $isAvailableOnSpecialOffers = false;
/** @var Coupon Coupon model */
- protected $coupon = null;
+ protected $couponModel = null;
- /** @var string Coupon type */
- protected $type;
+ /** @var string Coupon Service id */
+ protected $serviceId;
/** @var string Language code ISO (ex: fr_FR) */
protected $locale = null;
@@ -90,7 +90,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent
* @param string $code Coupon Code
* @param string $title Coupon title
* @param float $amount Amount removed from the Total Checkout
- * @param string $type Coupon type
+ * @param string $serviceId Coupon Service id
* @param string $shortDescription Coupon short description
* @param string $description Coupon description
* @param bool $isEnabled Enable/Disable
@@ -102,7 +102,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent
* @param string $locale Coupon Language code ISO (ex: fr_FR)
*/
public function __construct(
- $code, $title, $amount, $type, $shortDescription, $description, $isEnabled, \DateTime $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $isRemovingPostage, $maxUsage, $locale
+ $code, $title, $amount, $serviceId, $shortDescription, $description, $isEnabled, \DateTime $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $isRemovingPostage, $maxUsage, $locale
)
{
$this->amount = $amount;
@@ -116,7 +116,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent
$this->maxUsage = $maxUsage;
$this->shortDescription = $shortDescription;
$this->title = $title;
- $this->type = $type;
+ $this->serviceId = $serviceId;
$this->locale = $locale;
}
@@ -234,13 +234,13 @@ class CouponCreateOrUpdateEvent extends ActionEvent
}
/**
- * Get Coupon type (effect)
+ * Get Coupon Service id (Type)
*
* @return string
*/
- public function getType()
+ public function getServiceId()
{
- return $this->type;
+ return $this->serviceId;
}
/**
@@ -256,13 +256,13 @@ class CouponCreateOrUpdateEvent extends ActionEvent
/**
* Set Coupon Model
*
- * @param \Thelia\Model\Coupon $coupon Coupon Model
+ * @param Coupon $couponModel Coupon Model
*
* @return $this
*/
- public function setCoupon($coupon)
+ public function setCouponModel(Coupon $couponModel)
{
- $this->coupon = $coupon;
+ $this->couponModel = $couponModel;
return $this;
}
@@ -272,13 +272,13 @@ class CouponCreateOrUpdateEvent extends ActionEvent
*
* @return \Thelia\Model\Coupon
*/
- public function getCoupon()
+ public function getCouponModel()
{
- return $this->coupon;
+ return $this->couponModel;
}
/**
- * Get Rules
+ * Get Conditions
*
* @return null|ConditionCollection Array of ConditionManagerInterface
*/
@@ -288,15 +288,15 @@ class CouponCreateOrUpdateEvent extends ActionEvent
}
/**
- * set Rules
+ * Set Conditions
*
- * @param ConditionCollection $rules Array of ConditionManagerInterface
+ * @param ConditionCollection $conditions Array of ConditionManagerInterface
*
* @return $this
*/
- public function setConditions(ConditionCollection $rules)
+ public function setConditions(ConditionCollection $conditions)
{
- $this->conditions = $rules;
+ $this->conditions = $conditions;
return $this;
}
diff --git a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php
index 09b932a98..b35bd4a13 100755
--- a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php
+++ b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php
@@ -70,6 +70,13 @@ class Session extends BaseSession
$this->set("thelia.current.currency", $currency);
}
+ /**
+ * Return current currency
+ *
+ * @param bool $forceDefault If default currency forced
+ *
+ * @return Currency
+ */
public function getCurrency($forceDefault = true)
{
$currency = $this->get("thelia.current.currency");
diff --git a/core/lib/Thelia/Coupon/BaseAdapter.php b/core/lib/Thelia/Coupon/BaseFacade.php
similarity index 78%
rename from core/lib/Thelia/Coupon/BaseAdapter.php
rename to core/lib/Thelia/Coupon/BaseFacade.php
index 883758ce1..9d28be69f 100644
--- a/core/lib/Thelia/Coupon/BaseAdapter.php
+++ b/core/lib/Thelia/Coupon/BaseFacade.php
@@ -27,8 +27,8 @@ use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\TranslatorInterface;
+use Thelia\Condition\ConditionEvaluator;
use Thelia\Core\HttpFoundation\Request;
-use Thelia\Coupon\Type\CouponInterface;
use Thelia\Model\Coupon;
use Thelia\Model\CouponQuery;
use Thelia\Cart\CartTrait;
@@ -44,10 +44,9 @@ use Thelia\Model\CurrencyQuery;
*
* @package Coupon
* @author Guillaume MOREL
- * @todo implements
*
*/
-class BaseAdapter implements AdapterInterface
+class BaseFacade implements FacadeInterface
{
use CartTrait {
CartTrait::getCart as getCartFromTrait;
@@ -86,7 +85,7 @@ class BaseAdapter implements AdapterInterface
*/
public function getDeliveryAddress()
{
- // TODO: Implement getDeliveryAddress() method.
+ // @todo: Implement getDeliveryAddress() method.
}
/**
@@ -106,7 +105,7 @@ class BaseAdapter implements AdapterInterface
*/
public function getCheckoutTotalPrice()
{
- // TODO: Implement getCheckoutTotalPrice() method.
+ return $this->getRequest()->getSession()->getOrder()->getTotalAmount();
}
/**
@@ -116,7 +115,7 @@ class BaseAdapter implements AdapterInterface
*/
public function getCheckoutPostagePrice()
{
- // TODO: Implement getCheckoutPostagePrice() method.
+ return $this->getRequest()->getSession()->getOrder()->getPostage();
}
/**
@@ -126,7 +125,8 @@ class BaseAdapter implements AdapterInterface
*/
public function getCartTotalPrice()
{
- // TODO: Implement getCartTotalPrice() method.
+ return $this->getRequest()->getSession()->getCart()->getTotalAmount();
+
}
/**
@@ -136,7 +136,7 @@ class BaseAdapter implements AdapterInterface
*/
public function getCheckoutCurrency()
{
- $this->getRequest()->getSession()->getCurrency();
+ return $this->getRequest()->getSession()->getCurrency()->getCode();
}
@@ -147,7 +147,7 @@ class BaseAdapter implements AdapterInterface
*/
public function getNbArticlesInCart()
{
- // TODO: Implement getNbArticlesInCart() method.
+ return count($this->getRequest()->getSession()->getCart()->getCartItems());
}
/**
@@ -157,16 +157,13 @@ class BaseAdapter implements AdapterInterface
*/
public function getCurrentCoupons()
{
- // @todo implement
-// $consumedCoupons = $this->getRequest()->getSession()->getConsumedCoupons();
- // @todo convert coupon code to coupon Interface
-
+ $couponCodes = $this->getRequest()->getSession()->getConsumedCoupons();
+ if (null === $couponCodes) {
+ return array();
+ }
$couponFactory = $this->container->get('thelia.coupon.factory');
- // @todo get from cart
- $couponCodes = array('XMAS', 'SPRINGBREAK');
-
$coupons = array();
foreach ($couponCodes as $couponCode) {
$coupons[] = $couponFactory->buildCouponFromCode($couponCode);
@@ -190,34 +187,7 @@ class BaseAdapter implements AdapterInterface
}
/**
- * Save a Coupon in the database
- *
- * @param CouponInterface $coupon Coupon
- *
- * @return $this
- */
- public function saveCoupon(CouponInterface $coupon)
- {
-// $couponModel = new Coupon();
-// $couponModel->setCode($coupon->getCode());
-// $couponModel->setType(get_class($coupon));
-// $couponModel->setTitle($coupon->getTitle());
-// $couponModel->setShortDescription($coupon->getShortDescription());
-// $couponModel->setDescription($coupon->getDescription());
-// $couponModel->setAmount($coupon->getDiscount());
-// $couponModel->setIsUsed(0);
-// $couponModel->setIsEnabled(1);
-// $couponModel->set
-// $couponModel->set
-// $couponModel->set
-// $couponModel->set
-// $couponModel->set
-// $couponModel->set
-// $couponModel->set
- }
-
- /**
- * Return plateform Container
+ * Return platform Container
*
* @return Container
*/
@@ -245,7 +215,7 @@ class BaseAdapter implements AdapterInterface
*/
public function getMainCurrency()
{
- // TODO: Implement getMainCurrency() method.
+ return $this->getRequest()->getSession()->getCurrency();
}
/**
@@ -261,7 +231,7 @@ class BaseAdapter implements AdapterInterface
/**
* Return Constraint Validator
*
- * @return ConditionValidator
+ * @return ConditionEvaluator
*/
public function getConditionEvaluator()
{
diff --git a/core/lib/Thelia/Coupon/ConditionCollection.php b/core/lib/Thelia/Coupon/ConditionCollection.php
index 21e694aef..f9513160b 100644
--- a/core/lib/Thelia/Coupon/ConditionCollection.php
+++ b/core/lib/Thelia/Coupon/ConditionCollection.php
@@ -25,8 +25,6 @@ namespace Thelia\Coupon;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Thelia\Condition\ConditionManagerInterface;
-use Thelia\Constraint\Rule\CouponRuleInterface;
-use Thelia\Constraint\Rule\SerializableRule;
/**
* Created by JetBrains PhpStorm.
diff --git a/core/lib/Thelia/Coupon/CouponFactory.php b/core/lib/Thelia/Coupon/CouponFactory.php
index 102d1a74c..603fcaa77 100644
--- a/core/lib/Thelia/Coupon/CouponFactory.php
+++ b/core/lib/Thelia/Coupon/CouponFactory.php
@@ -47,7 +47,7 @@ class CouponFactory
/** @var ContainerInterface Service Container */
protected $container = null;
- /** @var AdapterInterface Provide necessary value from Thelia*/
+ /** @var FacadeInterface Provide necessary value from Thelia*/
protected $adapter;
/**
diff --git a/core/lib/Thelia/Coupon/CouponManager.php b/core/lib/Thelia/Coupon/CouponManager.php
index c4ba661be..1b446f1e0 100644
--- a/core/lib/Thelia/Coupon/CouponManager.php
+++ b/core/lib/Thelia/Coupon/CouponManager.php
@@ -26,6 +26,7 @@ namespace Thelia\Coupon;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Thelia\Condition\ConditionManagerInterface;
use Thelia\Coupon\Type\CouponInterface;
+use Thelia\Model\Coupon;
/**
* Created by JetBrains PhpStorm.
@@ -40,7 +41,7 @@ use Thelia\Coupon\Type\CouponInterface;
*/
class CouponManager
{
- /** @var AdapterInterface Provides necessary value from Thelia */
+ /** @var FacadeInterface Provides necessary value from Thelia */
protected $adapter = null;
/** @var ContainerInterface Service Container */
@@ -183,39 +184,12 @@ class CouponManager
$discount = 0.00;
/** @var CouponInterface $coupon */
foreach ($coupons as $coupon) {
- // @todo modify Cart with discount for each cart item
- $discount += $coupon->getDiscount($this->adapter);
+ $discount += $coupon->exec($this->adapter);
}
return $discount;
}
- /**
- * Build a ConditionManagerInterface from data coming from a form
- *
- * @param string $conditionServiceId Condition service id you want to instantiate
- * @param array $operators Condition Operator set by the Admin
- * @param array $values Condition Values set by the Admin
- *
- * @return ConditionManagerInterface
- */
- public function buildRuleFromForm($conditionServiceId, array $operators, array $values)
- {
- $condition = false;
- try {
-
- if ($this->container->has($conditionServiceId)) {
- /** @var ConditionManagerInterface $condition */
- $condition = $this->container->get($conditionServiceId);
- $condition->populateFromForm($operators, $values);
- }
- } catch (\InvalidArgumentException $e) {
-
- }
-
- return $condition;
- }
-
/**
* Add an available CouponManager (Services)
*
@@ -241,7 +215,7 @@ class CouponManager
*
* @param ConditionManagerInterface $condition ConditionManagerInterface
*/
- public function addAvailableRule(ConditionManagerInterface $condition)
+ public function addAvailableCondition(ConditionManagerInterface $condition)
{
$this->availableConditions[] = $condition;
}
@@ -255,4 +229,34 @@ class CouponManager
{
return $this->availableConditions;
}
+
+ /**
+ * Decrement this coupon quantity
+ *
+ * To call when a coupon is consumed
+ *
+ * @param \Thelia\Model\Coupon $coupon Coupon consumed
+ *
+ * @return bool
+ */
+ public function decrementeQuantity(Coupon $coupon)
+ {
+ $ret = true;
+ try {
+
+ $oldMaxUsage = $coupon->getMaxUsage();
+
+ if ($oldMaxUsage > 0) {
+ $oldMaxUsage--;
+ $coupon->setMaxUsage($$oldMaxUsage);
+
+ $coupon->save();
+ }
+
+ } catch(\Exception $e) {
+ $ret = false;
+ }
+
+ return $ret;
+ }
}
\ No newline at end of file
diff --git a/core/lib/Thelia/Coupon/AdapterInterface.php b/core/lib/Thelia/Coupon/FacadeInterface.php
similarity index 94%
rename from core/lib/Thelia/Coupon/AdapterInterface.php
rename to core/lib/Thelia/Coupon/FacadeInterface.php
index 37979b44f..4c264430c 100644
--- a/core/lib/Thelia/Coupon/AdapterInterface.php
+++ b/core/lib/Thelia/Coupon/FacadeInterface.php
@@ -25,11 +25,9 @@ namespace Thelia\Coupon;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerInterface;
-use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\TranslatorInterface;
use Thelia\Condition\ConditionEvaluator;
use Thelia\Core\HttpFoundation\Request;
-use Thelia\Coupon\Type\CouponInterface;
use Thelia\Model\Coupon;
/**
@@ -43,7 +41,7 @@ use Thelia\Model\Coupon;
* @author Guillaume MOREL
*
*/
-interface AdapterInterface
+interface FacadeInterface
{
/**
@@ -126,15 +124,6 @@ interface AdapterInterface
*/
public function findOneCouponByCode($code);
- /**
- * Save a Coupon in the database
- *
- * @param CouponInterface $coupon Coupon
- *
- * @return $this
- */
- public function saveCoupon(CouponInterface $coupon);
-
/**
* Return platform Container
*
diff --git a/core/lib/Thelia/Coupon/RuleOrganizer.php b/core/lib/Thelia/Coupon/RuleOrganizer.php
index ee840bfbc..673f27404 100644
--- a/core/lib/Thelia/Coupon/RuleOrganizer.php
+++ b/core/lib/Thelia/Coupon/RuleOrganizer.php
@@ -45,7 +45,7 @@ class RuleOrganizer implements RuleOrganizerInterface
*/
public function organize(array $conditions)
{
- // TODO: Implement organize() method.
+ // @todo: Implement organize() method.
}
}
\ No newline at end of file
diff --git a/core/lib/Thelia/Coupon/Type/CouponAbstract.php b/core/lib/Thelia/Coupon/Type/CouponAbstract.php
index f3aa392bc..d3107faa7 100644
--- a/core/lib/Thelia/Coupon/Type/CouponAbstract.php
+++ b/core/lib/Thelia/Coupon/Type/CouponAbstract.php
@@ -26,7 +26,7 @@ namespace Thelia\Coupon\Type;
use Symfony\Component\Intl\Exception\NotImplementedException;
use Thelia\Condition\ConditionEvaluator;
use Thelia\Core\Translation\Translator;
-use Thelia\Coupon\AdapterInterface;
+use Thelia\Coupon\FacadeInterface;
use Thelia\Coupon\ConditionCollection;
use Thelia\Coupon\RuleOrganizerInterface;
use Thelia\Exception\InvalidConditionException;
@@ -44,7 +44,7 @@ use Thelia\Exception\InvalidConditionException;
*/
abstract class CouponAbstract implements CouponInterface
{
- /** @var AdapterInterface Provide necessary value from Thelia */
+ /** @var FacadeInterface Provide necessary value from Thelia */
protected $adapter = null;
/** @var Translator Service Translator */
@@ -104,9 +104,9 @@ abstract class CouponAbstract implements CouponInterface
/**
* Constructor
*
- * @param AdapterInterface $adapter Service adapter
+ * @param FacadeInterface $adapter Service adapter
*/
- public function __construct(AdapterInterface $adapter)
+ public function __construct(FacadeInterface $adapter)
{
$this->adapter = $adapter;
$this->translator = $adapter->getTranslator();
@@ -195,7 +195,7 @@ abstract class CouponAbstract implements CouponInterface
*
* @return float Amount removed from the Total Checkout
*/
- public function getDiscount()
+ public function exec()
{
return $this->amount;
}
@@ -298,7 +298,7 @@ abstract class CouponAbstract implements CouponInterface
/**
* Check if the current state of the application is matching this Coupon conditions
- * Thelia variables are given by the AdapterInterface
+ * Thelia variables are given by the FacadeInterface
*
* @return bool
*/
@@ -307,5 +307,4 @@ abstract class CouponAbstract implements CouponInterface
return $this->conditionEvaluator->isMatching($this->conditions);
}
-
}
diff --git a/core/lib/Thelia/Coupon/Type/CouponInterface.php b/core/lib/Thelia/Coupon/Type/CouponInterface.php
index 192a608e8..b88039b5c 100644
--- a/core/lib/Thelia/Coupon/Type/CouponInterface.php
+++ b/core/lib/Thelia/Coupon/Type/CouponInterface.php
@@ -23,7 +23,6 @@
namespace Thelia\Coupon\Type;
-use Thelia\Coupon\AdapterInterface;
use Thelia\Coupon\ConditionCollection;
/**
@@ -205,11 +204,11 @@ interface CouponInterface
*
* @return float Amount removed from the Total Checkout
*/
- public function getDiscount();
+ public function exec();
/**
* Check if the current Coupon is matching its conditions (Rules)
- * Thelia variables are given by the AdapterInterface
+ * Thelia variables are given by the FacadeInterface
*
* @return bool
*/
diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercentForAttributeY.php b/core/lib/Thelia/Coupon/Type/RemoveXPercentForAttributeY.php
deleted file mode 100644
index f0a7ef472..000000000
--- a/core/lib/Thelia/Coupon/Type/RemoveXPercentForAttributeY.php
+++ /dev/null
@@ -1,38 +0,0 @@
-. */
-/* */
-/**********************************************************************************/
-
-namespace Thelia\Coupon\Type;
-
-/**
- * Created by JetBrains PhpStorm.
- * Date: 8/19/13
- * Time: 3:24 PM
- *
- * @package Coupon
- * @author Guillaume MOREL
- *
- */
-class RemoveXPercentForAttributeY extends RemoveXPercent
-{
-
-}
\ No newline at end of file
diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercentForCategoryY.php b/core/lib/Thelia/Coupon/Type/RemoveXPercentForCategoryY.php
deleted file mode 100644
index 717807da7..000000000
--- a/core/lib/Thelia/Coupon/Type/RemoveXPercentForCategoryY.php
+++ /dev/null
@@ -1,38 +0,0 @@
-. */
-/* */
-/**********************************************************************************/
-
-namespace Thelia\Coupon\Type;
-
-/**
- * Created by JetBrains PhpStorm.
- * Date: 8/19/13
- * Time: 3:24 PM
- *
- * @package Coupon
- * @author Guillaume MOREL
- *
- */
-class RemoveXPercentForCategoryY extends RemoveXPercent
-{
-
-}
\ No newline at end of file
diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercentForProductSaleElementIdY.php b/core/lib/Thelia/Coupon/Type/RemoveXPercentForProductSaleElementIdY.php
deleted file mode 100644
index bb052cd68..000000000
--- a/core/lib/Thelia/Coupon/Type/RemoveXPercentForProductSaleElementIdY.php
+++ /dev/null
@@ -1,38 +0,0 @@
-. */
-/* */
-/**********************************************************************************/
-
-namespace Thelia\Coupon\Type;
-
-/**
- * Created by JetBrains PhpStorm.
- * Date: 8/19/13
- * Time: 3:24 PM
- *
- * @package Coupon
- * @author Guillaume MOREL
- *
- */
-class RemoveXPercentForProductSaleElementIdY extends RemoveXPercent
-{
-
-}
\ No newline at end of file
diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercentForProductY.php b/core/lib/Thelia/Coupon/Type/RemoveXPercentForProductY.php
deleted file mode 100644
index 0b88ca44d..000000000
--- a/core/lib/Thelia/Coupon/Type/RemoveXPercentForProductY.php
+++ /dev/null
@@ -1,38 +0,0 @@
-. */
-/* */
-/**********************************************************************************/
-
-namespace Thelia\Coupon\Type;
-
-/**
- * Created by JetBrains PhpStorm.
- * Date: 8/19/13
- * Time: 3:24 PM
- *
- * @package Coupon
- * @author Guillaume MOREL
- *
- */
-class RemoveXPercentForProductY extends RemoveXPercent
-{
-
-}
\ No newline at end of file
diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercentManager.php b/core/lib/Thelia/Coupon/Type/RemoveXPercentManager.php
index d5c45b4d3..b0a8e82cd 100644
--- a/core/lib/Thelia/Coupon/Type/RemoveXPercentManager.php
+++ b/core/lib/Thelia/Coupon/Type/RemoveXPercentManager.php
@@ -98,7 +98,7 @@ class RemoveXPercentManager extends CouponAbstract
* @throws \InvalidArgumentException
* @return float
*/
- public function getDiscount()
+ public function exec()
{
if ($this->percent >= 100) {
throw new \InvalidArgumentException(
diff --git a/core/lib/Thelia/Form/CouponCode.php b/core/lib/Thelia/Form/CouponCode.php
new file mode 100755
index 000000000..06dceb177
--- /dev/null
+++ b/core/lib/Thelia/Form/CouponCode.php
@@ -0,0 +1,63 @@
+. */
+/* */
+/*************************************************************************************/
+namespace Thelia\Form;
+
+use Symfony\Component\Validator\Constraints;
+use Thelia\Model\ModuleQuery;
+use Thelia\Module\BaseModule;
+
+/**
+ * Class CouponCode
+ *
+ * Manage how a coupon is entered by a customer
+ *
+ * @package Thelia\Form
+ * @author Guillaume MOREL
+ */
+class CouponCode extends BaseForm
+{
+ /**
+ * Build form
+ */
+ protected function buildForm()
+ {
+ $this->formBuilder
+ ->add("coupon-code", "text", array(
+ "required" => true,
+ "constraints" => array(
+ new Constraints\NotBlank(),
+ )
+ )
+ );
+ }
+
+ /**
+ * Form name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return "thelia_coupon_code";
+ }
+}
diff --git a/core/lib/Thelia/Form/CouponCreationForm.php b/core/lib/Thelia/Form/CouponCreationForm.php
index 8edc26fbf..448f65e38 100755
--- a/core/lib/Thelia/Form/CouponCreationForm.php
+++ b/core/lib/Thelia/Form/CouponCreationForm.php
@@ -27,6 +27,7 @@ use Symfony\Component\Validator\Constraints\Date;
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\NotEqualTo;
+use Symfony\Component\Validator\Constraints\Range;
/**
* Created by JetBrains PhpStorm.
@@ -109,7 +110,7 @@ class CouponCreationForm extends BaseForm
)
->add(
'isEnabled',
- 'checkbox',
+ 'text',
array()
)
->add(
@@ -124,17 +125,17 @@ class CouponCreationForm extends BaseForm
)
->add(
'isCumulative',
- 'checkbox',
+ 'text',
array()
)
->add(
'isRemovingPostage',
- 'checkbox',
+ 'text',
array()
)
->add(
'isAvailableOnSpecialOffers',
- 'checkbox',
+ 'text',
array()
)
->add(
diff --git a/core/lib/Thelia/Tests/Condition/ConditionEvaluatorTest.php b/core/lib/Thelia/Tests/Condition/ConditionEvaluatorTest.php
index 6e54417e3..dac865a7d 100644
--- a/core/lib/Thelia/Tests/Condition/ConditionEvaluatorTest.php
+++ b/core/lib/Thelia/Tests/Condition/ConditionEvaluatorTest.php
@@ -25,7 +25,7 @@ namespace Thelia\Condition\Implementation;
use Thelia\Condition\ConditionEvaluator;
use Thelia\Condition\Operators;
-use Thelia\Coupon\AdapterInterface;
+use Thelia\Coupon\FacadeInterface;
use Thelia\Coupon\ConditionCollection;
use Thelia\Model\CurrencyQuery;
@@ -57,21 +57,21 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->getMock();
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getTranslator')
->will($this->returnValue($stubTranslator));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
$currencies = CurrencyQuery::create();
$currencies = $currencies->find();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getAvailableCurrencies')
->will($this->returnValue($currencies));
@@ -94,17 +94,17 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
->method('has')
->will($this->returnValue(true));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getContainer')
->will($this->returnValue($stubContainer));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getCheckoutCurrency')
->will($this->returnValue('EUR'));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getCartTotalPrice')
->will($this->returnValue(401.00));
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => '>',
MatchForTotalAmountManager::INPUT2 => '=='
@@ -131,21 +131,21 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->getMock();
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getTranslator')
->will($this->returnValue($stubTranslator));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
$currencies = CurrencyQuery::create();
$currencies = $currencies->find();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getAvailableCurrencies')
->will($this->returnValue($currencies));
@@ -168,17 +168,17 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
->method('has')
->will($this->returnValue(true));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getContainer')
->will($this->returnValue($stubContainer));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getCheckoutCurrency')
->will($this->returnValue('EUR'));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getCartTotalPrice')
->will($this->returnValue(400.00));
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => '>',
MatchForTotalAmountManager::INPUT2 => '=='
@@ -205,21 +205,21 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->getMock();
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getTranslator')
->will($this->returnValue($stubTranslator));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
$currencies = CurrencyQuery::create();
$currencies = $currencies->find();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getAvailableCurrencies')
->will($this->returnValue($currencies));
@@ -242,20 +242,20 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
->method('has')
->will($this->returnValue(true));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getContainer')
->will($this->returnValue($stubContainer));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getCheckoutCurrency')
->will($this->returnValue('EUR'));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getCartTotalPrice')
->will($this->returnValue(401.00));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getNbArticlesInCart')
->will($this->returnValue(5));
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => '>',
MatchForTotalAmountManager::INPUT2 => '=='
@@ -265,7 +265,7 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
MatchForTotalAmountManager::INPUT2 => 'EUR');
$condition1->setValidatorsFromForm($operators, $values);
- $condition2 = new MatchForXArticlesManager($stubAdapter);
+ $condition2 = new MatchForXArticlesManager($stubFacade);
$operators = array(
MatchForXArticlesManager::INPUT1 => '>'
);
@@ -292,21 +292,21 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->getMock();
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getTranslator')
->will($this->returnValue($stubTranslator));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
$currencies = CurrencyQuery::create();
$currencies = $currencies->find();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getAvailableCurrencies')
->will($this->returnValue($currencies));
@@ -329,20 +329,20 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
->method('has')
->will($this->returnValue(true));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getContainer')
->will($this->returnValue($stubContainer));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getCheckoutCurrency')
->will($this->returnValue('EUR'));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getCartTotalPrice')
->will($this->returnValue(400.00));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getNbArticlesInCart')
->will($this->returnValue(5));
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => '>',
MatchForTotalAmountManager::INPUT2 => '=='
@@ -352,7 +352,7 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
MatchForTotalAmountManager::INPUT2 => 'EUR');
$condition1->setValidatorsFromForm($operators, $values);
- $condition2 = new MatchForXArticlesManager($stubAdapter);
+ $condition2 = new MatchForXArticlesManager($stubFacade);
$operators = array(
MatchForXArticlesManager::INPUT1 => '>'
);
diff --git a/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php b/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php
index 295d9a308..28e81ee77 100644
--- a/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php
+++ b/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php
@@ -26,7 +26,7 @@ namespace Thelia\Condition\Implementation;
use Thelia\Condition\ConditionEvaluator;
use Thelia\Condition\ConditionFactory;
use Thelia\Condition\Operators;
-use Thelia\Coupon\AdapterInterface;
+use Thelia\Coupon\FacadeInterface;
use Thelia\Coupon\ConditionCollection;
use Thelia\Model\CurrencyQuery;
@@ -61,21 +61,21 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->getMock();
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getTranslator')
->will($this->returnValue($stubTranslator));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
$currencies = CurrencyQuery::create();
$currencies = $currencies->find();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getAvailableCurrencies')
->will($this->returnValue($currencies));
@@ -84,17 +84,17 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase
->getMock();
$stubContainer->expects($this->any())
->method('get')
- ->will($this->returnValue(new MatchForTotalAmountManager($stubAdapter)));
+ ->will($this->returnValue(new MatchForTotalAmountManager($stubFacade)));
$stubContainer->expects($this->any())
->method('has')
->will($this->returnValue(true));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getContainer')
->will($this->returnValue($stubContainer));
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
@@ -125,21 +125,21 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->getMock();
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getTranslator')
->will($this->returnValue($stubTranslator));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
$currencies = CurrencyQuery::create();
$currencies = $currencies->find();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getAvailableCurrencies')
->will($this->returnValue($currencies));
@@ -148,17 +148,17 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase
->getMock();
$stubContainer->expects($this->any())
->method('get')
- ->will($this->returnValue(new MatchForTotalAmountManager($stubAdapter)));
+ ->will($this->returnValue(new MatchForTotalAmountManager($stubFacade)));
$stubContainer->expects($this->any())
->method('has')
->will($this->returnValueMap(array('unset.service', false)));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getContainer')
->will($this->returnValue($stubContainer));
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
@@ -187,21 +187,21 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->getMock();
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getTranslator')
->will($this->returnValue($stubTranslator));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
$currencies = CurrencyQuery::create();
$currencies = $currencies->find();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getAvailableCurrencies')
->will($this->returnValue($currencies));
@@ -210,17 +210,17 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase
->getMock();
$stubContainer->expects($this->any())
->method('get')
- ->will($this->returnValue(new MatchForTotalAmountManager($stubAdapter)));
+ ->will($this->returnValue(new MatchForTotalAmountManager($stubFacade)));
$stubContainer->expects($this->any())
->method('has')
->will($this->returnValue(true));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getContainer')
->will($this->returnValue($stubContainer));
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
@@ -231,7 +231,7 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase
);
$condition1->setValidatorsFromForm($operators, $values);
- $condition2 = new MatchForTotalAmountManager($stubAdapter);
+ $condition2 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
@@ -266,28 +266,28 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->getMock();
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getTranslator')
->will($this->returnValue($stubTranslator));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
$currencies = CurrencyQuery::create();
$currencies = $currencies->find();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getAvailableCurrencies')
->will($this->returnValue($currencies));
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container')
->disableOriginalConstructor()
->getMock();
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$stubContainer->expects($this->any())
->method('get')
->will($this->returnValue($condition1));
@@ -296,7 +296,7 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase
->method('has')
->will($this->returnValue(true));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getContainer')
->will($this->returnValue($stubContainer));
@@ -331,28 +331,28 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->getMock();
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getTranslator')
->will($this->returnValue($stubTranslator));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
$currencies = CurrencyQuery::create();
$currencies = $currencies->find();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getAvailableCurrencies')
->will($this->returnValue($currencies));
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container')
->disableOriginalConstructor()
->getMock();
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$stubContainer->expects($this->any())
->method('get')
->will($this->returnValue($condition1));
@@ -361,7 +361,7 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase
->method('has')
->will($this->returnValue(false));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getContainer')
->will($this->returnValue($stubContainer));
diff --git a/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneManagerTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneManagerTest.php
index 726ed4988..ba097f750 100644
--- a/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneManagerTest.php
+++ b/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneManagerTest.php
@@ -25,7 +25,7 @@ namespace Thelia\Condition\Implementation;
use Thelia\Condition\ConditionEvaluator;
use Thelia\Condition\Operators;
-use Thelia\Coupon\AdapterInterface;
+use Thelia\Coupon\FacadeInterface;
use Thelia\Model\Currency;
/**
@@ -41,7 +41,7 @@ use Thelia\Model\Currency;
*/
class MatchForEveryoneManagerTest extends \PHPUnit_Framework_TestCase
{
- /** @var AdapterInterface $stubTheliaAdapter */
+ /** @var FacadeInterface $stubTheliaAdapter */
protected $stubTheliaAdapter = null;
/**
@@ -54,19 +54,19 @@ class MatchForEveryoneManagerTest extends \PHPUnit_Framework_TestCase
*/
public function generateAdapterStub($cartTotalPrice = 400, $checkoutCurrency = 'EUR')
{
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getCartTotalPrice')
->will($this->returnValue($cartTotalPrice));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getCheckoutCurrency')
->will($this->returnValue($checkoutCurrency));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
@@ -74,11 +74,11 @@ class MatchForEveryoneManagerTest extends \PHPUnit_Framework_TestCase
$currency1->setCode('EUR');
$currency2 = new Currency();
$currency2->setCode('USD');
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getAvailableCurrencies')
->will($this->returnValue(array($currency1, $currency2)));
- return $stubAdapter;
+ return $stubFacade;
}
/**
@@ -89,10 +89,10 @@ class MatchForEveryoneManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testValidBackOfficeInputOperator()
{
- $stubAdapter = $this->generateAdapterStub(399, 'EUR');
+ $stubFacade = $this->generateAdapterStub(399, 'EUR');
- /** @var AdapterInterface $stubAdapter */
- $condition1 = new MatchForEveryoneManager($stubAdapter);
+ /** @var FacadeInterface $stubFacade */
+ $condition1 = new MatchForEveryoneManager($stubFacade);
$operators = array();
$values = array();
$condition1->setValidatorsFromForm($operators, $values);
@@ -112,10 +112,10 @@ class MatchForEveryoneManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testIsMatching()
{
- $stubAdapter = $this->generateAdapterStub(399, 'EUR');
+ $stubFacade = $this->generateAdapterStub(399, 'EUR');
- /** @var AdapterInterface $stubAdapter */
- $condition1 = new MatchForEveryoneManager($stubAdapter);
+ /** @var FacadeInterface $stubFacade */
+ $condition1 = new MatchForEveryoneManager($stubFacade);
$isValid = $condition1->isMatching();
diff --git a/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountManagerTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountManagerTest.php
index cc142ac38..465f27225 100644
--- a/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountManagerTest.php
+++ b/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountManagerTest.php
@@ -25,7 +25,7 @@ namespace Thelia\Condition\Implementation;
use Thelia\Condition\ConditionEvaluator;
use Thelia\Condition\Operators;
-use Thelia\Coupon\AdapterInterface;
+use Thelia\Coupon\FacadeInterface;
use Thelia\Exception\InvalidConditionValueException;
use Thelia\Model\Currency;
@@ -42,7 +42,7 @@ use Thelia\Model\Currency;
*/
class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
{
- /** @var AdapterInterface $stubTheliaAdapter */
+ /** @var FacadeInterface $stubTheliaAdapter */
protected $stubTheliaAdapter = null;
/**
@@ -55,19 +55,19 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
*/
public function generateAdapterStub($cartTotalPrice = 400, $checkoutCurrency = 'EUR')
{
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getCartTotalPrice')
->will($this->returnValue($cartTotalPrice));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getCheckoutCurrency')
->will($this->returnValue($checkoutCurrency));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
@@ -75,11 +75,11 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
$currency1->setCode('EUR');
$currency2 = new Currency();
$currency2->setCode('USD');
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getAvailableCurrencies')
->will($this->returnValue(array($currency1, $currency2)));
- return $stubAdapter;
+ return $stubFacade;
}
/**
@@ -100,10 +100,10 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testInValidBackOfficeInputOperator()
{
- $stubAdapter = $this->generateAdapterStub(399, 'EUR');
+ $stubFacade = $this->generateAdapterStub(399, 'EUR');
- /** @var AdapterInterface $stubAdapter */
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ /** @var FacadeInterface $stubFacade */
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => Operators::IN,
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
@@ -129,10 +129,10 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testInValidBackOfficeInputOperator2()
{
- $stubAdapter = $this->generateAdapterStub(399, 'EUR');
+ $stubFacade = $this->generateAdapterStub(399, 'EUR');
- /** @var AdapterInterface $stubAdapter */
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ /** @var FacadeInterface $stubFacade */
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
MatchForTotalAmountManager::INPUT2 => Operators::INFERIOR
@@ -158,10 +158,10 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testInValidBackOfficeInputValue()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->generateAdapterStub(399, 'EUR');
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->generateAdapterStub(399, 'EUR');
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
@@ -187,10 +187,10 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testInValidBackOfficeInputValue2()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->generateAdapterStub(399, 'EUR');
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->generateAdapterStub(399, 'EUR');
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
@@ -215,10 +215,10 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testMatchingConditionInferior()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->generateAdapterStub(399, 'EUR');
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->generateAdapterStub(399, 'EUR');
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR,
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
@@ -243,10 +243,10 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testNotMatchingConditionInferior()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->generateAdapterStub(400, 'EUR');
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->generateAdapterStub(400, 'EUR');
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR,
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
@@ -271,10 +271,10 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testMatchingConditionInferiorEquals()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->generateAdapterStub(400, 'EUR');
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->generateAdapterStub(400, 'EUR');
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR_OR_EQUAL,
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
@@ -299,10 +299,10 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testMatchingConditionInferiorEquals2()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->generateAdapterStub(399, 'EUR');
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->generateAdapterStub(399, 'EUR');
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR_OR_EQUAL,
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
@@ -327,10 +327,10 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testNotMatchingConditionInferiorEquals()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->generateAdapterStub(401, 'EUR');
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->generateAdapterStub(401, 'EUR');
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR_OR_EQUAL,
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
@@ -355,10 +355,10 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testMatchingConditionEqual()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->generateAdapterStub(400, 'EUR');
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->generateAdapterStub(400, 'EUR');
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => Operators::EQUAL,
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
@@ -383,10 +383,10 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testNotMatchingConditionEqual()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->generateAdapterStub(399, 'EUR');
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->generateAdapterStub(399, 'EUR');
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => Operators::EQUAL,
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
@@ -411,10 +411,10 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testMatchingConditionSuperiorEquals()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->generateAdapterStub(401, 'EUR');
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->generateAdapterStub(401, 'EUR');
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL,
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
@@ -439,10 +439,10 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testMatchingConditionSuperiorEquals2()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->generateAdapterStub(400, 'EUR');
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->generateAdapterStub(400, 'EUR');
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL,
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
@@ -467,10 +467,10 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testNotMatchingConditionSuperiorEquals()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->generateAdapterStub(399, 'EUR');
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->generateAdapterStub(399, 'EUR');
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL,
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
@@ -495,10 +495,10 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testMatchingConditionSuperior()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->generateAdapterStub(401, 'EUR');
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->generateAdapterStub(401, 'EUR');
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
@@ -523,10 +523,10 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testNotMatchingConditionSuperior()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->generateAdapterStub(399, 'EUR');
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->generateAdapterStub(399, 'EUR');
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
@@ -551,10 +551,10 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testMatchingConditionCurrency()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->generateAdapterStub(400, 'EUR');
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->generateAdapterStub(400, 'EUR');
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => Operators::EQUAL,
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
@@ -579,10 +579,10 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testNotMatchingConditionCurrency()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->generateAdapterStub(400.00, 'EUR');
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->generateAdapterStub(400.00, 'EUR');
- $condition1 = new MatchForTotalAmountManager($stubAdapter);
+ $condition1 = new MatchForTotalAmountManager($stubFacade);
$operators = array(
MatchForTotalAmountManager::INPUT1 => Operators::EQUAL,
MatchForTotalAmountManager::INPUT2 => Operators::EQUAL
diff --git a/core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesManagerTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesManagerTest.php
index 4243b1082..a618d3dcd 100644
--- a/core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesManagerTest.php
+++ b/core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesManagerTest.php
@@ -26,7 +26,7 @@ namespace Thelia\Condition\Implementation;
use Thelia\Condition\ConditionEvaluator;
use Thelia\Condition\Operators;
use Thelia\Condition\SerializableCondition;
-use Thelia\Coupon\AdapterInterface;
+use Thelia\Coupon\FacadeInterface;
/**
* Created by JetBrains PhpStorm.
@@ -59,20 +59,20 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testInValidBackOfficeInputOperator()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter->expects($this->any())
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade->expects($this->any())
->method('getNbArticlesInCart')
->will($this->returnValue(4));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
- $condition1 = new MatchForXArticlesManager($stubAdapter);
+ $condition1 = new MatchForXArticlesManager($stubFacade);
$operators = array(
MatchForXArticlesManager::INPUT1 => Operators::IN
);
@@ -96,19 +96,19 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testInValidBackOfficeInputValue()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getNbArticlesInCart')
->will($this->returnValue(4));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
- $condition1 = new MatchForXArticlesManager($stubAdapter);
+ $condition1 = new MatchForXArticlesManager($stubFacade);
$operators = array(
MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR
);
@@ -132,19 +132,19 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testMatchingRuleInferior()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getNbArticlesInCart')
->will($this->returnValue(4));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
- $condition1 = new MatchForXArticlesManager($stubAdapter);
+ $condition1 = new MatchForXArticlesManager($stubFacade);
$operators = array(
MatchForXArticlesManager::INPUT1 => Operators::INFERIOR
);
@@ -168,19 +168,19 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testNotMatchingRuleInferior()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getNbArticlesInCart')
->will($this->returnValue(4));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
- $condition1 = new MatchForXArticlesManager($stubAdapter);
+ $condition1 = new MatchForXArticlesManager($stubFacade);
$operators = array(
MatchForXArticlesManager::INPUT1 => Operators::INFERIOR
);
@@ -204,19 +204,19 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testMatchingRuleInferiorEquals()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getNbArticlesInCart')
->will($this->returnValue(4));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
- $condition1 = new MatchForXArticlesManager($stubAdapter);
+ $condition1 = new MatchForXArticlesManager($stubFacade);
$operators = array(
MatchForXArticlesManager::INPUT1 => Operators::INFERIOR_OR_EQUAL,
);
@@ -240,19 +240,19 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testMatchingRuleInferiorEquals2()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getNbArticlesInCart')
->will($this->returnValue(4));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
- $condition1 = new MatchForXArticlesManager($stubAdapter);
+ $condition1 = new MatchForXArticlesManager($stubFacade);
$operators = array(
MatchForXArticlesManager::INPUT1 => Operators::INFERIOR_OR_EQUAL
);
@@ -276,19 +276,19 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testNotMatchingRuleInferiorEquals()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getNbArticlesInCart')
->will($this->returnValue(4));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
- $condition1 = new MatchForXArticlesManager($stubAdapter);
+ $condition1 = new MatchForXArticlesManager($stubFacade);
$operators = array(
MatchForXArticlesManager::INPUT1 => Operators::INFERIOR_OR_EQUAL
);
@@ -312,19 +312,19 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testMatchingRuleEqual()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getNbArticlesInCart')
->will($this->returnValue(4));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
- $condition1 = new MatchForXArticlesManager($stubAdapter);
+ $condition1 = new MatchForXArticlesManager($stubFacade);
$operators = array(
MatchForXArticlesManager::INPUT1 => Operators::EQUAL
);
@@ -348,19 +348,19 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testNotMatchingRuleEqual()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getNbArticlesInCart')
->will($this->returnValue(4));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
- $condition1 = new MatchForXArticlesManager($stubAdapter);
+ $condition1 = new MatchForXArticlesManager($stubFacade);
$operators = array(
MatchForXArticlesManager::INPUT1 => Operators::EQUAL
);
@@ -384,19 +384,19 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testMatchingRuleSuperiorEquals()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getNbArticlesInCart')
->will($this->returnValue(4));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
- $condition1 = new MatchForXArticlesManager($stubAdapter);
+ $condition1 = new MatchForXArticlesManager($stubFacade);
$operators = array(
MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL
);
@@ -420,19 +420,19 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testMatchingRuleSuperiorEquals2()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getNbArticlesInCart')
->will($this->returnValue(4));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
- $condition1 = new MatchForXArticlesManager($stubAdapter);
+ $condition1 = new MatchForXArticlesManager($stubFacade);
$operators = array(
MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL
);
@@ -456,19 +456,19 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testNotMatchingRuleSuperiorEquals()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getNbArticlesInCart')
->will($this->returnValue(4));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
- $condition1 = new MatchForXArticlesManager($stubAdapter);
+ $condition1 = new MatchForXArticlesManager($stubFacade);
$operators = array(
MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL
);
@@ -492,19 +492,19 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testMatchingRuleSuperior()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getNbArticlesInCart')
->will($this->returnValue(4));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
- $condition1 = new MatchForXArticlesManager($stubAdapter);
+ $condition1 = new MatchForXArticlesManager($stubFacade);
$operators = array(
MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR
);
@@ -528,19 +528,19 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testNotMatchingRuleSuperior()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getNbArticlesInCart')
->will($this->returnValue(4));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
- $condition1 = new MatchForXArticlesManager($stubAdapter);
+ $condition1 = new MatchForXArticlesManager($stubFacade);
$operators = array(
MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR
);
@@ -558,19 +558,19 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
public function testGetSerializableRule()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getNbArticlesInCart')
->will($this->returnValue(4));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
- $condition1 = new MatchForXArticlesManager($stubAdapter);
+ $condition1 = new MatchForXArticlesManager($stubFacade);
$operators = array(
MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR
);
@@ -594,19 +594,19 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
public function testGetAvailableOperators()
{
- /** @var AdapterInterface $stubAdapter */
- $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
+ /** @var FacadeInterface $stubFacade */
+ $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade')
->disableOriginalConstructor()
->getMock();
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getNbArticlesInCart')
->will($this->returnValue(4));
- $stubAdapter->expects($this->any())
+ $stubFacade->expects($this->any())
->method('getConditionEvaluator')
->will($this->returnValue(new ConditionEvaluator()));
- $condition1 = new MatchForXArticlesManager($stubAdapter);
+ $condition1 = new MatchForXArticlesManager($stubFacade);
$operators = array(
MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR
);
@@ -630,35 +630,6 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
}
-// public function testGetValidators()
-// {
-// $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter')
-// ->disableOriginalConstructor()
-// ->getMock();
-//
-// $stubAdapter->expects($this->any())
-// ->method('getNbArticlesInCart')
-// ->will($this->returnValue(4));
-//
-// $condition1 = new MatchForXArticlesManager($stubAdapter);
-// $operators = array(
-// MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR
-// );
-// $values = array(
-// MatchForXArticlesManager::INPUT1 => 4
-// );
-// $condition1->setValidatorsFromForm($operators, $values);
-//
-// $expected = array(
-// $operators,
-// $values
-// );
-// $actual = $condition1->getValidators();
-//
-// $this->assertEquals($expected, $actual);
-//
-// }
-
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
diff --git a/core/lib/Thelia/Tests/Coupon/CouponBaseAdapterTest.php b/core/lib/Thelia/Tests/Coupon/CouponBaseAdapterTest.php
index 438a025de..8e2d0addb 100644
--- a/core/lib/Thelia/Tests/Coupon/CouponBaseAdapterTest.php
+++ b/core/lib/Thelia/Tests/Coupon/CouponBaseAdapterTest.php
@@ -28,7 +28,7 @@ namespace Thelia\Coupon;
* Date: 8/19/13
* Time: 3:24 PM
*
- * Unit Test BaseAdapter Class
+ * Unit Test BaseFacade Class
*
* @package Coupon
* @author Guillaume MOREL
@@ -43,61 +43,5 @@ class CouponBaseAdapterTest extends \PHPUnit_Framework_TestCase
'This test has not been implemented yet.'
);
}
-// /**
-// * @var BaseAdapter
-// */
-// protected $object;
-//
-// /**
-// * Sets up the fixture, for example, opens a network connection.
-// * This method is called before a test is executed.
-// */
-// protected function setUp()
-// {
-// $this->object = new BaseAdapter;
-// }
-//
-// /**
-// * 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\BaseAdapter::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\BaseAdapter::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\BaseAdapter::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.'
-// );
-// }
+
}
diff --git a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php
index 21a0cfa4b..648dbcd19 100644
--- a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php
+++ b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php
@@ -23,14 +23,6 @@
namespace Thelia\Coupon;
-use Thelia\Constraint\Validator\PriceParam;
-use Thelia\Constraint\Validator\RuleValidator;
-use Thelia\Constraint\Rule\AvailableForTotalAmount;
-use Thelia\Constraint\Rule\Operators;
-use Thelia\Coupon\Type\CouponInterface;
-use Thelia\Exception\CouponExpiredException;
-use Thelia\Model\Coupon;
-
require_once 'CouponManagerTest.php';
/**
@@ -53,293 +45,4 @@ class CouponFactoryTest extends \PHPUnit_Framework_TestCase
'This test has not been implemented yet.'
);
}
-
-// /**
-// * Sets up the fixture, for example, opens a network connection.
-// * This method is called before a test is executed.
-// */
-// protected function setUp()
-// {
-// }
-//
-// /**
-// * Fake CouponQuery->findByCode
-// *
-// * @param string $code Coupon code
-// * @param string $type Coupon type (object)
-// * @param string $title Coupon title
-// * @param string $shortDescription Coupon short description
-// * @param string $description Coupon description
-// * @param float $amount Coupon amount
-// * @param bool $isUsed If Coupon has been used yet
-// * @param bool $isEnabled If Coupon is enabled
-// * @param \DateTime $expirationDate When Coupon expires
-// * @param ConditionCollection $rules Coupon rules
-// * @param bool $isCumulative If Coupon is cumulative
-// * @param bool $isRemovingPostage If Coupon is removing postage
-// *
-// * @return Coupon
-// */
-// public function generateCouponModelMock(
-// $code = null,
-// $type = null,
-// $title = null,
-// $shortDescription = null,
-// $description = null,
-// $amount = null,
-// $isUsed = null,
-// $isEnabled = null,
-// $expirationDate = null,
-// $rules = null,
-// $isCumulative = null,
-// $isRemovingPostage = null
-// ) {
-// $coupon = $this->generateValidCoupon(
-// $code,
-// $type,
-// $title,
-// $shortDescription,
-// $description,
-// $amount,
-// $isUsed,
-// $isEnabled,
-// $expirationDate,
-// $rules,
-// $isCumulative,
-// $isRemovingPostage
-// );
-//
-// /** @var AdapterInterface $stubCouponBaseAdapter */
-// $stubCouponBaseAdapter = $this->getMock(
-// 'Thelia\Coupon\BaseAdapter',
-// array('findOneCouponByCode'),
-// array()
-// );
-// $stubCouponBaseAdapter->expects($this->any())
-// ->method('findOneCouponByCode')
-// ->will($this->returnValue($coupon));
-//
-// return $stubCouponBaseAdapter;
-// }
-//
-//
-//
-// /**
-// * Test if an expired Coupon is build or not (superior)
-// *
-// * @covers Thelia\Coupon\CouponFactory::buildCouponFromCode
-// * @expectedException \Thelia\Exception\CouponExpiredException
-// */
-// public function testBuildCouponFromCodeExpiredDateBefore()
-// {
-// $date = new \DateTime();
-// $date->setTimestamp(strtotime("today - 2 months"));
-//
-// /** @var AdapterInterface $mockAdapter */
-// $mockAdapter = $this->generateCouponModelMock(null, null, null, null, null, null, null, null, $date);
-// $couponFactory = new CouponFactory($mockAdapter);
-// $coupon = $couponFactory->buildCouponFromCode('XMAS1');
-// }
-//
-// /**
-// * Test if an expired Coupon is build or not (equal)
-// *
-// * @covers Thelia\Coupon\CouponFactory::buildCouponFromCode
-// * @expectedException \Thelia\Exception\CouponExpiredException
-// */
-// public function testBuildCouponFromCodeExpiredDateEquals()
-// {
-// $date = new \DateTime();
-//
-// /** @var AdapterInterface $mockAdapter */
-// $mockAdapter = $this->generateCouponModelMock(null, null, null, null, null, null, null, null, $date);
-// $couponFactory = new CouponFactory($mockAdapter);
-// $coupon = $couponFactory->buildCouponFromCode('XMAS1');
-// }
-//
-// /**
-// * Test if an expired Coupon is build or not (equal)
-// *
-// * @covers Thelia\Coupon\CouponFactory::buildCouponFromCode
-// * @expectedException \Thelia\Exception\InvalidConditionException
-// */
-// public function testBuildCouponFromCodeWithoutRule()
-// {
-// /** @var AdapterInterface $mockAdapter */
-// $mockAdapter = $this->generateCouponModelMock(null, null, null, null, null, null, null, null, null, new ConditionCollection(array()));
-// $couponFactory = new CouponFactory($mockAdapter);
-// $coupon = $couponFactory->buildCouponFromCode('XMAS1');
-// }
-//
-// /**
-// * Test if a CouponInterface can be built from database
-// *
-// * @covers Thelia\Coupon\CouponFactory::buildCouponFromCode
-// */
-// public function testBuildCouponFromCode()
-// {
-// /** @var AdapterInterface $mockAdapter */
-// $mockAdapter = $this->generateCouponModelMock();
-// $couponFactory = new CouponFactory($mockAdapter);
-// /** @var CouponInterface $coupon */
-// $coupon = $couponFactory->buildCouponFromCode('XMAS1');
-//
-// $this->assertEquals('XMAS1', $coupon->getCode());
-// $this->assertEquals('Thelia\Coupon\Type\RemoveXAmount', get_class($coupon));
-// $this->assertEquals(CouponManagerTest::VALID_TITLE, $coupon->getTitle());
-// $this->assertEquals(CouponManagerTest::VALID_SHORT_DESCRIPTION, $coupon->getShortDescription());
-// $this->assertEquals(CouponManagerTest::VALID_DESCRIPTION, $coupon->getDescription());
-// $this->assertEquals(10.00, $coupon->getDiscount());
-// $this->assertEquals(1, $coupon->isEnabled());
-//
-// $date = new \DateTime();
-// $date->setTimestamp(strtotime("today + 2 months"));
-// $this->assertEquals($date, $coupon->getExpirationDate());
-//
-// $rules = $this->generateValidRules();
-// $this->assertEquals($rules, $coupon->getRules());
-//
-// $this->assertEquals(1, $coupon->isCumulative());
-// $this->assertEquals(0, $coupon->isRemovingPostage());
-// }
-//
-// /**
-// * Generate valid CouponRuleInterfaces
-// *
-// * @return ConditionCollection Set of ConditionManagerInterface
-// */
-// protected function generateValidRules()
-// {
-//// $rule1 = new AvailableForTotalAmount(
-//// , array(
-//// AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator(
-//// Operators::SUPERIOR,
-//// new PriceParam(
-//// , 40.00, 'EUR'
-//// )
-//// )
-//// )
-//// );
-//// $rule2 = new AvailableForTotalAmount(
-//// , array(
-//// AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator(
-//// Operators::INFERIOR,
-//// new PriceParam(
-//// , 400.00, 'EUR'
-//// )
-//// )
-//// )
-//// );
-//// $rules = new ConditionCollection(array($rule1, $rule2));
-////
-//// return $rules;
-// }
-//
-// /**
-// * Generate valid CouponInterface
-// *
-// * @param string $code Coupon code
-// * @param string $type Coupon type (object)
-// * @param string $title Coupon title
-// * @param string $shortDescription Coupon short description
-// * @param string $description Coupon description
-// * @param float $amount Coupon amount
-// * @param bool $isUsed If Coupon has been used yet
-// * @param bool $isEnabled If Coupon is enabled
-// * @param \DateTime $expirationDate When Coupon expires
-// * @param ConditionCollection $rules Coupon rules
-// * @param bool $isCumulative If Coupon is cumulative
-// * @param bool $isRemovingPostage If Coupon is removing postage
-// *
-// * @return Coupon
-// */
-// public function generateValidCoupon(
-// $code = null,
-// $type = null,
-// $title = null,
-// $shortDescription = null,
-// $description = null,
-// $amount = null,
-// $isUsed = null,
-// $isEnabled = null,
-// $expirationDate = null,
-// $rules = null,
-// $isCumulative = null,
-// $isRemovingPostage = null
-// ) {
-// $coupon = new Coupon();
-//
-// if ($code === null) {
-// $code = 'XMAS1';
-// }
-// $coupon->setCode($code);
-//
-// if ($type === null) {
-// $type = 'Thelia\Coupon\Type\RemoveXAmount';
-// }
-// $coupon->setType($type);
-//
-// if ($title === null) {
-// $title = CouponManagerTest::VALID_TITLE;
-// }
-// $coupon->setTitle($title);
-//
-// if ($shortDescription === null) {
-// $shortDescription = CouponManagerTest::VALID_SHORT_DESCRIPTION;
-// }
-// $coupon->setShortDescription($shortDescription);
-//
-// if ($description === null) {
-// $description = CouponManagerTest::VALID_DESCRIPTION;
-// }
-// $coupon->setDescription($description);
-//
-// if ($amount === null) {
-// $amount = 10.00;
-// }
-// $coupon->setAmount($amount);
-//
-// if ($isUsed === null) {
-// $isUsed = 1;
-// }
-// $coupon->setIsUsed($isUsed);
-//
-// if ($isEnabled === null) {
-// $isEnabled = 1;
-// }
-// $coupon->setIsEnabled($isEnabled);
-//
-// if ($isCumulative === null) {
-// $isCumulative = 1;
-// }
-// if ($isRemovingPostage === null) {
-// $isRemovingPostage = 0;
-// }
-//
-// if ($expirationDate === null) {
-// $date = new \DateTime();
-// $coupon->setExpirationDate(
-// $date->setTimestamp(strtotime("today + 2 months"))
-// );
-// }
-//
-// if ($rules === null) {
-// $rules = $this->generateValidRules();
-// }
-//
-// $coupon->setSerializedConditions(base64_encode(serialize($rules)));
-//
-// $coupon->setIsCumulative($isCumulative);
-// $coupon->setIsRemovingPostage($isRemovingPostage);
-//
-// return $coupon;
-// }
-//
-// /**
-// * Tears down the fixture, for example, closes a network connection.
-// * This method is called after a test is executed.
-// */
-// protected function tearDown()
-// {
-// }
}
diff --git a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php
index 1d1ba7c72..751a1ba33 100644
--- a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php
+++ b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php
@@ -23,11 +23,6 @@
namespace Thelia\Coupon;
-use Thelia\Constraint\Validator\PriceParam;
-use Thelia\Constraint\Validator\RuleValidator;
-use Thelia\Constraint\Rule\Operators;
-use Thelia\Coupon\Type\CouponInterface;
-use Thelia\Tools\PhpUnitUtils;
/**
* Created by JetBrains PhpStorm.
@@ -49,761 +44,5 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase
'This test has not been implemented yet.'
);
}
-// CONST VALID_CODE = 'XMAS';
-// CONST VALID_TITLE = 'XMAS coupon';
-// CONST VALID_SHORT_DESCRIPTION = 'Coupon for Christmas removing 10€ if your total checkout is more than 40€';
-// CONST VALID_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.';
-//
-// /**
-// * Sets up the fixture, for example, opens a network connection.
-// * This method is called before a test is executed.
-// */
-// protected function setUp()
-// {
-// }
-//
-// /**
-// * Test getDiscount() behaviour
-// * Entering : 1 valid Coupon (If 40 < total amount 400) - 10euros
-// *
-// * @covers Thelia\Coupon\CouponManager::getDiscount
-// */
-// public function testGetDiscountOneCoupon()
-// {
-// $cartTotalPrice = 100.00;
-// $checkoutTotalPrice = 120.00;
-//
-// /** @var CouponInterface $coupon */
-// $coupon = self::generateValidCoupon();
-//
-// /** @var AdapterInterface $stubCouponBaseAdapter */
-// $stubCouponBaseAdapter = $this->generateFakeAdapter(array($coupon), $cartTotalPrice, $checkoutTotalPrice);
-//
-// $couponManager = new CouponManager($stubCouponBaseAdapter);
-// $discount = $couponManager->getDiscount();
-//
-// $expected = 10.00;
-// $actual = $discount;
-// $this->assertEquals($expected, $actual);
-// }
-//
-// /**
-// * Test getDiscount() behaviour
-// * Entering : 1 valid Coupon (If 40 < total amount 400) - 10euros
-// * 1 valid Coupon (If total amount > 20) - 15euros
-// *
-// * @covers Thelia\Coupon\CouponManager::getDiscount
-// */
-// public function testGetDiscountTwoCoupon()
-// {
-// $adapter = new BaseAdapter();
-// $cartTotalPrice = 100.00;
-// $checkoutTotalPrice = 120.00;
-//
-// /** @var CouponInterface $coupon1 */
-// $coupon1 = self::generateValidCoupon();
-// $rule1 = new AvailableForTotalAmount(
-// $adapter, array(
-// AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator(
-// Operators::SUPERIOR,
-// new PriceParam(
-// $adapter, 40.00, 'EUR'
-// )
-// )
-// )
-// );
-// $rules = new ConditionCollection(array($rule1));
-// /** @var CouponInterface $coupon2 */
-// $coupon2 = $this->generateValidCoupon('XMAS2', null, null, null, 15.00, null, null, $rules);
-//
-// /** @var AdapterInterface $stubCouponBaseAdapter */
-// $stubCouponBaseAdapter = $this->generateFakeAdapter(array($coupon1, $coupon2), $cartTotalPrice, $checkoutTotalPrice);
-//
-// $couponManager = new CouponManager($stubCouponBaseAdapter);
-// $discount = $couponManager->getDiscount();
-//
-// $expected = 25.00;
-// $actual = $discount;
-// $this->assertEquals($expected, $actual);
-// }
-//
-// /**
-// * Test getDiscount() behaviour
-// * For a Cart of 21euros
-// * Entering : 1 valid Coupon (If total amount > 20) - 30euros
-// *
-// * @covers Thelia\Coupon\CouponManager::getDiscount
-// */
-// public function testGetDiscountAlwaysInferiorToPrice()
-// {
-// $adapter = new BaseAdapter();
-// $cartTotalPrice = 21.00;
-// $checkoutTotalPrice = 26.00;
-//
-// $rule1 = new AvailableForTotalAmount(
-// $adapter, array(
-// AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator(
-// Operators::SUPERIOR,
-// new PriceParam(
-// $adapter, 20.00, 'EUR'
-// )
-// )
-// )
-// );
-// $rules = new ConditionCollection(array($rule1));
-// /** @var CouponInterface $coupon */
-// $coupon = $this->generateValidCoupon('XMAS2', null, null, null, 30.00, null, null, $rules);
-//
-// /** @var AdapterInterface $stubCouponBaseAdapter */
-// $stubCouponBaseAdapter = $this->generateFakeAdapter(array($coupon), $cartTotalPrice, $checkoutTotalPrice);
-//
-// $couponManager = new CouponManager($stubCouponBaseAdapter);
-// $discount = $couponManager->getDiscount();
-//
-// $expected = 21.00;
-// $actual = $discount;
-// $this->assertEquals($expected, $actual);
-// }
-//
-//
-// /**
-// * Check if removing postage on discout is working
-// * @covers Thelia\Coupon\CouponManager::isCouponRemovingPostage
-// * @covers Thelia\Coupon\CouponManager::sortCoupons
-// */
-// public function testIsCouponRemovingPostage()
-// {
-// $adapter = new BaseAdapter();
-// $cartTotalPrice = 21.00;
-// $checkoutTotalPrice = 27.00;
-//
-// $rule1 = new AvailableForTotalAmount(
-// $adapter, array(
-// AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator(
-// Operators::SUPERIOR,
-// new PriceParam(
-// $adapter, 20.00, 'EUR'
-// )
-// )
-// )
-// );
-// $rules = new ConditionCollection(array($rule1));
-// /** @var CouponInterface $coupon */
-// $coupon = $this->generateValidCoupon('XMAS2', null, null, null, 30.00, null, null, $rules, null, true);
-//
-// /** @var AdapterInterface $stubCouponBaseAdapter */
-// $stubCouponBaseAdapter = $this->generateFakeAdapter(array($coupon), $cartTotalPrice, $checkoutTotalPrice);
-//
-// $couponManager = new CouponManager($stubCouponBaseAdapter);
-// $discount = $couponManager->getDiscount();
-//
-// $expected = 21.00;
-// $actual = $discount;
-// $this->assertEquals($expected, $actual);
-// }
-//
-// /**
-// * Testing how multiple Coupon behaviour
-// * Entering 1 Coupon not cumulative
-// *
-// * @covers Thelia\Coupon\CouponManager::sortCoupons
-// */
-// public function testCouponCumulationOneCouponNotCumulative()
-// {
-// $cartTotalPrice = 100.00;
-// $checkoutTotalPrice = 120.00;
-//
-// // Given
-// /** @var CouponInterface $coupon */
-// $couponCumulative1 = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false);
-//
-// $coupons = array($couponCumulative1);
-//
-// /** @var AdapterInterface $stubCouponBaseAdapter */
-// $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice);
-//
-// // When
-// $sortedCoupons = PhpUnitUtils::callMethod(
-// new CouponManager($stubCouponBaseAdapter),
-// 'sortCoupons',
-// array($coupons)
-// );
-//
-// // Then
-// $expected = $coupons;
-// $actual = $sortedCoupons;
-//
-// $this->assertSame($expected, $actual, 'Array Sorted despite there is only once');
-// }
-//
-// /**
-// * Testing how multiple Coupon behaviour
-// * Entering 1 Coupon cumulative
-// *
-// * @covers Thelia\Coupon\CouponManager::sortCoupons
-// */
-// public function testCouponCumulationOneCouponCumulative()
-// {
-// $cartTotalPrice = 100.00;
-// $checkoutTotalPrice = 120.00;
-//
-// // Given
-// /** @var CouponInterface $coupon */
-// $couponCumulative1 = $this->generateValidCoupon(null, null, null, null, null, null, null, null, true);
-//
-// $coupons = array($couponCumulative1);
-// /** @var AdapterInterface $stubCouponBaseAdapter */
-// $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice);
-//
-// // When
-// $sortedCoupons = PhpUnitUtils::callMethod(
-// new CouponManager($stubCouponBaseAdapter),
-// 'sortCoupons',
-// array($coupons)
-// );
-//
-// // Then
-// $expected = $coupons;
-// $actual = $sortedCoupons;
-//
-// $this->assertSame($expected, $actual, 'Array Sorted despite there is only once');
-// }
-//
-// /**
-// * Testing how multiple Coupon behaviour
-// * Entering 1 Coupon cumulative
-// * 1 Coupon cumulative
-// *
-// * @covers Thelia\Coupon\CouponManager::sortCoupons
-// */
-// public function testCouponCumulationTwoCouponCumulative()
-// {
-// $cartTotalPrice = 100.00;
-// $checkoutTotalPrice = 120.00;
-//
-// // Given
-// /** @var CouponInterface $coupon */
-// $couponCumulative1 = $this->generateValidCoupon('XMAS1', null, null, null, null, null, null, null, true);
-// $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, null, null, true);
-//
-// $coupons = array($couponCumulative1, $couponCumulative2);
-// /** @var AdapterInterface $stubCouponBaseAdapter */
-// $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice);
-//
-// // When
-// $sortedCoupons = PhpUnitUtils::callMethod(
-// new CouponManager($stubCouponBaseAdapter),
-// 'sortCoupons',
-// array($coupons)
-// );
-//
-// // Then
-// $expected = $coupons;
-// $actual = $sortedCoupons;
-//
-// $this->assertSame($expected, $actual, 'Array Sorted despite both Coupon can be accumulated');
-// }
-//
-// /**
-// * Testing how multiple Coupon behaviour
-// * Entering 1 Coupon cumulative
-// * 1 Coupon non cumulative
-// *
-// * @covers Thelia\Coupon\CouponManager::sortCoupons
-// */
-// public function testCouponCumulationOneCouponCumulativeOneNonCumulative()
-// {
-// $cartTotalPrice = 100.00;
-// $checkoutTotalPrice = 120.00;
-//
-// // Given
-// /** @var CouponInterface $coupon */
-// $couponCumulative1 = $this->generateValidCoupon('XMAS1', null, null, null, null, null, null, null, true);
-// $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, null, null, false);
-//
-// $coupons = array($couponCumulative1, $couponCumulative2);
-// /** @var AdapterInterface $stubCouponBaseAdapter */
-// $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice);
-//
-// // When
-// $sortedCoupons = PhpUnitUtils::callMethod(
-// new CouponManager($stubCouponBaseAdapter),
-// 'sortCoupons',
-// array($coupons)
-// );
-//
-// // Then
-// $expected = array($couponCumulative2);
-// $actual = $sortedCoupons;
-//
-// $this->assertSame($expected, $actual, 'Array Sorted despite both Coupon can be accumulated');
-// }
-//
-// /**
-// * Testing how multiple Coupon behaviour
-// * Entering 1 Coupon non cumulative
-// * 1 Coupon cumulative
-// *
-// * @covers Thelia\Coupon\CouponManager::sortCoupons
-// */
-// public function testCouponCumulationOneCouponNonCumulativeOneCumulative()
-// {
-// $cartTotalPrice = 100.00;
-// $checkoutTotalPrice = 120.00;
-//
-// // Given
-// /** @var CouponInterface $coupon */
-// $couponCumulative1 = $this->generateValidCoupon('XMAS1', null, null, null, null, null, null, null, false);
-// $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, null, null, true);
-//
-// $coupons = array($couponCumulative1, $couponCumulative2);
-// /** @var AdapterInterface $stubCouponBaseAdapter */
-// $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice);
-//
-// // When
-// $sortedCoupons = PhpUnitUtils::callMethod(
-// new CouponManager($stubCouponBaseAdapter),
-// 'sortCoupons',
-// array($coupons)
-// );
-//
-// // Then
-// $expected = array($couponCumulative2);
-// $actual = $sortedCoupons;
-//
-// $this->assertSame($expected, $actual, 'Array Sorted despite both Coupon can be accumulated');
-// }
-//
-// /**
-// * Testing how multiple Coupon behaviour
-// * Entering 1 Coupon non cumulative
-// * 1 Coupon non cumulative
-// *
-// * @covers Thelia\Coupon\CouponManager::sortCoupons
-// */
-// public function testCouponCumulationTwoCouponNonCumulative()
-// {
-// $cartTotalPrice = 100.00;
-// $checkoutTotalPrice = 120.00;
-//
-// // Given
-// /** @var CouponInterface $coupon */
-// $couponCumulative1 = $this->generateValidCoupon('XMAS1', null, null, null, null, null, null, null, false);
-// $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, null, null, false);
-//
-// $coupons = array($couponCumulative1, $couponCumulative2);
-// /** @var AdapterInterface $stubCouponBaseAdapter */
-// $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice);
-//
-// // When
-// $sortedCoupons = PhpUnitUtils::callMethod(
-// new CouponManager($stubCouponBaseAdapter),
-// 'sortCoupons',
-// array($coupons)
-// );
-//
-// // Then
-// $expected = array($couponCumulative2);
-// $actual = $sortedCoupons;
-//
-// $this->assertSame($expected, $actual, 'Array Sorted despite both Coupon can be accumulated');
-// }
-//
-// /**
-// * Testing how multiple Coupon behaviour
-// * Entering 1 Coupon cumulative expired
-// *
-// * @covers Thelia\Coupon\CouponManager::sortCoupons
-// */
-// public function testCouponCumulationOneCouponCumulativeExpired()
-// {
-// $cartTotalPrice = 100.00;
-// $checkoutTotalPrice = 120.00;
-//
-// // Given
-// /** @var CouponInterface $coupon */
-// $couponCumulative1 = $this->generateValidCoupon('XMAS1', null, null, null, null, null, new \DateTime(), null, true);
-//
-// $coupons = array($couponCumulative1);
-// /** @var AdapterInterface $stubCouponBaseAdapter */
-// $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice);
-//
-// // When
-// $sortedCoupons = PhpUnitUtils::callMethod(
-// new CouponManager($stubCouponBaseAdapter),
-// 'sortCoupons',
-// array($coupons)
-// );
-//
-// // Then
-// $expected = array();
-// $actual = $sortedCoupons;
-//
-// $this->assertSame($expected, $actual, 'Coupon expired ignored');
-// }
-//
-// /**
-// * Testing how multiple Coupon behaviour
-// * Entering 1 Coupon cumulative expired
-// * 1 Coupon cumulative expired
-// *
-// * @covers Thelia\Coupon\CouponManager::sortCoupons
-// */
-// public function testCouponCumulationTwoCouponCumulativeExpired()
-// {
-// $cartTotalPrice = 100.00;
-// $checkoutTotalPrice = 120.00;
-//
-// // Given
-// /** @var CouponInterface $coupon */
-// $couponCumulative1 = $this->generateValidCoupon('XMAS1', null, null, null, null, null, new \DateTime(), null, true);
-// $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, new \DateTime(), null, true);
-//
-// $coupons = array($couponCumulative1, $couponCumulative2);
-// /** @var AdapterInterface $stubCouponBaseAdapter */
-// $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice);
-//
-// // When
-// $sortedCoupons = PhpUnitUtils::callMethod(
-// new CouponManager($stubCouponBaseAdapter),
-// 'sortCoupons',
-// array($coupons)
-// );
-//
-// // Then
-// $expected = array();
-// $actual = $sortedCoupons;
-//
-// $this->assertSame($expected, $actual, 'Coupon expired ignored');
-// }
-//
-// /**
-// * Testing how multiple Coupon behaviour
-// * Entering 1 Coupon cumulative expired
-// * 1 Coupon cumulative valid
-// *
-// * @covers Thelia\Coupon\CouponManager::sortCoupons
-// */
-// public function testCouponCumulationOneCouponCumulativeExpiredOneNonExpired()
-// {
-// $cartTotalPrice = 100.00;
-// $checkoutTotalPrice = 120.00;
-//
-// // Given
-// /** @var CouponInterface $coupon */
-// $couponCumulative1 = $this->generateValidCoupon('XMAS1', null, null, null, null, null, new \DateTime(), null, true);
-// $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, null, null, true);
-//
-// $coupons = array($couponCumulative1, $couponCumulative2);
-// /** @var AdapterInterface $stubCouponBaseAdapter */
-// $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice);
-//
-// // When
-// $sortedCoupons = PhpUnitUtils::callMethod(
-// new CouponManager($stubCouponBaseAdapter),
-// 'sortCoupons',
-// array($coupons)
-// );
-//
-// // Then
-// $expected = array($couponCumulative2);
-// $actual = $sortedCoupons;
-//
-// $this->assertSame($expected, $actual, 'Coupon expired ignored');
-// }
-//
-// /**
-// * Testing how multiple Coupon behaviour
-// * Entering 1 Coupon cumulative valid
-// * 1 Coupon cumulative expired
-// *
-// * @covers Thelia\Coupon\CouponManager::sortCoupons
-// */
-// public function testCouponCumulationOneCouponCumulativeNonExpiredOneExpired()
-// {
-// $cartTotalPrice = 100.00;
-// $checkoutTotalPrice = 120.00;
-//
-// // Given
-// /** @var CouponInterface $coupon */
-// $couponCumulative1 = $this->generateValidCoupon('XMAS1', null, null, null, null, null, null, null, true);
-// $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, new \DateTime(), null, true);
-//
-// $coupons = array($couponCumulative1, $couponCumulative2);
-// /** @var AdapterInterface $stubCouponBaseAdapter */
-// $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice);
-//
-// // When
-// $sortedCoupons = PhpUnitUtils::callMethod(
-// new CouponManager($stubCouponBaseAdapter),
-// 'sortCoupons',
-// array($coupons)
-// );
-//
-// // Then
-// $expected = array($couponCumulative1);
-// $actual = $sortedCoupons;
-//
-// $this->assertSame($expected, $actual, 'Coupon expired ignored');
-// }
-//
-// /**
-// * Testing how multiple Coupon behaviour
-// * Entering 1 Coupon cumulative valid
-// * 1 Coupon cumulative valid
-// * 1 Coupon cumulative valid
-// * 1 Coupon cumulative valid
-// *
-// * @covers Thelia\Coupon\CouponManager::sortCoupons
-// */
-// public function testCouponCumulationFourCouponCumulative()
-// {
-// $cartTotalPrice = 100.00;
-// $checkoutTotalPrice = 120.00;
-//
-// // Given
-// /** @var CouponInterface $coupon */
-// $couponCumulative1 = $this->generateValidCoupon('XMAS1', null, null, null, null, null, null, null, true);
-// $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, null, null, true);
-// $couponCumulative3 = $this->generateValidCoupon('XMAS3', null, null, null, null, null, null, null, true);
-// $couponCumulative4 = $this->generateValidCoupon('XMAS4', null, null, null, null, null, null, null, true);
-//
-// $coupons = array($couponCumulative1, $couponCumulative2, $couponCumulative3, $couponCumulative4);
-// /** @var AdapterInterface $stubCouponBaseAdapter */
-// $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice);
-//
-// // When
-// $sortedCoupons = PhpUnitUtils::callMethod(
-// new CouponManager($stubCouponBaseAdapter),
-// 'sortCoupons',
-// array($coupons)
-// );
-//
-// // Then
-// $expected = $coupons;
-// $actual = $sortedCoupons;
-//
-// $this->assertSame($expected, $actual, 'Coupon cumulative ignored');
-// }
-//
-// /**
-// * Testing how multiple Coupon behaviour
-// * Entering 1 Coupon cumulative valid
-// * 1 Coupon cumulative valid
-// * 1 Coupon cumulative valid
-// * 1 Coupon non cumulative valid
-// *
-// * @covers Thelia\Coupon\CouponManager::sortCoupons
-// */
-// public function testCouponCumulationThreeCouponCumulativeOneNonCumulative()
-// {
-// $cartTotalPrice = 100.00;
-// $checkoutTotalPrice = 120.00;
-//
-// // Given
-// /** @var CouponInterface $coupon */
-// $couponCumulative1 = $this->generateValidCoupon('XMAS1', null, null, null, null, null, null, null, true);
-// $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, null, null, true);
-// $couponCumulative3 = $this->generateValidCoupon('XMAS3', null, null, null, null, null, null, null, true);
-// $couponCumulative4 = $this->generateValidCoupon('XMAS4', null, null, null, null, null, null, null, false);
-//
-// $coupons = array($couponCumulative1, $couponCumulative2, $couponCumulative3, $couponCumulative4);
-// /** @var AdapterInterface $stubCouponBaseAdapter */
-// $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice);
-//
-// // When
-// $sortedCoupons = PhpUnitUtils::callMethod(
-// new CouponManager($stubCouponBaseAdapter),
-// 'sortCoupons',
-// array($coupons)
-// );
-//
-// // Then
-// $expected = array($couponCumulative4);
-// $actual = $sortedCoupons;
-//
-// $this->assertSame($expected, $actual, 'Coupon cumulative ignored');
-// }
-//
-//
-// /**
-// * Generate valid CouponRuleInterfaces
-// *
-// * @return array Array of ConditionManagerInterface
-// */
-// public static function generateValidRules()
-// {
-// $adapter = new BaseAdapter();
-// $rule1 = new AvailableForTotalAmount(
-// $adapter, array(
-// AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator(
-// Operators::SUPERIOR,
-// new PriceParam(
-// $adapter, 40.00, 'EUR'
-// )
-// )
-// )
-// );
-// $rule2 = new AvailableForTotalAmount(
-// $adapter, array(
-// AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator(
-// Operators::INFERIOR,
-// new PriceParam(
-// $adapter, 400.00, 'EUR'
-// )
-// )
-// )
-// );
-// $rules = new ConditionCollection(array($rule1, $rule2));
-//
-// return $rules;
-// }
-//
-// /**
-// * Tears down the fixture, for example, closes a network connection.
-// * This method is called after a test is executed.
-// */
-// protected function tearDown()
-// {
-// }
-//
-// /**
-// * Generate a fake Adapter
-// *
-// * @param array $coupons Coupons
-// * @param float $cartTotalPrice Cart total price
-// * @param float $checkoutTotalPrice Checkout total price
-// * @param float $postagePrice Checkout postage price
-// *
-// * @return \PHPUnit_Framework_MockObject_MockObject
-// */
-// public function generateFakeAdapter(array $coupons, $cartTotalPrice, $checkoutTotalPrice, $postagePrice = 6.00)
-// {
-// $stubCouponBaseAdapter = $this->getMock(
-// 'Thelia\Coupon\BaseAdapter',
-// array(
-// 'getCurrentCoupons',
-// 'getCartTotalPrice',
-// 'getCheckoutTotalPrice',
-// 'getCheckoutPostagePrice'
-// ),
-// array()
-// );
-//
-// $stubCouponBaseAdapter->expects($this->any())
-// ->method('getCurrentCoupons')
-// ->will($this->returnValue(($coupons)));
-//
-// // Return Cart product amount = $cartTotalPrice euros
-// $stubCouponBaseAdapter->expects($this->any())
-// ->method('getCartTotalPrice')
-// ->will($this->returnValue($cartTotalPrice));
-//
-// // Return Checkout amount = $checkoutTotalPrice euros
-// $stubCouponBaseAdapter->expects($this->any())
-// ->method('getCheckoutTotalPrice')
-// ->will($this->returnValue($checkoutTotalPrice));
-//
-// $stubCouponBaseAdapter->expects($this->any())
-// ->method('getCheckoutPostagePrice')
-// ->will($this->returnValue($postagePrice));
-//
-// return $stubCouponBaseAdapter;
-// }
-//
-// /**
-// * Generate valid CouponInterface
-// *
-// * @param string $code Coupon Code
-// * @param string $title Coupon Title
-// * @param string $shortDescription Coupon short
-// * description
-// * @param string $description Coupon description
-// * @param float $amount Coupon discount
-// * @param bool $isEnabled Is Coupon enabled
-// * @param \DateTime $expirationDate Coupon expiration date
-// * @param ConditionCollection $rules Coupon rules
-// * @param bool $isCumulative If is cumulative
-// * @param bool $isRemovingPostage If is removing postage
-// * @param bool $isAvailableOnSpecialOffers If is available on
-// * special offers or not
-// * @param int $maxUsage How many time a Coupon
-// * can be used
-// *
-// * @return CouponInterface
-// */
-// public static function generateValidCoupon(
-// $code = null,
-// $title = null,
-// $shortDescription = null,
-// $description = null,
-// $amount = null,
-// $isEnabled = null,
-// $expirationDate = null,
-// $rules = null,
-// $isCumulative = null,
-// $isRemovingPostage = null,
-// $isAvailableOnSpecialOffers = null,
-// $maxUsage = null
-// ) {
-// $adapter = new BaseAdapter();
-// if ($code === null) {
-// $code = self::VALID_CODE;
-// }
-// if ($title === null) {
-// $title = self::VALID_TITLE;
-// }
-// if ($shortDescription === null) {
-// $shortDescription = self::VALID_SHORT_DESCRIPTION;
-// }
-// if ($description === null) {
-// $description = self::VALID_DESCRIPTION;
-// }
-// if ($amount === null) {
-// $amount = 10.00;
-// }
-// if ($isEnabled === null) {
-// $isEnabled = true;
-// }
-// if ($isCumulative === null) {
-// $isCumulative = true;
-// }
-// if ($isRemovingPostage === null) {
-// $isRemovingPostage = false;
-// }
-// if ($isAvailableOnSpecialOffers === null) {
-// $isAvailableOnSpecialOffers = true;
-// }
-// if ($maxUsage === null) {
-// $maxUsage = 40;
-// }
-//
-// if ($expirationDate === null) {
-// $expirationDate = new \DateTime();
-// $expirationDate->setTimestamp(strtotime("today + 2 months"));
-// }
-//
-// $coupon = new RemoveXAmount($adapter, $code, $title, $shortDescription, $description, $amount, $isCumulative, $isRemovingPostage, $isAvailableOnSpecialOffers, $isEnabled, $maxUsage, $expirationDate);
-//
-// if ($rules === null) {
-// $rules = self::generateValidRules();
-// }
-//
-// $coupon->setRules($rules);
-//
-// return $coupon;
-// }
}
diff --git a/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php b/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php
index 2b19ba130..0745e9b98 100644
--- a/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php
+++ b/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php
@@ -23,11 +23,6 @@
namespace Thelia\Coupon;
-use Thelia\Constraint\Validator\PriceParam;
-use Thelia\Constraint\Validator\RuleValidator;
-use Thelia\Constraint\Rule\AvailableForTotalAmount;
-use Thelia\Constraint\Rule\Operators;
-
/**
* Created by JetBrains PhpStorm.
* Date: 8/19/13
@@ -48,39 +43,4 @@ class CouponRuleCollectionTest extends \PHPUnit_Framework_TestCase
'This test has not been implemented yet.'
);
}
-// /**
-// *
-// */
-// public function testRuleSerialisation()
-// {
-//// $rule1 = new AvailableForTotalAmount(
-//// , array(
-//// AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator(
-//// Operators::SUPERIOR,
-//// new PriceParam(
-//// , 40.00, 'EUR'
-//// )
-//// )
-//// )
-//// );
-//// $rule2 = new AvailableForTotalAmount(
-//// , array(
-//// AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator(
-//// Operators::INFERIOR,
-//// new PriceParam(
-//// , 400.00, 'EUR'
-//// )
-//// )
-//// )
-//// );
-//// $rules = new ConditionCollection(array($rule1, $rule2));
-////
-//// $serializedRules = base64_encode(serialize($rules));
-//// $unserializedRules = unserialize(base64_decode($serializedRules));
-////
-//// $expected = $rules;
-//// $actual = $unserializedRules;
-////
-//// $this->assertEquals($expected, $actual);
-// }
}
diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php
index de739bf90..ee8ed3068 100644
--- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php
+++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php
@@ -23,10 +23,6 @@
namespace Thelia\Coupon;
-use Thelia\Constraint\Validator\PriceParam;
-use Thelia\Constraint\Validator\RuleValidator;
-use Thelia\Constraint\Rule\Operators;
-use Thelia\Coupon\Type\RemoveXAmountManager;
//require_once '../CouponManagerTest.php';
@@ -43,341 +39,27 @@ use Thelia\Coupon\Type\RemoveXAmountManager;
*/
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()
+ {
+ }
+
public function testSomething()
{
// Stop here and mark this test as incomplete.
$this->markTestIncomplete(
- 'This test has not been implemented yet.'
+ 'This coupon has not been implemented yet.'
);
}
-// /**
-// * Sets up the fixture, for example, opens a network connection.
-// * This method is called before a test is executed.
-// */
-// protected function setUp()
-// {
-//
-// }
-//
-// /**
-// * Test if a Coupon is well displayed
-// *
-// * @covers Thelia\Coupon\type\RemoveXAmountManager::getCode
-// * @covers Thelia\Coupon\type\RemoveXAmountManager::getTitle
-// * @covers Thelia\Coupon\type\RemoveXAmountManager::getShortDescription
-// * @covers Thelia\Coupon\type\RemoveXAmountManager::getDescription
-// *
-// */
-// public function testDisplay()
-// {
-// $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, true, true);
-//
-// $expected = CouponManagerTest::VALID_CODE;
-// $actual = $coupon->getCode();
-// $this->assertEquals($expected, $actual);
-//
-// $expected = CouponManagerTest::VALID_TITLE;
-// $actual = $coupon->getTitle();
-// $this->assertEquals($expected, $actual);
-//
-// $expected = CouponManagerTest::VALID_SHORT_DESCRIPTION;
-// $actual = $coupon->getShortDescription();
-// $this->assertEquals($expected, $actual);
-//
-// $expected = CouponManagerTest::VALID_DESCRIPTION;
-// $actual = $coupon->getDescription();
-// $this->assertEquals($expected, $actual);
-// }
-//
-// /**
-// * Test if a Coupon can be Cumulative
-// *
-// * @covers Thelia\Coupon\type\RemoveXAmountManager::isCumulative
-// *
-// */
-// public function testIsCumulative()
-// {
-// $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, true, true);
-//
-// $actual = $coupon->isCumulative();
-// $this->assertTrue($actual);
-// }
-//
-// /**
-// * Test if a Coupon can be non cumulative
-// *
-// * @covers Thelia\Coupon\type\RemoveXAmountManager::isCumulative
-// *
-// */
-// public function testIsNotCumulative()
-// {
-// $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false);
-//
-// $actual = $coupon->isCumulative();
-// $this->assertFalse($actual);
-// }
-//
-//
-// /**
-// * Test if a Coupon can remove postage
-// *
-// * @covers Thelia\Coupon\type\RemoveXAmountManager::isRemovingPostage
-// *
-// */
-// public function testIsRemovingPostage()
-// {
-// $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, true, true);
-//
-// $actual = $coupon->isRemovingPostage();
-// $this->assertTrue($actual);
-// }
-//
-// /**
-// * Test if a Coupon won't remove postage if not set to
-// *
-// * @covers Thelia\Coupon\type\RemoveXAmountManager::isRemovingPostage
-// */
-// public function testIsNotRemovingPostage()
-// {
-// $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false);
-//
-// $actual = $coupon->isRemovingPostage();
-// $this->assertFalse($actual);
-// }
-//
-//
-// /**
-// * Test if a Coupon has the effect expected (discount 10euros)
-// *
-// * @covers Thelia\Coupon\type\RemoveXAmountManager::getEffect
-// */
-// public function testGetEffect()
-// {
-// $adapter = new BaseAdapter();
-// $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false);
-//
-// $expected = 10;
-// $actual = $coupon->getDiscount();
-// $this->assertEquals($expected, $actual);
-// }
-//
-// /**
-// * Test Coupon rule setter
-// *
-// * @covers Thelia\Coupon\type\RemoveXAmountManager::setRules
-// * @covers Thelia\Coupon\type\RemoveXAmountManager::getRules
-// */
-// public function testSetRulesValid()
-// {
-// // Given
-// $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo(
-// Operators::EQUAL,
-// 20.00
-// );
-// $rule1 = $this->generateValidRuleAvailableForTotalAmountOperatorTo(
-// Operators::INFERIOR,
-// 100.23
-// );
-// $rule2 = $this->generateValidRuleAvailableForTotalAmountOperatorTo(
-// Operators::SUPERIOR,
-// 421.23
-// );
-//
-// $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false);
-//
-// // When
-// $coupon->setRules(new ConditionCollection(array($rule0, $rule1, $rule2)));
-//
-// // Then
-// $expected = 3;
-// $this->assertCount($expected, $coupon->getRules()->getRules());
-// }
-//
-// /**
-// * Test Coupon rule setter
-// *
-// * @covers Thelia\Coupon\type\RemoveXAmountManager::setRules
-// * @expectedException \Thelia\Exception\InvalidConditionException
-// *
-// */
-// public function testSetRulesInvalid()
-// {
-// // Given
-// $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo(
-// Operators::EQUAL,
-// 20.00
-// );
-// $rule1 = $this->generateValidRuleAvailableForTotalAmountOperatorTo(
-// Operators::INFERIOR,
-// 100.23
-// );
-// $rule2 = $this;
-//
-// $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false);
-//
-// // When
-// $coupon->setRules(new ConditionCollection(array($rule0, $rule1, $rule2)));
-// }
-//
-// /**
-// * Test Coupon effect for rule Total Amount < 400
-// *
-// * @covers Thelia\Coupon\type\RemoveXAmountManager::getEffect
-// *
-// */
-// public function testGetEffectIfTotalAmountInferiorTo400Valid()
-// {
-// // Given
-// $adapter = new BaseAdapter();
-// $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo(
-// Operators::INFERIOR,
-// 400.00
-// );
-// $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false);
-//
-// // When
-// $coupon->setRules(new ConditionCollection(array($rule0)));
-//
-// // Then
-// $expected = 10.00;
-// $actual = $coupon->getDiscount();
-// $this->assertEquals($expected, $actual);
-// }
-//
-// /**
-// * Test Coupon effect for rule Total Amount <= 400
-// *
-// * @covers Thelia\Coupon\type\RemoveXAmountManager::getEffect
-// *
-// */
-// public function testGetEffectIfTotalAmountInferiorOrEqualTo400Valid()
-// {
-// // Given
-// $adapter = new BaseAdapter();
-// $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo(
-// Operators::INFERIOR_OR_EQUAL,
-// 400.00
-// );
-// $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false);
-//
-// // When
-// $coupon->setRules(new ConditionCollection(array($rule0)));
-//
-// // Then
-// $expected = 10.00;
-// $actual = $coupon->getDiscount();
-// $this->assertEquals($expected, $actual);
-// }
-//
-// /**
-// * Test Coupon effect for rule Total Amount == 400
-// *
-// * @covers Thelia\Coupon\type\RemoveXAmountManager::getEffect
-// *
-// */
-// public function testGetEffectIfTotalAmountEqualTo400Valid()
-// {
-// // Given
-// $adapter = new BaseAdapter();
-// $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo(
-// Operators::EQUAL,
-// 400.00
-// );
-// $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false);
-//
-// // When
-// $coupon->setRules(new ConditionCollection(array($rule0)));
-//
-// // Then
-// $expected = 10.00;
-// $actual = $coupon->getDiscount();
-// $this->assertEquals($expected, $actual);
-// }
-//
-// /**
-// * Test Coupon effect for rule Total Amount >= 400
-// *
-// * @covers Thelia\Coupon\type\RemoveXAmountManager::getEffect
-// *
-// */
-// public function testGetEffectIfTotalAmountSuperiorOrEqualTo400Valid()
-// {
-// // Given
-// $adapter = new BaseAdapter();
-// $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo(
-// Operators::SUPERIOR_OR_EQUAL,
-// 400.00
-// );
-// $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false);
-//
-// // When
-// $coupon->setRules(new ConditionCollection(array($rule0)));
-//
-// // Then
-// $expected = 10.00;
-// $actual = $coupon->getDiscount();
-// $this->assertEquals($expected, $actual);
-// }
-//
-// /**
-// * Test Coupon effect for rule Total Amount > 400
-// *
-// * @covers Thelia\Coupon\type\RemoveXAmountManager::getEffect
-// *
-// */
-// public function testGetEffectIfTotalAmountSuperiorTo400Valid()
-// {
-// // Given
-// $adapter = new BaseAdapter();
-// $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo(
-// Operators::SUPERIOR,
-// 400.00
-// );
-// $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false);
-//
-// // When
-// $coupon->setRules(new ConditionCollection(array($rule0)));
-//
-// // Then
-// $expected = 10.00;
-// $actual = $coupon->getDiscount();
-// $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()
-// {
-// }
-//
-// /**
-// * Generate valid rule AvailableForTotalAmount
-// * according to given operator and amount
-// *
-// * @param string $operator Operators::CONST
-// * @param float $amount Amount with 2 decimals
-// *
-// * @return AvailableForTotalAmount
-// */
-// protected function generateValidRuleAvailableForTotalAmountOperatorTo($operator, $amount)
-// {
-// $adapter = new BaseAdapter();
-// $validators = array(
-// AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator(
-// $operator,
-// new PriceParam(
-// $adapter,
-// $amount,
-// 'EUR'
-// )
-// )
-// );
-//
-// return new AvailableForTotalAmount($adapter, $validators);
-// }
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ protected function tearDown()
+ {
+ }
}
diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php
index b1b012fb3..bbb0c24a3 100644
--- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php
+++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php
@@ -24,11 +24,6 @@
namespace Thelia\Coupon;
use PHPUnit_Framework_TestCase;
-use Thelia\Constraint\Rule\Operators;
-use Thelia\Constraint\Validator\PriceParam;
-use Thelia\Constraint\Validator\RuleValidator;
-use Thelia\Coupon\Type\CouponInterface;
-use Thelia\Coupon\Type\RemoveXPercentManager;
//require_once '../CouponManagerTest.php';
@@ -46,412 +41,27 @@ use Thelia\Coupon\Type\RemoveXPercentManager;
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()
+ {
+ }
+
public function testSomething()
{
- // Stop here and mark this test as incomplete.
$this->markTestIncomplete(
- 'This test has not been implemented yet.'
+ 'This coupon has not been implemented yet.'
);
}
-// /**
-// * Sets up the fixture, for example, opens a network connection.
-// * This method is called before a test is executed.
-// */
-// protected function setUp()
-// {
-// }
-//
-// /**
-// * Test if a Coupon can be Cumulative
-// *
-// * @covers Thelia\Coupon\type\RemoveXPercentManager::isCumulative
-// *
-// */
-// public function testIsCumulative()
-// {
-// $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, true, true);
-//
-// $actual = $coupon->isCumulative();
-// $this->assertTrue($actual);
-// }
-//
-// /**
-// * Test if a Coupon can be non cumulative
-// *
-// * @covers Thelia\Coupon\type\RemoveXPercentManager::isCumulative
-// *
-// */
-// public function testIsNotCumulative()
-// {
-// $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false);
-//
-// $actual = $coupon->isCumulative();
-// $this->assertFalse($actual);
-// }
-//
-//
-// /**
-// * Test if a Coupon can remove postage
-// *
-// * @covers Thelia\Coupon\type\RemoveXPercentManager::isRemovingPostage
-// *
-// */
-// public function testIsRemovingPostage()
-// {
-// $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, true, true);
-//
-// $actual = $coupon->isRemovingPostage();
-// $this->assertTrue($actual);
-// }
-//
-// /**
-// * Test if a Coupon won't remove postage if not set to
-// *
-// * @covers Thelia\Coupon\type\RemoveXPercentManager::isRemovingPostage
-// */
-// public function testIsNotRemovingPostage()
-// {
-// $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false);
-//
-// $actual = $coupon->isRemovingPostage();
-// $this->assertFalse($actual);
-// }
-//
-//
-// /**
-// * Test if a Coupon has the effect expected (discount 10euros)
-// *
-// * @covers Thelia\Coupon\type\RemoveXPercentManager::getEffect
-// */
-// public function testGetEffect()
-// {
-// $adapter = $this->generateFakeAdapter(245);
-// $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false);
-//
-// $expected = 24.50;
-// $actual = $coupon->getDiscount($adapter);
-// $this->assertEquals($expected, $actual);
-// }
-//
-// /**
-// * Test Coupon rule setter
-// *
-// * @covers Thelia\Coupon\type\RemoveXPercentManager::setRules
-// * @covers Thelia\Coupon\type\RemoveXPercentManager::getRules
-// */
-// public function testSetRulesValid()
-// {
-// // Given
-// $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo(
-// Operators::EQUAL,
-// 20.00
-// );
-// $rule1 = $this->generateValidRuleAvailableForTotalAmountOperatorTo(
-// Operators::INFERIOR,
-// 100.23
-// );
-// $rule2 = $this->generateValidRuleAvailableForTotalAmountOperatorTo(
-// Operators::SUPERIOR,
-// 421.23
-// );
-//
-// $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false);
-//
-// // When
-// $coupon->setRules(new ConditionCollection(array($rule0, $rule1, $rule2)));
-//
-// // Then
-// $expected = 3;
-// $this->assertCount($expected, $coupon->getRules()->getRules());
-// }
-//
-// /**
-// * Test Coupon rule setter
-// *
-// * @covers Thelia\Coupon\type\RemoveXPercentManager::setRules
-// * @expectedException \Thelia\Exception\InvalidConditionException
-// *
-// */
-// public function testSetRulesInvalid()
-// {
-// // Given
-// $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo(
-// Operators::EQUAL,
-// 20.00
-// );
-// $rule1 = $this->generateValidRuleAvailableForTotalAmountOperatorTo(
-// Operators::INFERIOR,
-// 100.23
-// );
-// $rule2 = $this;
-//
-// $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false);
-//
-// // When
-// $coupon->setRules(new ConditionCollection(array($rule0, $rule1, $rule2)));
-// }
-//
-// /**
-// * Test Coupon effect for rule Total Amount < 400
-// *
-// * @covers Thelia\Coupon\type\RemoveXPercentManager::getEffect
-// *
-// */
-// public function testGetEffectIfTotalAmountInferiorTo400Valid()
-// {
-// // Given
-// $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo(
-// Operators::INFERIOR,
-// 400.00
-// );
-// $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false);
-//
-// // When
-// $coupon->setRules(new ConditionCollection(array($rule0)));
-//
-// // Then
-// $expected = 24.50;
-// $actual = $coupon->getDiscount();
-// $this->assertEquals($expected, $actual);
-// }
-//
-// /**
-// * Test Coupon effect for rule Total Amount <= 400
-// *
-// * @covers Thelia\Coupon\type\RemoveXPercentManager::getEffect
-// *
-// */
-// public function testGetEffectIfTotalAmountInferiorOrEqualTo400Valid()
-// {
-// // Given
-// $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo(
-// Operators::INFERIOR_OR_EQUAL,
-// 400.00
-// );
-// $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false);
-//
-// // When
-// $coupon->setRules(new ConditionCollection(array($rule0)));
-//
-// // Then
-// $expected = 24.50;
-// $actual = $coupon->getDiscount();
-// $this->assertEquals($expected, $actual);
-// }
-//
-// /**
-// * Test Coupon effect for rule Total Amount == 400
-// *
-// * @covers Thelia\Coupon\type\RemoveXPercentManager::getEffect
-// *
-// */
-// public function testGetEffectIfTotalAmountEqualTo400Valid()
-// {
-// // Given
-// $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo(
-// Operators::EQUAL,
-// 400.00
-// );
-// $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false);
-//
-// // When
-// $coupon->setRules(new ConditionCollection(array($rule0)));
-//
-// // Then
-// $expected = 24.50;
-// $actual = $coupon->getDiscount();
-// $this->assertEquals($expected, $actual);
-// }
-//
-// /**
-// * Test Coupon effect for rule Total Amount >= 400
-// *
-// * @covers Thelia\Coupon\type\RemoveXPercentManager::getEffect
-// *
-// */
-// public function testGetEffectIfTotalAmountSuperiorOrEqualTo400Valid()
-// {
-// // Given
-// $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo(
-// Operators::SUPERIOR_OR_EQUAL,
-// 400.00
-// );
-// $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false);
-//
-// // When
-// $coupon->setRules(new ConditionCollection(array($rule0)));
-//
-// // Then
-// $expected = 24.50;
-// $actual = $coupon->getDiscount();
-// $this->assertEquals($expected, $actual);
-// }
-//
-// /**
-// * Test Coupon effect for rule Total Amount > 400
-// *
-// * @covers Thelia\Coupon\type\RemoveXPercentManager::getEffect
-// *
-// */
-// public function testGetEffectIfTotalAmountSuperiorTo400Valid()
-// {
-// // Given
-// $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo(
-// Operators::SUPERIOR,
-// 400.00
-// );
-// $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false);
-//
-// // When
-// $coupon->setRules(new ConditionCollection(array($rule0)));
-//
-// // Then
-// $expected = 24.50;
-// $actual = $coupon->getDiscount();
-// $this->assertEquals($expected, $actual);
-// }
-//
-// /**
-// * Generate valid CouponInterface
-// *
-// * @param string $code Coupon Code
-// * @param string $title Coupon Title
-// * @param string $shortDescription Coupon short
-// * description
-// * @param string $description Coupon description
-// * @param float $amount Coupon discount
-// * @param bool $isEnabled Is Coupon enabled
-// * @param \DateTime $expirationDate Coupon expiration date
-// * @param ConditionCollection $rules Coupon rules
-// * @param bool $isCumulative If is cumulative
-// * @param bool $isRemovingPostage If is removing postage
-// * @param bool $isAvailableOnSpecialOffers If is available on
-// * special offers or not
-// * @param int $maxUsage How many time a Coupon
-// * can be used
-// *
-// * @return CouponInterface
-// */
-// public function generateValidCoupon(
-// $code = null,
-// $title = null,
-// $shortDescription = null,
-// $description = null,
-// $percent = null,
-// $isEnabled = null,
-// $expirationDate = null,
-// $rules = null,
-// $isCumulative = null,
-// $isRemovingPostage = null,
-// $isAvailableOnSpecialOffers = null,
-// $maxUsage = null
-// ) {
-// $adapter = $this->generateFakeAdapter(245);
-//
-// if ($code === null) {
-// $code = CouponManagerTest::VALID_CODE;
-// }
-// if ($title === null) {
-// $title = CouponManagerTest::VALID_TITLE;
-// }
-// if ($shortDescription === null) {
-// $shortDescription = CouponManagerTest::VALID_SHORT_DESCRIPTION;
-// }
-// if ($description === null) {
-// $description = CouponManagerTest::VALID_DESCRIPTION;
-// }
-// if ($percent === null) {
-// $percent = 10.00;
-// }
-// if ($isEnabled === null) {
-// $isEnabled = true;
-// }
-// if ($isCumulative === null) {
-// $isCumulative = true;
-// }
-// if ($isRemovingPostage === null) {
-// $isRemovingPostage = false;
-// }
-// if ($isAvailableOnSpecialOffers === null) {
-// $isAvailableOnSpecialOffers = true;
-// }
-// if ($maxUsage === null) {
-// $maxUsage = 40;
-// }
-//
-// if ($expirationDate === null) {
-// $expirationDate = new \DateTime();
-// $expirationDate->setTimestamp(strtotime("today + 2 months"));
-// }
-//
-// $coupon = new RemoveXPercent($adapter, $code, $title, $shortDescription, $description, $percent, $isCumulative, $isRemovingPostage, $isAvailableOnSpecialOffers, $isEnabled, $maxUsage, $expirationDate);
-//
-// if ($rules === null) {
-// $rules = CouponManagerTest::generateValidRules();
-// }
-//
-// $coupon->setRules($rules);
-//
-// return $coupon;
-// }
-//
-//
-// /**
-// * Generate valid rule AvailableForTotalAmount
-// * according to given operator and amount
-// *
-// * @param string $operator Operators::CONST
-// * @param float $amount Amount with 2 decimals
-// *
-// * @return AvailableForTotalAmount
-// */
-// protected function generateValidRuleAvailableForTotalAmountOperatorTo($operator, $amount)
-// {
-// $adapter = new BaseAdapter();
-// $validators = array(
-// AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator(
-// $operator,
-// new PriceParam(
-// $adapter,
-// $amount,
-// 'EUR'
-// )
-// )
-// );
-//
-// return new AvailableForTotalAmount($adapter, $validators);
-// }
-//
-// /**
-// * Generate a fake Adapter
-// *
-// * @param float $cartTotalPrice Cart total price
-// *
-// * @return \PHPUnit_Framework_MockObject_MockObject
-// */
-// public function generateFakeAdapter($cartTotalPrice)
-// {
-// $stubCouponBaseAdapter = $this->getMock(
-// 'Thelia\Coupon\BaseAdapter',
-// array(
-// 'getCartTotalPrice'
-// ),
-// array()
-// );
-//
-// $stubCouponBaseAdapter->expects($this->any())
-// ->method('getCartTotalPrice')
-// ->will($this->returnValue(($cartTotalPrice)));
-//
-// return $stubCouponBaseAdapter;
-// }
-//
-// /**
-// * Tears down the fixture, for example, closes a network connection.
-// * This method is called after a test is executed.
-// */
-// protected function tearDown()
-// {
-// }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ protected function tearDown()
+ {
+ }
}
diff --git a/core/lib/Thelia/Tests/Tools/FileManagerTest.php b/core/lib/Thelia/Tests/Tools/FileManagerTest.php
index 0b8e2f9de..3ad898ef2 100644
--- a/core/lib/Thelia/Tests/Tools/FileManagerTest.php
+++ b/core/lib/Thelia/Tests/Tools/FileManagerTest.php
@@ -33,7 +33,7 @@ class FileManagerTest extends \PHPUnit_Framework_TestCase
public function testCopyUploadedFile()
{
$this->markTestIncomplete(
- 'Mock issue'
+ 'This test has not been implemented yet : Mock issue'
);
$stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
@@ -112,7 +112,7 @@ class FileManagerTest extends \PHPUnit_Framework_TestCase
public function testCopyUploadedFileExceptionImageException()
{
$this->markTestIncomplete(
- 'Mock issue'
+ 'This test has not been implemented yet : Mock issue'
);
$stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
diff --git a/install/faker.php b/install/faker.php
index 86b401aee..60bc2bb81 100755
--- a/install/faker.php
+++ b/install/faker.php
@@ -5,7 +5,7 @@ use Thelia\Condition\Implementation\MatchForEveryoneManager;
use Thelia\Condition\Implementation\MatchForTotalAmountManager;
use Thelia\Condition\Implementation\MatchForXArticlesManager;
use Thelia\Condition\Operators;
-use Thelia\Coupon\AdapterInterface;
+use Thelia\Coupon\FacadeInterface;
use Thelia\Coupon\ConditionCollection;
@@ -644,7 +644,7 @@ function generateCouponFixtures(\Thelia\Core\Thelia $thelia)
{
/** @var $container ContainerInterface Service Container */
$container = $thelia->getContainer();
- /** @var AdapterInterface $adapter */
+ /** @var FacadeInterface $adapter */
$adapter = $container->get('thelia.adapter');
// Coupons
diff --git a/templates/admin/default/assets/js/coupon.js b/templates/admin/default/assets/js/coupon.js
index 68cfb42e9..2c412765a 100644
--- a/templates/admin/default/assets/js/coupon.js
+++ b/templates/admin/default/assets/js/coupon.js
@@ -55,7 +55,7 @@ $(function($){
$.couponManager.conditionToSave = $.couponManager.conditionsToSave[id];
// Set the condition selector
- $("#category-rule option").filter(function() {
+ $("#category-condition option").filter(function() {
return $(this).val() == $.couponManager.conditionToSave.serviceId;
}).prop('selected', true);
@@ -89,8 +89,8 @@ $(function($){
// Save conditions on click
$.couponManager.onClickSaveCondition = function() {
- $('#constraint-save-btn').on('click', function () {
- if($('#category-rule').val() == 'thelia.condition.match_for_everyone') {
+ $('#condition-save-btn').on('click', function () {
+ if($('#category-condition').val() == 'thelia.condition.match_for_everyone') {
// // @todo translate message + put it in modal
var r = confirm("Do you really want to set this coupon available to everyone ?");
if (r == true) {
@@ -106,7 +106,7 @@ $(function($){
// Remove condition on click
$.couponManager.onClickDeleteCondition = function() {
- $('.constraint-delete-btn').on('click', function (e) {
+ $('.condition-delete-btn').on('click', function (e) {
e.preventDefault();
var $this = $(this);
$.couponManager.removeConditionAjax($this.attr('data-int'));
@@ -140,7 +140,7 @@ $(function($){
// Reload condition inputs when changing effect
$.couponManager.onConditionChange = function() {
- $('#category-rule').on('change', function () {
+ $('#category-condition').on('change', function () {
$.couponManager.loadConditionInputs($(this).val(), function() {});
});
};
@@ -152,9 +152,9 @@ $(function($){
// Set max usage to unlimited or not
$.couponManager.onUsageUnlimitedChange = function() {
- var isUnlimited = $('#is-unlimited');
+ var $isUnlimited = $('#is-unlimited');
if ($('#max-usage').val() == -1) {
- isUnlimited.prop('checked', true);
+ $isUnlimited.prop('checked', true);
$('#max-usage').hide();
$('#max-usage-label').hide();
} else {
@@ -163,7 +163,7 @@ $(function($){
$('#max-usage-label').show();
}
- isUnlimited.change(function(){
+ $isUnlimited.change(function(){
var $this = $(this);
if ($this.is(':checked')) {
$('#max-usage').hide().val('-1');
diff --git a/templates/admin/default/coupon-create.html b/templates/admin/default/coupon-create.html
index f82501916..19f4bf795 100755
--- a/templates/admin/default/coupon-create.html
+++ b/templates/admin/default/coupon-create.html
@@ -45,9 +45,25 @@
{/javascripts}
- {**}
- {**}
+
{/javascripts}
+