- Coupon - add rule AJAX
This commit is contained in:
gmorel
2013-09-09 16:40:53 +02:00
parent 849520eff9
commit b778898d92
23 changed files with 689 additions and 132 deletions

View File

@@ -219,26 +219,34 @@
<argument type="service" id="service_container" />
</service>
<service id="thelia.coupon.manager" class="Thelia\Coupon\CouponManager">
<argument type="service" id="thelia.adapter" />
<argument type="service" id="service_container" />
</service>
<service id="thelia.coupon.factory" class="Thelia\Coupon\CouponFactory">
<argument type="service" id="service_container" />
</service>
<service id="thelia.constraint.factory" class="Thelia\Constraint\ConstraintFactory">
<argument type="service" id="service_container" />
</service>
<service id="thelia.constraint.rule.available_for_everyone" class="Thelia\Constraint\Rule\AvailableForEveryoneManager">
<argument type="service" id="thelia.adapter" />
<tag name="thelia.coupon.addRule"/>
</service>
<service id="thelia.constraint.rule.available_for_x_articles" class="Thelia\Constraint\Rule\AvailableForXArticlesManager">
<argument type="service" id="thelia.translator" />
<argument type="service" id="thelia.adapter" />
<tag name="thelia.coupon.addRule"/>
</service>
<service id="thelia.constraint.rule.available_for_total_amount" class="Thelia\Constraint\Rule\AvailableForTotalAmountManager">
<argument type="service" id="thelia.translator" />
<argument type="service" id="thelia.adapter" />
<tag name="thelia.coupon.addRule"/>
</service>
<service id="thelia.coupon.type.remove_x_amount" class="Thelia\Coupon\Type\RemoveXAmount">
<argument type="service" id="thelia.translator" />
<service id="thelia.coupon.type.remove_x_amount" class="Thelia\Coupon\Type\RemoveXAmountManager">
<argument type="service" id="thelia.adapter" />
<tag name="thelia.coupon.addCoupon"/>
</service>
<service id="thelia.coupon.type.remove_x_percent" class="Thelia\Coupon\Type\RemoveXPercent">
<argument type="service" id="thelia.translator" />
<service id="thelia.coupon.type.remove_x_percent" class="Thelia\Coupon\Type\RemoveXPercentManager">
<argument type="service" id="thelia.adapter" />
<tag name="thelia.coupon.addCoupon"/>
</service>

View File

@@ -0,0 +1,135 @@
<?php
/**********************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/**********************************************************************************/
namespace Thelia\Constraint\Rule;
use InvalidArgumentException;
use Symfony\Component\Translation\Translator;
use Thelia\Constraint\ConstraintValidator;
use Thelia\Constraint\Validator\QuantityParam;
use Thelia\Constraint\Validator\RuleValidator;
use Thelia\Coupon\CouponAdapterInterface;
use Thelia\Exception\InvalidRuleException;
use Thelia\Exception\InvalidRuleValueException;
use Thelia\Type\FloatType;
/**
* Created by JetBrains PhpStorm.
* Date: 8/19/13
* Time: 3:24 PM
*
* Allow every one, perform no check
*
* @package Constraint
* @author Guillaume MOREL <gmorel@openstudio.fr>
*
*/
class AvailableForEveryoneManager extends CouponRuleAbstract
{
/** @var string Service Id from Resources/config.xml */
protected $serviceId = 'thelia.constraint.rule.available_for_everyone';
/** @var array Available Operators (Operators::CONST) */
protected $availableOperators = array();
/**
* Check validators relevancy and store them
*
* @param array $operators Operators the Admin set in BackOffice
* @param array $values Values the Admin set in BackOffice
*
* @throws \InvalidArgumentException
* @return $this
*/
public function setValidatorsFromForm(array $operators, array $values)
{
$this->setValidators();
return $this;
}
/**
* Check validators relevancy and store them
*
* @throws \InvalidArgumentException
* @return $this
*/
protected function setValidators()
{
$this->operators = array();
$this->values = array();
return $this;
}
/**
* Test if Customer meets conditions
*
* @return bool
*/
public function isMatching()
{
return true;
}
/**
* Get I18n name
*
* @return string
*/
public function getName()
{
return $this->translator->trans(
'Everybody can use it (no condition)',
array(),
'constraint'
);
}
/**
* Get I18n tooltip
*
* @return string
*/
public function getToolTip()
{
$toolTip = $this->translator->trans(
'Will return always true',
array(),
'constraint'
);
return $toolTip;
}
/**
* Generate inputs ready to be drawn
*
* @return array
*/
protected function generateInputs()
{
return array();
}
}

View File

@@ -32,6 +32,8 @@ use Thelia\Constraint\Validator\RuleValidator;
use Thelia\Exception\InvalidRuleException;
use Thelia\Exception\InvalidRuleOperatorException;
use Thelia\Exception\InvalidRuleValueException;
use Thelia\Model\Currency;
use Thelia\Model\CurrencyQuery;
use Thelia\Type\FloatType;
/**
@@ -297,7 +299,7 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract
*/
public function getName()
{
return $this->adapter->get('thelia.translator')->trans(
return $this->translator->trans(
'Cart total amount',
array(),
'constraint'
@@ -328,6 +330,40 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract
return $toolTip;
}
/**
* Generate inputs ready to be drawn
*
* @return array
*/
protected function generateInputs()
{
$currencies = CurrencyQuery::create()->find();
$cleanedCurrencies = array();
/** @var Currency $currency */
foreach ($currencies as $currency) {
$cleanedCurrencies[$currency->getCode()] = $currency->getSymbol();
}
return array(
self::INPUT1 => array(
'availableOperators' => $this->availableOperators[self::INPUT1],
'availableValues' => '',
'type' => 'text',
'class' => 'form-control',
'value' => '',
'selectedOperator' => ''
),
self::INPUT2 => array(
'availableOperators' => $this->availableOperators[self::INPUT2],
'availableValues' => $cleanedCurrencies,
'type' => 'select',
'class' => 'form-control',
'value' => '',
'selectedOperator' => Operators::EQUAL
)
);
}
// /**
// * Populate a Rule from a form admin
// *

View File

@@ -297,4 +297,22 @@ class AvailableForXArticlesManager extends CouponRuleAbstract
// return $this;
// }
/**
* Generate inputs ready to be drawn
*
* @return array
*/
protected function generateInputs()
{
return array(
self::INPUT1 => array(
'availableOperators' => $this->availableOperators[self::INPUT1],
'type' => 'text',
'class' => 'form-control',
'value' => '',
'selectedOperator' => ''
)
);
}
}

View File

@@ -188,9 +188,35 @@ abstract class CouponRuleAbstract implements CouponRuleInterface
*/
public function getValidators()
{
return array(
$this->operators,
$this->values
$this->validators = $this->generateInputs();
$translatedInputs = array();
foreach ($this->validators as $key => $validator) {
$translatedOperators = array();
foreach ($validator['availableOperators'] as $availableOperators) {
$translatedOperators[$availableOperators] = Operators::getI18n(
$this->translator,
$availableOperators
);
}
$validator['availableOperators'] = $translatedOperators;
$translatedInputs[$key] = $validator;
}
return $translatedInputs;
}
/**
* Generate inputs ready to be drawn
*
* @throws \Thelia\Exception\NotImplementedException
* @return array
*/
protected function generateInputs()
{
throw new \Thelia\Exception\NotImplementedException(
'The generateInputs method must be implemented in ' . get_class()
);
}

View File

@@ -141,4 +141,6 @@ interface CouponRuleInterface
}

View File

@@ -24,6 +24,7 @@
namespace Thelia\Controller\Admin;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Router;
use Thelia\Constraint\ConstraintFactory;
use Thelia\Constraint\ConstraintFactoryTest;
use Thelia\Constraint\Rule\AvailableForTotalAmount;
@@ -38,7 +39,9 @@ use Thelia\Core\Security\Exception\AuthenticationException;
use Thelia\Core\Security\Exception\AuthorizationException;
use Thelia\Core\Translation\Translator;
use Thelia\Coupon\CouponAdapterInterface;
use Thelia\Coupon\CouponManager;
use Thelia\Coupon\CouponRuleCollection;
use Thelia\Coupon\Type\CouponInterface;
use Thelia\Form\CouponCreationForm;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Log\Tlog;
@@ -142,7 +145,7 @@ class CouponController extends BaseAdminController
$i18n = new I18n();
/** @var Lang $lang */
$lang = $this->getSession()->get('lang');
$lang = $this->getSession()->getLang();
$eventToDispatch = TheliaEvents::COUPON_UPDATE;
if ($this->getRequest()->isMethod('POST')) {
@@ -172,14 +175,16 @@ class CouponController extends BaseAdminController
'locale' => $coupon->getLocale(),
);
/** @var CouponAdapterInterface $adapter */
$adapter = $this->container->get('thelia.adapter');
/** @var Translator $translator */
$translator = $this->container->get('thelia.translator');
$args['rulesObject'] = array();
/** @var ConstraintFactory $constraintFactory */
$constraintFactory = $this->container->get('thelia.constraint.factory');
$rules = $constraintFactory->unserializeCouponRuleCollection(
$coupon->getSerializedRules()
);
/** @var CouponRuleInterface $rule */
foreach ($coupon->getRules()->getRules() as $rule) {
foreach ($rules as $rule) {
$args['rulesObject'][] = array(
'name' => $rule->getName(),
'tooltip' => $rule->getToolTip(),
@@ -194,6 +199,15 @@ class CouponController extends BaseAdminController
$this->getParserContext()->addForm($changeForm);
}
$args['availableCoupons'] = $this->getAvailableCoupons();
$args['availableRules'] = $this->getAvailableRules();
$args['urlAjaxGetRuleInput'] = $this->getRouteFromRouter(
'router.admin',
'admin.coupon.rule.input',
array('ruleId' => 'ruleId'),
Router::ABSOLUTE_URL
);
$args['formAction'] = 'admin/coupon/update/' . $couponId;
return $this->render(
@@ -489,6 +503,52 @@ class CouponController extends BaseAdminController
return $this;
}
/**
* Get all available rules
*
* @return array
*/
protected function getAvailableRules()
{
/** @var CouponManager $couponManager */
$couponManager = $this->container->get('thelia.coupon.manager');
$availableRules = $couponManager->getAvailableRules();
$cleanedRules = array();
/** @var CouponRuleInterface $availableRule */
foreach ($availableRules as $availableRule) {
$rule = array();
$rule['serviceId'] = $availableRule->getServiceId();
$rule['name'] = $availableRule->getName();
$rule['toolTip'] = $availableRule->getToolTip();
$cleanedRules[] = $rule;
}
return $cleanedRules;
}
/**
* Get all available coupons
*
* @return array
*/
protected function getAvailableCoupons()
{
/** @var CouponManager $couponManager */
$couponManager = $this->container->get('thelia.coupon.manager');
$availableCoupons = $couponManager->getAvailableCoupons();
$cleanedRules = array();
/** @var CouponInterface $availableCoupon */
foreach ($availableCoupons as $availableCoupon) {
$rule = array();
$rule['serviceId'] = $availableCoupon->getServiceId();
$rule['name'] = $availableCoupon->getName();
$rule['toolTip'] = $availableCoupon->getToolTip();
$cleanedRules[] = $rule;
}
return $cleanedRules;
}
// /**
// * Validation Rule creation
// *
@@ -511,4 +571,6 @@ class CouponController extends BaseAdminController
// }
// }
}

View File

@@ -55,11 +55,11 @@ class RegisterRulePass implements CompilerPassInterface
}
$couponManager = $container->getDefinition('thelia.coupon.manager');
$services = $container->findTaggedServiceIds("thelia.coupon.addCoupon");
$services = $container->findTaggedServiceIds("thelia.coupon.addRule");
foreach ($services as $id => $rule) {
$couponManager->addMethodCall(
'addAvailableCoupon',
'addAvailableRule',
array(
new Reference($id)
)

View File

@@ -147,7 +147,7 @@ class CouponBaseAdapter implements CouponAdapterInterface
*/
public function getCurrentCoupons()
{
$couponFactory = new CouponFactory($this);
$couponFactory = $this->container->get('thelia.coupon.factory');
// @todo Get from Session
$couponCodes = array('XMAS', 'SPRINGBREAK');

View File

@@ -23,7 +23,9 @@
namespace Thelia\Coupon;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Translation\Exception\NotFoundResourceException;
use Thelia\Constraint\ConstraintFactory;
use Thelia\Constraint\Rule\CouponRuleInterface;
use Thelia\Coupon\Type\CouponInterface;
use Thelia\Exception\CouponExpiredException;
@@ -44,17 +46,21 @@ use Symfony\Component\Serializer\Encoder\JsonEncoder;
*/
class CouponFactory
{
/** @var ContainerInterface Service Container */
protected $container = null;
/** @var CouponAdapterInterface Provide necessary value from Thelia*/
protected $adapter;
/**
* Constructor
*
* @param CouponAdapterInterface $adapter Provide necessary value from Thelia
* @param ContainerInterface $container Service container
*/
function __construct(CouponAdapterInterface $adapter)
function __construct(ContainerInterface $container)
{
$this->adapter = $adapter;
$this->container = $container;
$this->adapter = $container->get('thelia.adapter');
}
/**
@@ -102,10 +108,15 @@ class CouponFactory
{
$isCumulative = ($model->getIsCumulative() == 1 ? true : false);
$isRemovingPostage = ($model->getIsRemovingPostage() == 1 ? true : false);
$couponClass = $model->getType();
/** @var CouponInterface $coupon*/
$coupon = new $couponClass(
if (!$this->container->has($model->getType())) {
return false;
}
/** @var CouponInterface $couponManager*/
$couponManager = $this->container->get($model->getType());
$couponManager->set(
$this->adapter,
$model->getCode(),
$model->getTitle(),
$model->getShortDescription(),
@@ -119,12 +130,15 @@ class CouponFactory
$model->getExpirationDate()
);
/** @var CouponRuleCollection $rules */
$rules = unserialize(base64_decode($model->getSerializedRules()));
/** @var ConstraintFactory $constraintFactory */
$constraintFactory = $this->container->get('thelia.constraint.factory');
$rules = $constraintFactory->unserializeCouponRuleCollection(
$model->getSerializedRules()
);
$coupon->setRules($rules);
$couponManager->setRules($rules);
return $coupon;
return $couponManager;
}

View File

@@ -49,6 +49,12 @@ class CouponManager
/** @var array CouponInterface to process*/
protected $coupons = array();
/** @var array Available Coupons (Services) */
protected $availableCoupons = array();
/** @var array Available Rules (Services) */
protected $availableRules = array();
/**
* Constructor
*
@@ -208,4 +214,44 @@ class CouponManager
return $rule;
}
/**
* Add an available CouponManager (Services)
*
* @param CouponInterface $coupon CouponManager
*/
public function addAvailableCoupon(CouponInterface $coupon)
{
$this->availableCoupons[] = $coupon;
}
/**
* Get all available CouponManagers (Services)
*
* @return array
*/
public function getAvailableCoupons()
{
return $this->availableCoupons;
}
/**
* Add an available ConstraintManager (Services)
*
* @param CouponRuleInterface $rule CouponRuleInterface
*/
public function addAvailableRule(CouponRuleInterface $rule)
{
$this->availableRules[] = $rule;
}
/**
* Get all available ConstraintManagers (Services)
*
* @return array
*/
public function getAvailableRules()
{
return $this->availableRules;
}
}

View File

@@ -82,7 +82,7 @@ class CouponRuleCollection
*/
public function isEmpty()
{
return isEmpty($this->rules);
return (empty($this->rules));
}
/**

View File

@@ -25,6 +25,7 @@ namespace Thelia\Coupon\Type;
use Symfony\Component\Intl\Exception\NotImplementedException;
use Thelia\Constraint\ConstraintManager;
use Thelia\Constraint\ConstraintValidator;
use Thelia\Coupon\CouponAdapterInterface;
use Thelia\Coupon\CouponRuleCollection;
use Thelia\Coupon\RuleOrganizerInterface;
@@ -43,17 +44,23 @@ use Thelia\Exception\InvalidRuleException;
*/
abstract class CouponAbstract implements CouponInterface
{
/** @var CouponAdapterInterface Provides necessary value from Thelia */
/** @var string Service Id */
protected $serviceId = null;
/** @var CouponAdapterInterface Provide necessary value from Thelia */
protected $adapter = null;
/** @var Translator Service Translator */
protected $translator = null;
/** @var RuleOrganizerInterface */
protected $organizer = null;
/** @var CouponRuleCollection Array of CouponRuleInterface */
protected $rules = null;
/** @var ConstraintManager CouponRuleInterface Manager*/
protected $constraintManager = null;
/** @var ConstraintValidator Constraint validator */
protected $constraintValidator = null;
/** @var string Coupon code (ex: XMAS) */
protected $code = null;
@@ -88,6 +95,18 @@ abstract class CouponAbstract implements CouponInterface
/** @var bool if Coupon is available for Products already on special offers */
protected $isAvailableOnSpecialOffers = false;
/**
* Constructor
*
* @param CouponAdapterInterface $adapter Service adapter
*/
function __construct(CouponAdapterInterface $adapter)
{
$this->adapter = $adapter;
$this->translator = $adapter->getTranslator();
}
/**
* Set Rule Organizer
*
@@ -197,10 +216,6 @@ abstract class CouponAbstract implements CouponInterface
public function setRules(CouponRuleCollection $rules)
{
$this->rules = $rules;
$this->constraintManager = new ConstraintManager(
$this->adapter,
$this->rules
);
return $this;
}
@@ -209,14 +224,11 @@ abstract class CouponAbstract implements CouponInterface
* Check if the current Coupon is matching its conditions (Rules)
* Thelia variables are given by the CouponAdapterInterface
*
* @param CouponAdapterInterface $adapter allowing to gather
* all necessary Thelia variables
*
* @return bool
*/
public function isMatching(CouponAdapterInterface $adapter)
public function isMatching()
{
return $this->constraintManager->isMatching();
return $this->constraintValidator->test($this->rules);
}
/**
@@ -278,4 +290,16 @@ abstract class CouponAbstract implements CouponInterface
return $ret;
}
/**
* Get Coupon Manager service Id
*
* @return string
*/
public function getServiceId()
{
return $this->serviceId;
}
}

View File

@@ -39,6 +39,37 @@ use Thelia\Coupon\CouponRuleCollection;
*/
interface CouponInterface
{
/**
* Set Coupon
*
* @param CouponInterface $adapter Provides necessary value from Thelia
* @param string $code Coupon code (ex: XMAS)
* @param string $title Coupon title (ex: Coupon for XMAS)
* @param string $shortDescription Coupon short description
* @param string $description Coupon description
* @param float $effect Coupon amount/percentage to deduce
* @param bool $isCumulative If Coupon is cumulative
* @param bool $isRemovingPostage If Coupon is removing postage
* @param bool $isAvailableOnSpecialOffers If available on Product already
* on special offer price
* @param bool $isEnabled False if Coupon is disabled by admin
* @param int $maxUsage How many usage left
* @param \Datetime $expirationDate When the Code is expiring
*/
public function set(
$adapter,
$code,
$title,
$shortDescription,
$description,
$effect,
$isCumulative,
$isRemovingPostage,
$isAvailableOnSpecialOffers,
$isEnabled,
$maxUsage,
\DateTime $expirationDate);
/**
* Return Coupon code (ex: XMAS)
*
@@ -107,12 +138,9 @@ interface CouponInterface
* Check if the current Coupon is matching its conditions (Rules)
* Thelia variables are given by the CouponAdapterInterface
*
* @param CouponAdapterInterface $adapter allowing to gather
* all necessary Thelia variables
*
* @return bool
*/
public function isMatching(CouponAdapterInterface $adapter);
public function isMatching();
/**
* Replace the existing Rules by those given in parameter
@@ -177,4 +205,11 @@ interface CouponInterface
*/
public function getToolTip();
/**
* Get Coupon Manager service Id
*
* @return string
*/
public function getServiceId();
}

View File

@@ -37,10 +37,13 @@ use Thelia\Coupon\Type\CouponAbstract;
* @author Guillaume MOREL <gmorel@openstudio.fr>
*
*/
class RemoveXAmount extends CouponAbstract
class RemoveXAmountManager extends CouponAbstract
{
/** @var string Service Id */
protected $serviceId = 'thelia.coupon.type.remove_x_amount';
/**
* Constructor
* Set Coupon
*
* @param CouponInterface $adapter Provides necessary value from Thelia
* @param string $code Coupon code (ex: XMAS)
@@ -56,7 +59,7 @@ class RemoveXAmount extends CouponAbstract
* @param int $maxUsage How many usage left
* @param \Datetime $expirationDate When the Code is expiring
*/
function __construct(
public function set(
$adapter,
$code,
$title,
@@ -97,7 +100,7 @@ class RemoveXAmount extends CouponAbstract
{
return $this->adapter
->getTranslator()
->trans('Remove X amount to total cart', null, 'constraint');
->trans('Remove X amount to total cart', array(), 'constraint');
}
/**
@@ -111,7 +114,7 @@ class RemoveXAmount extends CouponAbstract
->getTranslator()
->trans(
'This coupon will remove the entered amount to the customer total checkout. If the discount is superior to the total checkout price the customer will only pay the postage. Unless if the coupon is set to remove postage too.',
null,
array(),
'constraint'
);

View File

@@ -36,12 +36,15 @@ use Thelia\Exception\MissingAdapterException;
* @author Guillaume MOREL <gmorel@openstudio.fr>
*
*/
class RemoveXPercent extends CouponAbstract
class RemoveXPercentManager extends CouponAbstract
{
/** @var string Service Id */
protected $serviceId = 'thelia.coupon.type.remove_x_percent';
protected $percent = 0;
/**
* Constructor
* Set Coupon
*
* @param CouponInterface $adapter Provides necessary value from Thelia
* @param string $code Coupon code (ex: XMAS)
@@ -57,7 +60,7 @@ class RemoveXPercent extends CouponAbstract
* @param int $maxUsage How many usage left
* @param \Datetime $expirationDate When the Code is expiring
*/
function __construct(
public function set(
$adapter,
$code,
$title,
@@ -119,7 +122,7 @@ class RemoveXPercent extends CouponAbstract
{
return $this->adapter
->getTranslator()
->trans('Remove X percent to total cart', null, 'constraint');
->trans('Remove X percent to total cart', array(), 'constraint');
}
/**
@@ -133,7 +136,7 @@ class RemoveXPercent extends CouponAbstract
->getTranslator()
->trans(
'This coupon will remove the entered percentage to the customer total checkout. If the discount is superior to the total checkout price the customer will only pay the postage. Unless if the coupon is set to remove postage too.',
null,
array(),
'constraint'
);

View File

@@ -25,10 +25,10 @@ namespace Thelia\Coupon;
use Thelia\Constraint\Validator\PriceParam;
use Thelia\Constraint\Validator\RuleValidator;
use Thelia\Constraint\Rule\AvailableForTotalAmount;
use Thelia\Constraint\Rule\AvailableForTotalAmountManager;
use Thelia\Constraint\Rule\Operators;
use Thelia\Coupon\Type\CouponInterface;
use Thelia\Coupon\Type\RemoveXAmount;
use Thelia\Coupon\Type\RemoveXAmountManager;
use Thelia\Tools\PhpUnitUtils;
/**

View File

@@ -25,9 +25,9 @@ namespace Thelia\Coupon;
use Thelia\Constraint\Validator\PriceParam;
use Thelia\Constraint\Validator\RuleValidator;
use Thelia\Constraint\Rule\AvailableForTotalAmount;
use Thelia\Constraint\Rule\AvailableForTotalAmountManager;
use Thelia\Constraint\Rule\Operators;
use Thelia\Coupon\Type\RemoveXAmount;
use Thelia\Coupon\Type\RemoveXAmountManager;
require_once '../CouponManagerTest.php';
@@ -56,10 +56,10 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase
/**
* Test if a Coupon is well displayed
*
* @covers Thelia\Coupon\type\RemoveXAmount::getCode
* @covers Thelia\Coupon\type\RemoveXAmount::getTitle
* @covers Thelia\Coupon\type\RemoveXAmount::getShortDescription
* @covers Thelia\Coupon\type\RemoveXAmount::getDescription
* @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()
@@ -86,7 +86,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase
/**
* Test if a Coupon can be Cumulative
*
* @covers Thelia\Coupon\type\RemoveXAmount::isCumulative
* @covers Thelia\Coupon\type\RemoveXAmountManager::isCumulative
*
*/
public function testIsCumulative()
@@ -100,7 +100,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase
/**
* Test if a Coupon can be non cumulative
*
* @covers Thelia\Coupon\type\RemoveXAmount::isCumulative
* @covers Thelia\Coupon\type\RemoveXAmountManager::isCumulative
*
*/
public function testIsNotCumulative()
@@ -115,7 +115,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase
/**
* Test if a Coupon can remove postage
*
* @covers Thelia\Coupon\type\RemoveXAmount::isRemovingPostage
* @covers Thelia\Coupon\type\RemoveXAmountManager::isRemovingPostage
*
*/
public function testIsRemovingPostage()
@@ -129,7 +129,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase
/**
* Test if a Coupon won't remove postage if not set to
*
* @covers Thelia\Coupon\type\RemoveXAmount::isRemovingPostage
* @covers Thelia\Coupon\type\RemoveXAmountManager::isRemovingPostage
*/
public function testIsNotRemovingPostage()
{
@@ -143,7 +143,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase
/**
* Test if a Coupon has the effect expected (discount 10euros)
*
* @covers Thelia\Coupon\type\RemoveXAmount::getEffect
* @covers Thelia\Coupon\type\RemoveXAmountManager::getEffect
*/
public function testGetEffect()
{
@@ -158,8 +158,8 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase
/**
* Test Coupon rule setter
*
* @covers Thelia\Coupon\type\RemoveXAmount::setRules
* @covers Thelia\Coupon\type\RemoveXAmount::getRules
* @covers Thelia\Coupon\type\RemoveXAmountManager::setRules
* @covers Thelia\Coupon\type\RemoveXAmountManager::getRules
*/
public function testSetRulesValid()
{
@@ -190,7 +190,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase
/**
* Test Coupon rule setter
*
* @covers Thelia\Coupon\type\RemoveXAmount::setRules
* @covers Thelia\Coupon\type\RemoveXAmountManager::setRules
* @expectedException \Thelia\Exception\InvalidRuleException
*
*/
@@ -216,7 +216,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase
/**
* Test Coupon effect for rule Total Amount < 400
*
* @covers Thelia\Coupon\type\RemoveXAmount::getEffect
* @covers Thelia\Coupon\type\RemoveXAmountManager::getEffect
*
*/
public function testGetEffectIfTotalAmountInferiorTo400Valid()
@@ -241,7 +241,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase
/**
* Test Coupon effect for rule Total Amount <= 400
*
* @covers Thelia\Coupon\type\RemoveXAmount::getEffect
* @covers Thelia\Coupon\type\RemoveXAmountManager::getEffect
*
*/
public function testGetEffectIfTotalAmountInferiorOrEqualTo400Valid()
@@ -266,7 +266,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase
/**
* Test Coupon effect for rule Total Amount == 400
*
* @covers Thelia\Coupon\type\RemoveXAmount::getEffect
* @covers Thelia\Coupon\type\RemoveXAmountManager::getEffect
*
*/
public function testGetEffectIfTotalAmountEqualTo400Valid()
@@ -291,7 +291,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase
/**
* Test Coupon effect for rule Total Amount >= 400
*
* @covers Thelia\Coupon\type\RemoveXAmount::getEffect
* @covers Thelia\Coupon\type\RemoveXAmountManager::getEffect
*
*/
public function testGetEffectIfTotalAmountSuperiorOrEqualTo400Valid()
@@ -316,7 +316,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase
/**
* Test Coupon effect for rule Total Amount > 400
*
* @covers Thelia\Coupon\type\RemoveXAmount::getEffect
* @covers Thelia\Coupon\type\RemoveXAmountManager::getEffect
*
*/
public function testGetEffectIfTotalAmountSuperiorTo400Valid()

View File

@@ -58,7 +58,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase
/**
* Test if a Coupon can be Cumulative
*
* @covers Thelia\Coupon\type\RemoveXAmount::isCumulative
* @covers Thelia\Coupon\type\RemoveXPercentManager::isCumulative
*
*/
public function testIsCumulative()
@@ -72,7 +72,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase
/**
* Test if a Coupon can be non cumulative
*
* @covers Thelia\Coupon\type\RemoveXAmount::isCumulative
* @covers Thelia\Coupon\type\RemoveXPercentManager::isCumulative
*
*/
public function testIsNotCumulative()
@@ -87,7 +87,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase
/**
* Test if a Coupon can remove postage
*
* @covers Thelia\Coupon\type\RemoveXAmount::isRemovingPostage
* @covers Thelia\Coupon\type\RemoveXPercentManager::isRemovingPostage
*
*/
public function testIsRemovingPostage()
@@ -101,7 +101,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase
/**
* Test if a Coupon won't remove postage if not set to
*
* @covers Thelia\Coupon\type\RemoveXAmount::isRemovingPostage
* @covers Thelia\Coupon\type\RemoveXPercentManager::isRemovingPostage
*/
public function testIsNotRemovingPostage()
{
@@ -115,7 +115,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase
/**
* Test if a Coupon has the effect expected (discount 10euros)
*
* @covers Thelia\Coupon\type\RemoveXAmount::getEffect
* @covers Thelia\Coupon\type\RemoveXPercentManager::getEffect
*/
public function testGetEffect()
{
@@ -130,8 +130,8 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase
/**
* Test Coupon rule setter
*
* @covers Thelia\Coupon\type\RemoveXAmount::setRules
* @covers Thelia\Coupon\type\RemoveXAmount::getRules
* @covers Thelia\Coupon\type\RemoveXPercentManager::setRules
* @covers Thelia\Coupon\type\RemoveXPercentManager::getRules
*/
public function testSetRulesValid()
{
@@ -162,7 +162,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase
/**
* Test Coupon rule setter
*
* @covers Thelia\Coupon\type\RemoveXAmount::setRules
* @covers Thelia\Coupon\type\RemoveXPercentManager::setRules
* @expectedException \Thelia\Exception\InvalidRuleException
*
*/
@@ -188,7 +188,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase
/**
* Test Coupon effect for rule Total Amount < 400
*
* @covers Thelia\Coupon\type\RemoveXAmount::getEffect
* @covers Thelia\Coupon\type\RemoveXPercentManager::getEffect
*
*/
public function testGetEffectIfTotalAmountInferiorTo400Valid()
@@ -212,7 +212,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase
/**
* Test Coupon effect for rule Total Amount <= 400
*
* @covers Thelia\Coupon\type\RemoveXAmount::getEffect
* @covers Thelia\Coupon\type\RemoveXPercentManager::getEffect
*
*/
public function testGetEffectIfTotalAmountInferiorOrEqualTo400Valid()
@@ -236,7 +236,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase
/**
* Test Coupon effect for rule Total Amount == 400
*
* @covers Thelia\Coupon\type\RemoveXAmount::getEffect
* @covers Thelia\Coupon\type\RemoveXPercentManager::getEffect
*
*/
public function testGetEffectIfTotalAmountEqualTo400Valid()
@@ -260,7 +260,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase
/**
* Test Coupon effect for rule Total Amount >= 400
*
* @covers Thelia\Coupon\type\RemoveXAmount::getEffect
* @covers Thelia\Coupon\type\RemoveXPercentManager::getEffect
*
*/
public function testGetEffectIfTotalAmountSuperiorOrEqualTo400Valid()
@@ -284,7 +284,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase
/**
* Test Coupon effect for rule Total Amount > 400
*
* @covers Thelia\Coupon\type\RemoveXAmount::getEffect
* @covers Thelia\Coupon\type\RemoveXPercentManager::getEffect
*
*/
public function testGetEffectIfTotalAmountSuperiorTo400Valid()