From d276d5aa523db490c12ac83f91282ddac34efdcb Mon Sep 17 00:00:00 2001 From: gmorel Date: Sat, 23 Nov 2013 17:37:48 +0100 Subject: [PATCH 01/23] Fix Coupon/Condition utf8 issue --- .../Implementation/MatchForTotalAmountManagerTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountManagerTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountManagerTest.php index 0db635e51..153737d1d 100644 --- a/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountManagerTest.php +++ b/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountManagerTest.php @@ -940,9 +940,9 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase 'title' => 'Price', 'availableOperators' => array('==' => 'Price'), 'availableValues' => array( - 'EUR' => '€', + 'EUR' => '€', 'USD' => '$', - 'GBP' => '£', + 'GBP' => '£', ), 'type' => 'select', 'class' => 'form-control', From 59a04f6a09f21cfe46c8e5a66cad8ac3dfc7218c Mon Sep 17 00:00:00 2001 From: gmorel Date: Sat, 23 Nov 2013 17:51:59 +0100 Subject: [PATCH 02/23] Fix Condition comment --- core/lib/Thelia/Condition/SerializableCondition.php | 2 +- .../lib/Thelia/{ => Tests}/Condition/ConditionOrganizerTest.php | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename core/lib/Thelia/{ => Tests}/Condition/ConditionOrganizerTest.php (100%) diff --git a/core/lib/Thelia/Condition/SerializableCondition.php b/core/lib/Thelia/Condition/SerializableCondition.php index 31163cdda..cd2f1de44 100644 --- a/core/lib/Thelia/Condition/SerializableCondition.php +++ b/core/lib/Thelia/Condition/SerializableCondition.php @@ -28,7 +28,7 @@ namespace Thelia\Condition; * Date: 8/19/13 * Time: 3:24 PM * - * A condition set by an admin ready to be serialized and stored in DataBase + * A condition ready to be serialized and stored in DataBase * * @package Condition * @author Guillaume MOREL diff --git a/core/lib/Thelia/Condition/ConditionOrganizerTest.php b/core/lib/Thelia/Tests/Condition/ConditionOrganizerTest.php similarity index 100% rename from core/lib/Thelia/Condition/ConditionOrganizerTest.php rename to core/lib/Thelia/Tests/Condition/ConditionOrganizerTest.php From 8ce1030178bea2ebe1d11e366bd40305187812e6 Mon Sep 17 00:00:00 2001 From: gmorel Date: Sat, 23 Nov 2013 18:35:21 +0100 Subject: [PATCH 03/23] Refactor rule => condition adapter => facade --- .../Condition/ConditionManagerAbstract.php | 2 +- .../Condition/ConditionManagerInterface.php | 2 +- core/lib/Thelia/Coupon/CouponFactory.php | 8 +++---- core/lib/Thelia/Coupon/CouponManager.php | 14 ++++++------- .../lib/Thelia/Coupon/Type/CouponAbstract.php | 12 +++++------ .../Thelia/Coupon/Type/CouponInterface.php | 17 ++++++++------- .../Coupon/Type/RemoveXAmountManager.php | 11 +++++----- .../Coupon/Type/RemoveXPercentManager.php | 17 ++++++++------- ...ception.php => MissingFacadeException.php} | 4 ++-- .../Condition/ConditionOrganizerTest.php | 21 ------------------- .../Thelia/Tests/Coupon/CouponFactoryTest.php | 8 ++++++- 11 files changed, 52 insertions(+), 64 deletions(-) rename core/lib/Thelia/Exception/{MissingAdapterException.php => MissingFacadeException.php} (96%) diff --git a/core/lib/Thelia/Condition/ConditionManagerAbstract.php b/core/lib/Thelia/Condition/ConditionManagerAbstract.php index 97418178f..86e438ca5 100644 --- a/core/lib/Thelia/Condition/ConditionManagerAbstract.php +++ b/core/lib/Thelia/Condition/ConditionManagerAbstract.php @@ -35,7 +35,7 @@ use Thelia\Type\FloatType; * Date: 8/19/13 * Time: 3:24 PM * - * Assist in writing a condition of whether the Rule is applied or not + * Assist in writing a condition of whether the Condition is applied or not * * @package Constraint * @author Guillaume MOREL diff --git a/core/lib/Thelia/Condition/ConditionManagerInterface.php b/core/lib/Thelia/Condition/ConditionManagerInterface.php index ceda090bf..e25c6dcaa 100644 --- a/core/lib/Thelia/Condition/ConditionManagerInterface.php +++ b/core/lib/Thelia/Condition/ConditionManagerInterface.php @@ -47,7 +47,7 @@ interface ConditionManagerInterface function __construct(FacadeInterface $adapter); /** - * Get Rule Service id + * Get Condition Service id * * @return string */ diff --git a/core/lib/Thelia/Coupon/CouponFactory.php b/core/lib/Thelia/Coupon/CouponFactory.php index 67ffd9295..ea3db1ff9 100644 --- a/core/lib/Thelia/Coupon/CouponFactory.php +++ b/core/lib/Thelia/Coupon/CouponFactory.php @@ -48,7 +48,7 @@ class CouponFactory protected $container = null; /** @var FacadeInterface Provide necessary value from Thelia*/ - protected $adapter; + protected $facade; /** * Constructor @@ -58,7 +58,7 @@ class CouponFactory public function __construct(ContainerInterface $container) { $this->container = $container; - $this->adapter = $container->get('thelia.facade'); + $this->facade = $container->get('thelia.facade'); } /** @@ -74,7 +74,7 @@ class CouponFactory public function buildCouponFromCode($couponCode) { /** @var Coupon $couponModel */ - $couponModel = $this->adapter->findOneCouponByCode($couponCode); + $couponModel = $this->facade->findOneCouponByCode($couponCode); if ($couponModel === null) { throw new NotFoundResourceException( 'Coupon ' . $couponCode . ' not found in Database' @@ -115,7 +115,7 @@ class CouponFactory /** @var CouponInterface $couponManager*/ $couponManager = $this->container->get($model->getType()); $couponManager->set( - $this->adapter, + $this->facade, $model->getCode(), $model->getTitle(), $model->getShortDescription(), diff --git a/core/lib/Thelia/Coupon/CouponManager.php b/core/lib/Thelia/Coupon/CouponManager.php index 1598ab926..ed500c3a4 100644 --- a/core/lib/Thelia/Coupon/CouponManager.php +++ b/core/lib/Thelia/Coupon/CouponManager.php @@ -42,7 +42,7 @@ use Thelia\Model\Coupon; class CouponManager { /** @var FacadeInterface Provides necessary value from Thelia */ - protected $adapter = null; + protected $facade = null; /** @var ContainerInterface Service Container */ protected $container = null; @@ -64,8 +64,8 @@ class CouponManager public function __construct(ContainerInterface $container) { $this->container = $container; - $this->adapter = $container->get('thelia.facade'); - $this->coupons = $this->adapter->getCurrentCoupons(); + $this->facade = $container->get('thelia.facade'); + $this->coupons = $this->facade->getCurrentCoupons(); } @@ -87,12 +87,12 @@ class CouponManager $discount = $this->getEffect($couponsKept); if ($isRemovingPostage) { - $postage = $this->adapter->getCheckoutPostagePrice(); + $postage = $this->facade->getCheckoutPostagePrice(); $discount += $postage; } // Just In Case test - $checkoutTotalPrice = $this->adapter->getCartTotalPrice(); + $checkoutTotalPrice = $this->facade->getCartTotalPrice(); if ($discount >= $checkoutTotalPrice) { $discount = $checkoutTotalPrice; } @@ -164,7 +164,7 @@ class CouponManager /** @var CouponInterface $coupon */ foreach ($coupons as $coupon) { - if ($coupon->isMatching($this->adapter)) { + if ($coupon->isMatching($this->facade)) { $couponsKept[] = $coupon; } } @@ -184,7 +184,7 @@ class CouponManager $discount = 0.00; /** @var CouponInterface $coupon */ foreach ($coupons as $coupon) { - $discount += $coupon->exec($this->adapter); + $discount += $coupon->exec($this->facade); } return $discount; diff --git a/core/lib/Thelia/Coupon/Type/CouponAbstract.php b/core/lib/Thelia/Coupon/Type/CouponAbstract.php index 8d7794956..d8b1a207a 100644 --- a/core/lib/Thelia/Coupon/Type/CouponAbstract.php +++ b/core/lib/Thelia/Coupon/Type/CouponAbstract.php @@ -45,7 +45,7 @@ use Thelia\Exception\InvalidConditionException; abstract class CouponAbstract implements CouponInterface { /** @var FacadeInterface Provide necessary value from Thelia */ - protected $adapter = null; + protected $facade = null; /** @var Translator Service Translator */ protected $translator = null; @@ -104,13 +104,13 @@ abstract class CouponAbstract implements CouponInterface /** * Constructor * - * @param FacadeInterface $adapter Service adapter + * @param FacadeInterface $facade Service facade */ - public function __construct(FacadeInterface $adapter) + public function __construct(FacadeInterface $facade) { - $this->adapter = $adapter; - $this->translator = $adapter->getTranslator(); - $this->conditionEvaluator = $adapter->getConditionEvaluator(); + $this->facade = $facade; + $this->translator = $facade->getTranslator(); + $this->conditionEvaluator = $facade->getConditionEvaluator(); } /** diff --git a/core/lib/Thelia/Coupon/Type/CouponInterface.php b/core/lib/Thelia/Coupon/Type/CouponInterface.php index 411446945..f88a08c8c 100644 --- a/core/lib/Thelia/Coupon/Type/CouponInterface.php +++ b/core/lib/Thelia/Coupon/Type/CouponInterface.php @@ -24,6 +24,7 @@ namespace Thelia\Coupon\Type; use Thelia\Condition\ConditionCollection; +use Thelia\Coupon\FacadeInterface; /** * Created by JetBrains PhpStorm. @@ -62,7 +63,7 @@ interface CouponInterface /** * Set Coupon * - * @param CouponInterface $adapter Provides necessary value from Thelia + * @param FacadeInterface $facade Provides necessary value from Thelia * @param string $code Coupon code (ex: XMAS) * @param string $title Coupon title (ex: Coupon for XMAS) * @param string $shortDescription Coupon short description @@ -77,7 +78,7 @@ interface CouponInterface * @param \Datetime $expirationDate When the Code is expiring */ public function set( - $adapter, + FacadeInterface $facade, $code, $title, $shortDescription, @@ -144,15 +145,15 @@ interface CouponInterface public function getConditions(); /** - * Replace the existing Rules by those given in parameter - * If one Rule is badly implemented, no Rule will be added + * Replace the existing Conditions by those given in parameter + * If one Condition is badly implemented, no Condition will be added * - * @param ConditionCollection $rules ConditionManagerInterface to add + * @param ConditionCollection $conditions ConditionManagerInterface to add * * @return $this * @throws \Thelia\Exception\InvalidConditionException */ - public function setConditions(ConditionCollection $rules); + public function setConditions(ConditionCollection $conditions); /** * Return Coupon expiration date @@ -198,7 +199,7 @@ interface CouponInterface * A positive value * * Effects could also affect something else than the final Checkout price - * CouponAdapter $adapter could be use to directly pass a Session value + * FacadeInterface $facade could be used to directly pass a Session value * some would wish to modify * Hence affecting a wide variety of Thelia elements * @@ -207,7 +208,7 @@ interface CouponInterface public function exec(); /** - * Check if the current Coupon is matching its conditions (Rules) + * Check if the current Coupon is matching its conditions * Thelia variables are given by the FacadeInterface * * @return bool diff --git a/core/lib/Thelia/Coupon/Type/RemoveXAmountManager.php b/core/lib/Thelia/Coupon/Type/RemoveXAmountManager.php index 1f9e12420..9a3019b4b 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXAmountManager.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXAmountManager.php @@ -23,6 +23,7 @@ namespace Thelia\Coupon\Type; +use Thelia\Coupon\FacadeInterface; use Thelia\Coupon\Type\CouponAbstract; /** @@ -44,7 +45,7 @@ class RemoveXAmountManager extends CouponAbstract /** * Set Coupon * - * @param CouponInterface $adapter Provides necessary value from Thelia + * @param FacadeInterface $facade Provides necessary value from Thelia * @param string $code Coupon code (ex: XMAS) * @param string $title Coupon title (ex: Coupon for XMAS) * @param string $shortDescription Coupon short description @@ -59,7 +60,7 @@ class RemoveXAmountManager extends CouponAbstract * @param \Datetime $expirationDate When the Code is expiring */ public function set( - $adapter, + FacadeInterface $facade, $code, $title, $shortDescription, @@ -87,7 +88,7 @@ class RemoveXAmountManager extends CouponAbstract $this->isEnabled = $isEnabled; $this->maxUsage = $maxUsage; $this->expirationDate = $expirationDate; - $this->adapter = $adapter; + $this->facade = $facade; } /** @@ -97,7 +98,7 @@ class RemoveXAmountManager extends CouponAbstract */ public function getName() { - return $this->adapter + return $this->facade ->getTranslator() ->trans('Remove X amount to total cart', array(), 'constraint'); } @@ -109,7 +110,7 @@ class RemoveXAmountManager extends CouponAbstract */ public function getToolTip() { - $toolTip = $this->adapter + $toolTip = $this->facade ->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.', diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercentManager.php b/core/lib/Thelia/Coupon/Type/RemoveXPercentManager.php index b0a8e82cd..5a1e7e051 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXPercentManager.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXPercentManager.php @@ -23,8 +23,9 @@ namespace Thelia\Coupon\Type; +use Thelia\Coupon\FacadeInterface; use Thelia\Coupon\Type\CouponAbstract; -use Thelia\Exception\MissingAdapterException; +use Thelia\Exception\MissingFacadeException; /** * Created by JetBrains PhpStorm. @@ -45,7 +46,7 @@ class RemoveXPercentManager extends CouponAbstract /** * Set Coupon * - * @param CouponInterface $adapter Provides necessary value from Thelia + * @param FacadeInterface $facade Provides necessary value from Thelia * @param string $code Coupon code (ex: XMAS) * @param string $title Coupon title (ex: Coupon for XMAS) * @param string $shortDescription Coupon short description @@ -60,7 +61,7 @@ class RemoveXPercentManager extends CouponAbstract * @param \Datetime $expirationDate When the Code is expiring */ public function set( - $adapter, + FacadeInterface $facade, $code, $title, $shortDescription, @@ -87,14 +88,14 @@ class RemoveXPercentManager extends CouponAbstract $this->isEnabled = $isEnabled; $this->maxUsage = $maxUsage; $this->expirationDate = $expirationDate; - $this->adapter = $adapter; + $this->facade = $facade; } /** * Return effects generated by the coupon * A negative value * - * @throws \Thelia\Exception\MissingAdapterException + * @throws \Thelia\Exception\MissingFacadeException * @throws \InvalidArgumentException * @return float */ @@ -106,7 +107,7 @@ class RemoveXPercentManager extends CouponAbstract ); } - $basePrice = $this->adapter->getCartTotalPrice(); + $basePrice = $this->facade->getCartTotalPrice(); return $basePrice * (( $this->percent ) / 100); } @@ -119,7 +120,7 @@ class RemoveXPercentManager extends CouponAbstract */ public function getName() { - return $this->adapter + return $this->facade ->getTranslator() ->trans('Remove X percent to total cart', array(), 'constraint'); } @@ -131,7 +132,7 @@ class RemoveXPercentManager extends CouponAbstract */ public function getToolTip() { - $toolTip = $this->adapter + $toolTip = $this->facade ->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.', diff --git a/core/lib/Thelia/Exception/MissingAdapterException.php b/core/lib/Thelia/Exception/MissingFacadeException.php similarity index 96% rename from core/lib/Thelia/Exception/MissingAdapterException.php rename to core/lib/Thelia/Exception/MissingFacadeException.php index 3659dcc68..5616e9575 100644 --- a/core/lib/Thelia/Exception/MissingAdapterException.php +++ b/core/lib/Thelia/Exception/MissingFacadeException.php @@ -30,13 +30,13 @@ use Thelia\Log\Tlog; * Date: 8/19/13 * Time: 3:24 PM * - * Thrown when the Adapter is not set + * Thrown when the Facade is not set * * @package Coupon * @author Guillaume MOREL * */ -class MissingAdapterException extends \RuntimeException +class MissingFacadeException extends \RuntimeException { /** * {@inheritdoc} diff --git a/core/lib/Thelia/Tests/Condition/ConditionOrganizerTest.php b/core/lib/Thelia/Tests/Condition/ConditionOrganizerTest.php index 521482083..0591df0ab 100644 --- a/core/lib/Thelia/Tests/Condition/ConditionOrganizerTest.php +++ b/core/lib/Thelia/Tests/Condition/ConditionOrganizerTest.php @@ -38,27 +38,6 @@ use Thelia\Condition\ConditionOrganizer; */ class ConditionOrganizerTest extends \PHPUnit_Framework_TestCase { - /** - * @var ConditionOrganizer - */ - 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 ConditionOrganizer; - } - - /** - * 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\RuleOrganizer::organize diff --git a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php index b4e2d2ec2..8a52bd1c7 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php @@ -27,6 +27,7 @@ use Thelia\Condition\ConditionEvaluator; use Thelia\Condition\ConditionFactory; use Thelia\Condition\Implementation\MatchForTotalAmountManager; use Thelia\Condition\Operators; +use Thelia\Coupon\Type\RemoveXAmountManager; use Thelia\Model\Coupon; use Thelia\Model\CurrencyQuery; @@ -192,9 +193,14 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $stubFacade->expects($this->any()) ->method('findOneCouponByCode') ->will($this->returnValue($expected)); - $stubContainer->expects($this->any()) + $stubContainer->expects($this->at(0)) ->method('get') ->will($this->returnValue($stubFacade)); + + $couponManager = new RemoveXAmountManager(); + $stubContainer->expects($this->at(1)) + ->method('get') + ->will($this->returnValue($couponManager)); $stubContainer->expects($this->any()) ->method('has') ->will($this->returnValue(true)); From 90b5fbde056f0c5a9e0eb80b82d849fdb00a0d31 Mon Sep 17 00:00:00 2001 From: gmorel Date: Sat, 23 Nov 2013 20:18:04 +0100 Subject: [PATCH 04/23] Refactor removing Manager notion --- core/lib/Thelia/Action/Coupon.php | 6 +- .../Thelia/Condition/ConditionCollection.php | 16 +- .../Thelia/Condition/ConditionEvaluator.php | 2 +- .../lib/Thelia/Condition/ConditionFactory.php | 12 +- .../Thelia/Condition/ConditionOrganizer.php | 6 +- .../Condition/ConditionOrganizerInterface.php | 6 +- .../ConditionAbstract.php} | 2 +- .../ConditionInterface.php} | 2 +- ...eryoneManager.php => MatchForEveryone.php} | 4 +- ...untManager.php => MatchForTotalAmount.php} | 4 +- ...iclesManager.php => MatchForXArticles.php} | 4 +- core/lib/Thelia/Config/Resources/coupon.xml | 10 +- .../Controller/Admin/CouponController.php | 8 +- .../Coupon/CouponCreateOrUpdateEvent.php | 6 +- core/lib/Thelia/Core/Template/Loop/Coupon.php | 4 +- core/lib/Thelia/Coupon/CouponFactory.php | 6 +- core/lib/Thelia/Coupon/CouponManager.php | 6 +- .../lib/Thelia/Coupon/Type/CouponAbstract.php | 4 +- .../Thelia/Coupon/Type/CouponInterface.php | 4 +- ...veXAmountManager.php => RemoveXAmount.php} | 2 +- ...XPercentManager.php => RemoveXPercent.php} | 2 +- .../Condition/ConditionCollectionTest.php | 32 +- .../Condition/ConditionEvaluatorTest.php | 8 +- .../Tests/Condition/ConditionFactoryTest.php | 70 ++--- .../MatchForEveryoneManagerTest.php | 26 +- .../MatchForTotalAmountManagerTest.php | 288 +++++++++--------- .../MatchForXArticlesManagerTest.php | 152 ++++----- .../Thelia/Tests/Coupon/CouponFactoryTest.php | 83 +++-- .../Coupon/Type/RemoveXAmountManagerTest.php | 14 +- .../Coupon/Type/RemoveXPercentManagerTest.php | 16 +- install/faker.php | 34 +-- install/faker_add_ecotax.php | 6 +- install/import.php | 4 +- install/tax_faker.php | 4 +- 34 files changed, 442 insertions(+), 411 deletions(-) rename core/lib/Thelia/Condition/{ConditionManagerAbstract.php => Implementation/ConditionAbstract.php} (98%) rename core/lib/Thelia/Condition/{ConditionManagerInterface.php => Implementation/ConditionInterface.php} (98%) rename core/lib/Thelia/Condition/Implementation/{MatchForEveryoneManager.php => MatchForEveryone.php} (97%) rename core/lib/Thelia/Condition/Implementation/{MatchForTotalAmountManager.php => MatchForTotalAmount.php} (98%) rename core/lib/Thelia/Condition/Implementation/{MatchForXArticlesManager.php => MatchForXArticles.php} (98%) rename core/lib/Thelia/Coupon/Type/{RemoveXAmountManager.php => RemoveXAmount.php} (99%) rename core/lib/Thelia/Coupon/Type/{RemoveXPercentManager.php => RemoveXPercent.php} (99%) diff --git a/core/lib/Thelia/Action/Coupon.php b/core/lib/Thelia/Action/Coupon.php index bbe71ed94..4ac8481f7 100755 --- a/core/lib/Thelia/Action/Coupon.php +++ b/core/lib/Thelia/Action/Coupon.php @@ -25,7 +25,7 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Condition\ConditionFactory; -use Thelia\Condition\ConditionManagerInterface; +use Thelia\Condition\ConditionInterface; use Thelia\Core\Event\Coupon\CouponConsumeEvent; use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent; use Thelia\Core\Event\TheliaEvents; @@ -102,7 +102,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface $couponManager = $this->container->get('thelia.coupon.manager'); /** @var CouponInterface $coupon */ - $coupon = $couponFactory->buildCouponFromCode($event->getCode()); + $coupon = $couponFactory->buildCouponManagerFromCode($event->getCode()); $isValid = $coupon->isMatching(); @@ -154,7 +154,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface $coupon->setDispatcher($this->getDispatcher()); // Set default condition if none found - /** @var ConditionManagerInterface $noConditionRule */ + /** @var ConditionInterface $noConditionRule */ $noConditionRule = $this->container->get('thelia.condition.match_for_everyone'); /** @var ConditionFactory $conditionFactory */ $conditionFactory = $this->container->get('thelia.condition.factory'); diff --git a/core/lib/Thelia/Condition/ConditionCollection.php b/core/lib/Thelia/Condition/ConditionCollection.php index 47f184cdf..1a31a5f92 100644 --- a/core/lib/Thelia/Condition/ConditionCollection.php +++ b/core/lib/Thelia/Condition/ConditionCollection.php @@ -24,14 +24,14 @@ namespace Thelia\Condition; use Symfony\Component\DependencyInjection\ContainerInterface; -use Thelia\Condition\ConditionManagerInterface; +use Thelia\Condition\ConditionInterface; /** * Created by JetBrains PhpStorm. * Date: 8/19/13 * Time: 3:24 PM * - * Manage a set of ConditionManagerInterface + * Manage a set of ConditionInterface * * @package Condition * @author Guillaume MOREL @@ -39,13 +39,13 @@ use Thelia\Condition\ConditionManagerInterface; */ class ConditionCollection { - /** @var array Array of ConditionManagerInterface */ + /** @var array Array of ConditionInterface */ protected $conditions = array(); /** * Get Conditions * - * @return array Array of ConditionManagerInterface + * @return array Array of ConditionInterface */ public function getConditions() { @@ -53,13 +53,13 @@ class ConditionCollection } /** - * Add a ConditionManagerInterface to the Collection + * Add a ConditionInterface to the Collection * - * @param ConditionManagerInterface $condition Condition + * @param ConditionInterface $condition Condition * * @return $this */ - public function add(ConditionManagerInterface $condition) + public function add(ConditionInterface $condition) { $this->conditions[] = $condition; @@ -84,7 +84,7 @@ class ConditionCollection public function __toString() { $arrayToSerialize = array(); - /** @var ConditionManagerInterface $condition */ + /** @var ConditionInterface $condition */ foreach ($this->getConditions() as $condition) { $arrayToSerialize[] = $condition->getSerializableCondition(); } diff --git a/core/lib/Thelia/Condition/ConditionEvaluator.php b/core/lib/Thelia/Condition/ConditionEvaluator.php index 768054a26..956694b09 100644 --- a/core/lib/Thelia/Condition/ConditionEvaluator.php +++ b/core/lib/Thelia/Condition/ConditionEvaluator.php @@ -51,7 +51,7 @@ class ConditionEvaluator public function isMatching(ConditionCollection $conditions) { $isMatching = true; - /** @var ConditionManagerInterface $condition */ + /** @var ConditionInterface $condition */ foreach ($conditions->getConditions() as $condition) { if (!$condition->isMatching()) { $isMatching = false; diff --git a/core/lib/Thelia/Condition/ConditionFactory.php b/core/lib/Thelia/Condition/ConditionFactory.php index 35598f427..68eec8083 100644 --- a/core/lib/Thelia/Condition/ConditionFactory.php +++ b/core/lib/Thelia/Condition/ConditionFactory.php @@ -71,7 +71,7 @@ class ConditionFactory public function serializeConditionCollection(ConditionCollection $collection) { if ($collection->isEmpty()) { - /** @var ConditionManagerInterface $conditionNone */ + /** @var ConditionInterface $conditionNone */ $conditionNone = $this->container->get( 'thelia.condition.match_for_everyone' ); @@ -80,7 +80,7 @@ class ConditionFactory $serializableConditions = array(); $conditions = $collection->getConditions(); if ($conditions !== null) { - /** @var $condition ConditionManagerInterface */ + /** @var $condition ConditionInterface */ foreach ($conditions as $condition) { $serializableConditions[] = $condition->getSerializableCondition(); } @@ -106,7 +106,7 @@ class ConditionFactory /** @var SerializableCondition $condition */ foreach ($unserializedConditions as $condition) { if ($this->container->has($condition->conditionServiceId)) { - /** @var ConditionManagerInterface $conditionManager */ + /** @var ConditionInterface $conditionManager */ $conditionManager = $this->build( $condition->conditionServiceId, (array) $condition->operators, @@ -129,7 +129,7 @@ class ConditionFactory * @param array $values Values setting this Condition * * @throws \InvalidArgumentException - * @return ConditionManagerInterface Ready to use Condition or false + * @return ConditionInterface Ready to use Condition or false */ public function build($conditionServiceId, array $operators, array $values) { @@ -137,7 +137,7 @@ class ConditionFactory return false; } - /** @var ConditionManagerInterface $condition */ + /** @var ConditionInterface $condition */ $condition = $this->container->get($conditionServiceId); $condition->setValidatorsFromForm($operators, $values); @@ -157,7 +157,7 @@ class ConditionFactory return false; } - /** @var ConditionManagerInterface $condition */ + /** @var ConditionInterface $condition */ $condition = $this->container->get($conditionServiceId); return $condition->getValidators(); diff --git a/core/lib/Thelia/Condition/ConditionOrganizer.php b/core/lib/Thelia/Condition/ConditionOrganizer.php index 116203e5b..f678142ab 100644 --- a/core/lib/Thelia/Condition/ConditionOrganizer.php +++ b/core/lib/Thelia/Condition/ConditionOrganizer.php @@ -37,11 +37,11 @@ namespace Thelia\Condition; class ConditionOrganizer implements ConditionOrganizerInterface { /** - * Organize ConditionManagerInterface + * Organize ConditionInterface * - * @param array $conditions Array of ConditionManagerInterface + * @param array $conditions Array of ConditionInterface * - * @return array Array of ConditionManagerInterface sorted + * @return array Array of ConditionInterface sorted */ public function organize(array $conditions) { diff --git a/core/lib/Thelia/Condition/ConditionOrganizerInterface.php b/core/lib/Thelia/Condition/ConditionOrganizerInterface.php index 5e30f8596..00f8d55b8 100644 --- a/core/lib/Thelia/Condition/ConditionOrganizerInterface.php +++ b/core/lib/Thelia/Condition/ConditionOrganizerInterface.php @@ -37,11 +37,11 @@ namespace Thelia\Condition; interface ConditionOrganizerInterface { /** - * Organize ConditionManagerInterface + * Organize ConditionInterface * - * @param array $conditions Array of ConditionManagerInterface + * @param array $conditions Array of ConditionInterface * - * @return array Array of ConditionManagerInterface sorted + * @return array Array of ConditionInterface sorted */ public function organize(array $conditions); } \ No newline at end of file diff --git a/core/lib/Thelia/Condition/ConditionManagerAbstract.php b/core/lib/Thelia/Condition/Implementation/ConditionAbstract.php similarity index 98% rename from core/lib/Thelia/Condition/ConditionManagerAbstract.php rename to core/lib/Thelia/Condition/Implementation/ConditionAbstract.php index 86e438ca5..b00dae73a 100644 --- a/core/lib/Thelia/Condition/ConditionManagerAbstract.php +++ b/core/lib/Thelia/Condition/Implementation/ConditionAbstract.php @@ -41,7 +41,7 @@ use Thelia\Type\FloatType; * @author Guillaume MOREL * */ -abstract class ConditionManagerAbstract implements ConditionManagerInterface +abstract class ConditionAbstract implements ConditionInterface { /** @var string Service Id from Resources/config.xml */ diff --git a/core/lib/Thelia/Condition/ConditionManagerInterface.php b/core/lib/Thelia/Condition/Implementation/ConditionInterface.php similarity index 98% rename from core/lib/Thelia/Condition/ConditionManagerInterface.php rename to core/lib/Thelia/Condition/Implementation/ConditionInterface.php index e25c6dcaa..dbb65c57b 100644 --- a/core/lib/Thelia/Condition/ConditionManagerInterface.php +++ b/core/lib/Thelia/Condition/Implementation/ConditionInterface.php @@ -37,7 +37,7 @@ use Thelia\Coupon\FacadeInterface; * @author Guillaume MOREL * */ -interface ConditionManagerInterface +interface ConditionInterface { /** * Constructor diff --git a/core/lib/Thelia/Condition/Implementation/MatchForEveryoneManager.php b/core/lib/Thelia/Condition/Implementation/MatchForEveryone.php similarity index 97% rename from core/lib/Thelia/Condition/Implementation/MatchForEveryoneManager.php rename to core/lib/Thelia/Condition/Implementation/MatchForEveryone.php index 00108a3b0..ffd3d3f6f 100644 --- a/core/lib/Thelia/Condition/Implementation/MatchForEveryoneManager.php +++ b/core/lib/Thelia/Condition/Implementation/MatchForEveryone.php @@ -24,7 +24,7 @@ namespace Thelia\Condition\Implementation; use InvalidArgumentException; -use Thelia\Condition\ConditionManagerAbstract; +use Thelia\Condition\ConditionAbstract; /** * Created by JetBrains PhpStorm. @@ -37,7 +37,7 @@ use Thelia\Condition\ConditionManagerAbstract; * @author Guillaume MOREL * */ -class MatchForEveryoneManager extends ConditionManagerAbstract +class MatchForEveryone extends ConditionAbstract { /** @var string Service Id from Resources/config.xml */ protected $serviceId = 'thelia.condition.match_for_everyone'; diff --git a/core/lib/Thelia/Condition/Implementation/MatchForTotalAmountManager.php b/core/lib/Thelia/Condition/Implementation/MatchForTotalAmount.php similarity index 98% rename from core/lib/Thelia/Condition/Implementation/MatchForTotalAmountManager.php rename to core/lib/Thelia/Condition/Implementation/MatchForTotalAmount.php index a3ba846fa..527f1871d 100644 --- a/core/lib/Thelia/Condition/Implementation/MatchForTotalAmountManager.php +++ b/core/lib/Thelia/Condition/Implementation/MatchForTotalAmount.php @@ -24,7 +24,7 @@ namespace Thelia\Condition\Implementation; use Symfony\Component\Intl\Exception\NotImplementedException; -use Thelia\Condition\ConditionManagerAbstract; +use Thelia\Condition\ConditionAbstract; use Thelia\Condition\Operators; use Thelia\Exception\InvalidConditionOperatorException; use Thelia\Model\Currency; @@ -42,7 +42,7 @@ use Thelia\Model\CurrencyQuery; * @author Guillaume MOREL * */ -class MatchForTotalAmountManager extends ConditionManagerAbstract +class MatchForTotalAmount extends ConditionAbstract { /** Condition 1st parameter : price */ CONST INPUT1 = 'price'; diff --git a/core/lib/Thelia/Condition/Implementation/MatchForXArticlesManager.php b/core/lib/Thelia/Condition/Implementation/MatchForXArticles.php similarity index 98% rename from core/lib/Thelia/Condition/Implementation/MatchForXArticlesManager.php rename to core/lib/Thelia/Condition/Implementation/MatchForXArticles.php index d8721cb07..b7fc479cd 100644 --- a/core/lib/Thelia/Condition/Implementation/MatchForXArticlesManager.php +++ b/core/lib/Thelia/Condition/Implementation/MatchForXArticles.php @@ -24,7 +24,7 @@ namespace Thelia\Condition\Implementation; use InvalidArgumentException; -use Thelia\Condition\ConditionManagerAbstract; +use Thelia\Condition\ConditionAbstract; use Thelia\Condition\Operators; use Thelia\Exception\InvalidConditionOperatorException; use Thelia\Exception\InvalidConditionValueException; @@ -40,7 +40,7 @@ use Thelia\Exception\InvalidConditionValueException; * @author Guillaume MOREL * */ -class MatchForXArticlesManager extends ConditionManagerAbstract +class MatchForXArticles extends ConditionAbstract { /** Condition 1st parameter : quantity */ CONST INPUT1 = 'quantity'; diff --git a/core/lib/Thelia/Config/Resources/coupon.xml b/core/lib/Thelia/Config/Resources/coupon.xml index 8be9ea59f..d0d763ea2 100644 --- a/core/lib/Thelia/Config/Resources/coupon.xml +++ b/core/lib/Thelia/Config/Resources/coupon.xml @@ -19,11 +19,11 @@ - + - + @@ -35,15 +35,15 @@ - + - + - + diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php index 6da5ec6b1..d302b6008 100755 --- a/core/lib/Thelia/Controller/Admin/CouponController.php +++ b/core/lib/Thelia/Controller/Admin/CouponController.php @@ -26,7 +26,7 @@ namespace Thelia\Controller\Admin; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Router; use Thelia\Condition\ConditionFactory; -use Thelia\Condition\ConditionManagerInterface; +use Thelia\Condition\ConditionInterface; use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent; use Thelia\Core\Event\TheliaEvents; @@ -227,7 +227,7 @@ class CouponController extends BaseAdminController $args['conditionsObject'] = array(); - /** @var ConditionManagerInterface $condition */ + /** @var ConditionInterface $condition */ foreach ($conditions->getConditions() as $condition) { $args['conditionsObject'][] = array( 'serviceId' => $condition->getServiceId(), @@ -519,7 +519,7 @@ class CouponController extends BaseAdminController $couponManager = $this->container->get('thelia.coupon.manager'); $availableConditions = $couponManager->getAvailableConditions(); $cleanedConditions = array(); - /** @var ConditionManagerInterface $availableCondition */ + /** @var ConditionInterface $availableCondition */ foreach ($availableConditions as $availableCondition) { $condition = array(); $condition['serviceId'] = $availableCondition->getServiceId(); @@ -564,7 +564,7 @@ class CouponController extends BaseAdminController protected function cleanConditionForTemplate(ConditionCollection $conditions) { $cleanedConditions = array(); - /** @var $condition ConditionManagerInterface */ + /** @var $condition ConditionInterface */ foreach ($conditions->getConditions() as $condition) { $cleanedConditions[] = $condition->getToolTip(); } diff --git a/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php b/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php index f890fd8cd..374643fda 100644 --- a/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php @@ -39,7 +39,7 @@ use Thelia\Model\Coupon; */ class CouponCreateOrUpdateEvent extends ActionEvent { - /** @var ConditionCollection Array of ConditionManagerInterface */ + /** @var ConditionCollection Array of ConditionInterface */ protected $conditions = null; /** @var string Coupon code (ex: XMAS) */ @@ -280,7 +280,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent /** * Get Conditions * - * @return null|ConditionCollection Array of ConditionManagerInterface + * @return null|ConditionCollection Array of ConditionInterface */ public function getConditions() { @@ -290,7 +290,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent /** * Set Conditions * - * @param ConditionCollection $conditions Array of ConditionManagerInterface + * @param ConditionCollection $conditions Array of ConditionInterface * * @return $this */ diff --git a/core/lib/Thelia/Core/Template/Loop/Coupon.php b/core/lib/Thelia/Core/Template/Loop/Coupon.php index fea2cb23e..88c9b92a0 100755 --- a/core/lib/Thelia/Core/Template/Loop/Coupon.php +++ b/core/lib/Thelia/Core/Template/Loop/Coupon.php @@ -26,7 +26,7 @@ namespace Thelia\Core\Template\Loop; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Util\PropelModelPager; use Thelia\Condition\ConditionFactory; -use Thelia\Condition\ConditionManagerInterface; +use Thelia\Condition\ConditionInterface; use Thelia\Core\HttpFoundation\Request; use Thelia\Core\Template\Element\BaseI18nLoop; use Thelia\Core\Template\Element\LoopResult; @@ -125,7 +125,7 @@ class Coupon extends BaseI18nLoop implements PropelSearchLoopInterface $daysLeftBeforeExpiration = floor($datediff/(60*60*24)); $cleanedConditions = array(); - /** @var ConditionManagerInterface $condition */ + /** @var ConditionInterface $condition */ foreach ($conditions->getConditions() as $condition) { $cleanedConditions[] = $condition->getToolTip(); } diff --git a/core/lib/Thelia/Coupon/CouponFactory.php b/core/lib/Thelia/Coupon/CouponFactory.php index ea3db1ff9..e528a1d49 100644 --- a/core/lib/Thelia/Coupon/CouponFactory.php +++ b/core/lib/Thelia/Coupon/CouponFactory.php @@ -71,7 +71,7 @@ class CouponFactory * @throws \Symfony\Component\Translation\Exception\NotFoundResourceException * @return CouponInterface ready to be processed */ - public function buildCouponFromCode($couponCode) + public function buildCouponManagerFromCode($couponCode) { /** @var Coupon $couponModel */ $couponModel = $this->facade->findOneCouponByCode($couponCode); @@ -86,7 +86,7 @@ class CouponFactory } /** @var CouponInterface $couponInterface */ - $couponInterface = $this->buildCouponInterfaceFromModel($couponModel); + $couponInterface = $this->buildCouponManagerFromModel($couponModel); if ($couponInterface->getConditions()->isEmpty()) { throw new InvalidConditionException( get_class($couponInterface) @@ -103,7 +103,7 @@ class CouponFactory * * @return CouponInterface ready to use CouponInterface object instance */ - protected function buildCouponInterfaceFromModel(Coupon $model) + protected function buildCouponManagerFromModel(Coupon $model) { $isCumulative = ($model->getIsCumulative() == 1 ? true : false); $isRemovingPostage = ($model->getIsRemovingPostage() == 1 ? true : false); diff --git a/core/lib/Thelia/Coupon/CouponManager.php b/core/lib/Thelia/Coupon/CouponManager.php index ed500c3a4..4bc3aed0e 100644 --- a/core/lib/Thelia/Coupon/CouponManager.php +++ b/core/lib/Thelia/Coupon/CouponManager.php @@ -24,7 +24,7 @@ namespace Thelia\Coupon; use Symfony\Component\DependencyInjection\ContainerInterface; -use Thelia\Condition\ConditionManagerInterface; +use Thelia\Condition\ConditionInterface; use Thelia\Coupon\Type\CouponInterface; use Thelia\Model\Coupon; @@ -213,9 +213,9 @@ class CouponManager /** * Add an available ConstraintManager (Services) * - * @param ConditionManagerInterface $condition ConditionManagerInterface + * @param ConditionInterface $condition ConditionInterface */ - public function addAvailableCondition(ConditionManagerInterface $condition) + public function addAvailableCondition(ConditionInterface $condition) { $this->availableConditions[] = $condition; } diff --git a/core/lib/Thelia/Coupon/Type/CouponAbstract.php b/core/lib/Thelia/Coupon/Type/CouponAbstract.php index d8b1a207a..98c258c27 100644 --- a/core/lib/Thelia/Coupon/Type/CouponAbstract.php +++ b/core/lib/Thelia/Coupon/Type/CouponAbstract.php @@ -53,7 +53,7 @@ abstract class CouponAbstract implements CouponInterface /** @var ConditionOrganizerInterface */ protected $organizer = null; - /** @var ConditionCollection Array of ConditionManagerInterface */ + /** @var ConditionCollection Array of ConditionInterface */ protected $conditions = null; /** @var ConditionEvaluator Condition validator */ @@ -214,7 +214,7 @@ abstract class CouponAbstract implements CouponInterface * Replace the existing Conditions by those given in parameter * If one Condition is badly implemented, no Condition will be added * - * @param ConditionCollection $conditions ConditionManagerInterface to add + * @param ConditionCollection $conditions ConditionInterface to add * * @return $this * @throws \Thelia\Exception\InvalidConditionException diff --git a/core/lib/Thelia/Coupon/Type/CouponInterface.php b/core/lib/Thelia/Coupon/Type/CouponInterface.php index f88a08c8c..63c7e4267 100644 --- a/core/lib/Thelia/Coupon/Type/CouponInterface.php +++ b/core/lib/Thelia/Coupon/Type/CouponInterface.php @@ -140,7 +140,7 @@ interface CouponInterface /** * Return condition to validate the Coupon or not * - * @return ConditionCollection A set of ConditionManagerInterface + * @return ConditionCollection A set of ConditionInterface */ public function getConditions(); @@ -148,7 +148,7 @@ interface CouponInterface * Replace the existing Conditions by those given in parameter * If one Condition is badly implemented, no Condition will be added * - * @param ConditionCollection $conditions ConditionManagerInterface to add + * @param ConditionCollection $conditions ConditionInterface to add * * @return $this * @throws \Thelia\Exception\InvalidConditionException diff --git a/core/lib/Thelia/Coupon/Type/RemoveXAmountManager.php b/core/lib/Thelia/Coupon/Type/RemoveXAmount.php similarity index 99% rename from core/lib/Thelia/Coupon/Type/RemoveXAmountManager.php rename to core/lib/Thelia/Coupon/Type/RemoveXAmount.php index 9a3019b4b..1609ffc3e 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXAmountManager.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXAmount.php @@ -37,7 +37,7 @@ use Thelia\Coupon\Type\CouponAbstract; * @author Guillaume MOREL * */ -class RemoveXAmountManager extends CouponAbstract +class RemoveXAmount extends CouponAbstract { /** @var string Service Id */ protected $serviceId = 'thelia.coupon.type.remove_x_amount'; diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercentManager.php b/core/lib/Thelia/Coupon/Type/RemoveXPercent.php similarity index 99% rename from core/lib/Thelia/Coupon/Type/RemoveXPercentManager.php rename to core/lib/Thelia/Coupon/Type/RemoveXPercent.php index 5a1e7e051..931ddad67 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXPercentManager.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXPercent.php @@ -36,7 +36,7 @@ use Thelia\Exception\MissingFacadeException; * @author Guillaume MOREL * */ -class RemoveXPercentManager extends CouponAbstract +class RemoveXPercent extends CouponAbstract { /** @var string Service Id */ protected $serviceId = 'thelia.coupon.type.remove_x_percent'; diff --git a/core/lib/Thelia/Tests/Condition/ConditionCollectionTest.php b/core/lib/Thelia/Tests/Condition/ConditionCollectionTest.php index a4d940391..46f639521 100644 --- a/core/lib/Thelia/Tests/Condition/ConditionCollectionTest.php +++ b/core/lib/Thelia/Tests/Condition/ConditionCollectionTest.php @@ -22,7 +22,7 @@ /**********************************************************************************/ namespace Thelia\Condition; -use Thelia\Condition\Implementation\MatchForTotalAmountManager; +use Thelia\Condition\Implementation\MatchForTotalAmount; use Thelia\Model\CurrencyQuery; /** @@ -116,14 +116,14 @@ class ConditionCollectionTest extends \PHPUnit_Framework_TestCase { $stubFacade = $this->generateFacadeStub(); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::EQUAL, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::EQUAL, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 400, - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => 400, + MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $collection = new ConditionCollection(); @@ -153,24 +153,24 @@ class ConditionCollectionTest extends \PHPUnit_Framework_TestCase { $stubFacade = $this->generateFacadeStub(); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators1 = array( - MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values1 = array( - MatchForTotalAmountManager::INPUT1 => 400, - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => 400, + MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators1, $values1); - $condition2 = new MatchForTotalAmountManager($stubFacade); + $condition2 = new MatchForTotalAmount($stubFacade); $operators2 = array( - MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::INFERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values2 = array( - MatchForTotalAmountManager::INPUT1 => 600, - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => 600, + MatchForTotalAmount::INPUT2 => 'EUR'); $condition2->setValidatorsFromForm($operators2, $values2); $collection = new ConditionCollection(); diff --git a/core/lib/Thelia/Tests/Condition/ConditionEvaluatorTest.php b/core/lib/Thelia/Tests/Condition/ConditionEvaluatorTest.php index fdf97de0c..2c85e05e5 100644 --- a/core/lib/Thelia/Tests/Condition/ConditionEvaluatorTest.php +++ b/core/lib/Thelia/Tests/Condition/ConditionEvaluatorTest.php @@ -146,14 +146,14 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase */ public function testIsMatchingTrue() { - $stubConditionTrue1 = $this->getMockBuilder('\Thelia\Condition\Implementation\MatchForXArticlesManager') + $stubConditionTrue1 = $this->getMockBuilder('\Thelia\Condition\Implementation\MatchForXArticles') ->disableOriginalConstructor() ->getMock(); $stubConditionTrue1->expects($this->any()) ->method('isMatching') ->will($this->returnValue(true)); - $stubConditionTrue2 = $this->getMockBuilder('\Thelia\Condition\Implementation\MatchForXArticlesManager') + $stubConditionTrue2 = $this->getMockBuilder('\Thelia\Condition\Implementation\MatchForXArticles') ->disableOriginalConstructor() ->getMock(); $stubConditionTrue2->expects($this->any()) @@ -177,14 +177,14 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase */ public function testIsMatchingFalse() { - $stubConditionTrue = $this->getMockBuilder('\Thelia\Condition\Implementation\MatchForXArticlesManager') + $stubConditionTrue = $this->getMockBuilder('\Thelia\Condition\Implementation\MatchForXArticles') ->disableOriginalConstructor() ->getMock(); $stubConditionTrue->expects($this->any()) ->method('isMatching') ->will($this->returnValue(true)); - $stubConditionFalse = $this->getMockBuilder('\Thelia\Condition\Implementation\MatchForXArticlesManager') + $stubConditionFalse = $this->getMockBuilder('\Thelia\Condition\Implementation\MatchForXArticles') ->disableOriginalConstructor() ->getMock(); $stubConditionFalse->expects($this->any()) diff --git a/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php b/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php index c99938408..37fde4cea 100644 --- a/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php +++ b/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php @@ -84,7 +84,7 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase ->getMock(); $stubContainer->expects($this->any()) ->method('get') - ->will($this->returnValue(new MatchForTotalAmountManager($stubFacade))); + ->will($this->returnValue(new MatchForTotalAmount($stubFacade))); $stubContainer->expects($this->any()) ->method('has') @@ -94,14 +94,14 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase ->method('getContainer') ->will($this->returnValue($stubContainer)); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 40.00, - MatchForTotalAmountManager::INPUT2 => 'EUR' + MatchForTotalAmount::INPUT1 => 40.00, + MatchForTotalAmount::INPUT2 => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); @@ -148,7 +148,7 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase ->getMock(); $stubContainer->expects($this->any()) ->method('get') - ->will($this->returnValue(new MatchForTotalAmountManager($stubFacade))); + ->will($this->returnValue(new MatchForTotalAmount($stubFacade))); $stubContainer->expects($this->any()) ->method('has') @@ -158,14 +158,14 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase ->method('getContainer') ->will($this->returnValue($stubContainer)); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 40.00, - MatchForTotalAmountManager::INPUT2 => 'EUR' + MatchForTotalAmount::INPUT1 => 40.00, + MatchForTotalAmount::INPUT2 => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); @@ -210,7 +210,7 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase ->getMock(); $stubContainer->expects($this->any()) ->method('get') - ->will($this->returnValue(new MatchForTotalAmountManager($stubFacade))); + ->will($this->returnValue(new MatchForTotalAmount($stubFacade))); $stubContainer->expects($this->any()) ->method('has') @@ -220,25 +220,25 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase ->method('getContainer') ->will($this->returnValue($stubContainer)); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 40.00, - MatchForTotalAmountManager::INPUT2 => 'EUR' + MatchForTotalAmount::INPUT1 => 40.00, + MatchForTotalAmount::INPUT2 => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); - $condition2 = new MatchForTotalAmountManager($stubFacade); + $condition2 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 400.00, - MatchForTotalAmountManager::INPUT2 => 'EUR' + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR' ); $condition2->setValidatorsFromForm($operators, $values); @@ -287,7 +287,7 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container') ->disableOriginalConstructor() ->getMock(); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $stubContainer->expects($this->any()) ->method('get') ->will($this->returnValue($condition1)); @@ -301,12 +301,12 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($stubContainer)); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 40.00, - MatchForTotalAmountManager::INPUT2 => 'EUR' + MatchForTotalAmount::INPUT1 => 40.00, + MatchForTotalAmount::INPUT2 => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); @@ -352,7 +352,7 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container') ->disableOriginalConstructor() ->getMock(); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $stubContainer->expects($this->any()) ->method('get') ->will($this->returnValue($condition1)); @@ -366,12 +366,12 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($stubContainer)); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 40.00, - MatchForTotalAmountManager::INPUT2 => 'EUR' + MatchForTotalAmount::INPUT1 => 40.00, + MatchForTotalAmount::INPUT2 => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); @@ -421,7 +421,7 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase ->getMock(); $stubContainer->expects($this->any()) ->method('get') - ->will($this->returnValue(new MatchForEveryoneManager($stubFacade))); + ->will($this->returnValue(new MatchForEveryone($stubFacade))); $stubContainer->expects($this->any()) ->method('has') @@ -437,7 +437,7 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase $conditionFactory = new ConditionFactory($stubContainer); - $conditionNone = new MatchForEveryoneManager($stubFacade); + $conditionNone = new MatchForEveryone($stubFacade); $expectedCollection = new ConditionCollection(); $expectedCollection->add($conditionNone); diff --git a/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneManagerTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneManagerTest.php index f31ebb2c3..f59fe04ef 100644 --- a/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneManagerTest.php +++ b/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneManagerTest.php @@ -33,13 +33,13 @@ use Thelia\Model\Currency; * Date: 8/19/13 * Time: 3:24 PM * - * Unit Test MatchForEveryoneManager Class + * Unit Test MatchForEveryone Class * * @package Condition * @author Guillaume MOREL * */ -class MatchForEveryoneManagerTest extends \PHPUnit_Framework_TestCase +class MatchForEveryoneTest extends \PHPUnit_Framework_TestCase { /** @var FacadeInterface $stubTheliaAdapter */ protected $stubTheliaAdapter = null; @@ -96,7 +96,7 @@ class MatchForEveryoneManagerTest extends \PHPUnit_Framework_TestCase /** * Check if validity test on BackOffice inputs are working * - * @covers Thelia\Condition\Implementation\MatchForEveryoneManager::setValidators + * @covers Thelia\Condition\Implementation\MatchForEveryone::setValidators * */ public function testValidBackOfficeInputOperator() @@ -104,7 +104,7 @@ class MatchForEveryoneManagerTest extends \PHPUnit_Framework_TestCase $stubFacade = $this->generateFacadeStub(399, 'EUR'); /** @var FacadeInterface $stubFacade */ - $condition1 = new MatchForEveryoneManager($stubFacade); + $condition1 = new MatchForEveryone($stubFacade); $operators = array(); $values = array(); $condition1->setValidatorsFromForm($operators, $values); @@ -119,7 +119,7 @@ class MatchForEveryoneManagerTest extends \PHPUnit_Framework_TestCase /** * Check if condition is always matching * - * @covers Thelia\Condition\Implementation\MatchForEveryoneManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForEveryone::isMatching * */ public function testIsMatching() @@ -127,7 +127,7 @@ class MatchForEveryoneManagerTest extends \PHPUnit_Framework_TestCase $stubFacade = $this->generateFacadeStub(399, 'EUR'); /** @var FacadeInterface $stubFacade */ - $condition1 = new MatchForEveryoneManager($stubFacade); + $condition1 = new MatchForEveryone($stubFacade); $isValid = $condition1->isMatching(); @@ -139,7 +139,7 @@ class MatchForEveryoneManagerTest extends \PHPUnit_Framework_TestCase /** * Check getName i18n * - * @covers Thelia\Condition\Implementation\MatchForEveryoneManager::getName + * @covers Thelia\Condition\Implementation\MatchForEveryone::getName * */ public function testGetName() @@ -147,7 +147,7 @@ class MatchForEveryoneManagerTest extends \PHPUnit_Framework_TestCase $stubFacade = $this->generateFacadeStub(399, 'EUR', 'Everybody can use it (no condition)'); /** @var FacadeInterface $stubFacade */ - $condition1 = new MatchForEveryoneManager($stubFacade); + $condition1 = new MatchForEveryone($stubFacade); $actual = $condition1->getName(); $expected = 'Everybody can use it (no condition)'; @@ -157,7 +157,7 @@ class MatchForEveryoneManagerTest extends \PHPUnit_Framework_TestCase /** * Check tooltip i18n * - * @covers Thelia\Condition\Implementation\MatchForEveryoneManager::getToolTip + * @covers Thelia\Condition\Implementation\MatchForEveryone::getToolTip * */ public function testGetToolTip() @@ -165,7 +165,7 @@ class MatchForEveryoneManagerTest extends \PHPUnit_Framework_TestCase $stubFacade = $this->generateFacadeStub(399, 'EUR', 'Will return always true'); /** @var FacadeInterface $stubFacade */ - $condition1 = new MatchForEveryoneManager($stubFacade); + $condition1 = new MatchForEveryone($stubFacade); $actual = $condition1->getToolTip(); $expected = 'Will return always true'; @@ -175,15 +175,15 @@ class MatchForEveryoneManagerTest extends \PHPUnit_Framework_TestCase /** * Check validator * - * @covers Thelia\Condition\Implementation\MatchForEveryoneManager::generateInputs - * @covers Thelia\Condition\Implementation\MatchForEveryoneManager::setValidatorsFromForm + * @covers Thelia\Condition\Implementation\MatchForEveryone::generateInputs + * @covers Thelia\Condition\Implementation\MatchForEveryone::setValidatorsFromForm */ public function testGetValidator() { $stubFacade = $this->generateFacadeStub(399, 'EUR'); /** @var FacadeInterface $stubFacade */ - $condition1 = new MatchForEveryoneManager($stubFacade); + $condition1 = new MatchForEveryone($stubFacade); $actual1 = $condition1->setValidatorsFromForm(array(), array()); $expected1 = $condition1; $actual2 = $condition1->getValidators(); diff --git a/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountManagerTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountManagerTest.php index 153737d1d..0390536c5 100644 --- a/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountManagerTest.php +++ b/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountManagerTest.php @@ -37,13 +37,13 @@ use Thelia\Model\CurrencyQuery; * Date: 8/19/13 * Time: 3:24 PM * - * Unit Test MatchForTotalAmountManager Class + * Unit Test MatchForTotalAmount Class * * @package Condition * @author Guillaume MOREL * */ -class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase +class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase { /** @var FacadeInterface $stubTheliaAdapter */ protected $stubTheliaAdapter = null; @@ -97,7 +97,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check if validity test on BackOffice inputs are working * - * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::setValidators + * @covers Thelia\Condition\Implementation\MatchForTotalAmount::setValidators * @expectedException \Thelia\Exception\InvalidConditionOperatorException * */ @@ -106,14 +106,14 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase $stubFacade = $this->generateAdapterStub(399, 'EUR'); /** @var FacadeInterface $stubFacade */ - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::IN, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::IN, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => '400', - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => '400', + MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -126,7 +126,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check if validity test on BackOffice inputs are working * - * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::setValidators + * @covers Thelia\Condition\Implementation\MatchForTotalAmount::setValidators * @expectedException \Thelia\Exception\InvalidConditionOperatorException * */ @@ -135,14 +135,14 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase $stubFacade = $this->generateAdapterStub(399, 'EUR'); /** @var FacadeInterface $stubFacade */ - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmountManager::INPUT2 => Operators::INFERIOR + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::INFERIOR ); $values = array( - MatchForTotalAmountManager::INPUT1 => '400', - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => '400', + MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -155,7 +155,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check if validity test on BackOffice inputs are working * - * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::setValidators + * @covers Thelia\Condition\Implementation\MatchForTotalAmount::setValidators * @expectedException \Thelia\Exception\InvalidConditionValueException * */ @@ -164,14 +164,14 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** @var FacadeInterface $stubFacade */ $stubFacade = $this->generateAdapterStub(399, 'EUR'); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 'X', - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => 'X', + MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -184,7 +184,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check if validity test on BackOffice inputs are working * - * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::setValidators + * @covers Thelia\Condition\Implementation\MatchForTotalAmount::setValidators * @expectedException \Thelia\Exception\InvalidConditionValueException * */ @@ -193,14 +193,14 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** @var FacadeInterface $stubFacade */ $stubFacade = $this->generateAdapterStub(399, 'EUR'); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 400, - MatchForTotalAmountManager::INPUT2 => 'FLA'); + MatchForTotalAmount::INPUT1 => 400, + MatchForTotalAmount::INPUT2 => 'FLA'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -213,7 +213,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test inferior operator is working * - * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching * */ public function testMatchingConditionInferior() @@ -221,14 +221,14 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** @var FacadeInterface $stubFacade */ $stubFacade = $this->generateAdapterStub(399, 'EUR'); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::INFERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 400.00, - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -241,7 +241,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test inferior operator is working * - * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching * */ public function testNotMatchingConditionInferior() @@ -249,14 +249,14 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** @var FacadeInterface $stubFacade */ $stubFacade = $this->generateAdapterStub(400, 'EUR'); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::INFERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 400.00, - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -269,7 +269,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test inferior operator is working * - * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching * */ public function testMatchingConditionInferiorEquals() @@ -277,14 +277,14 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** @var FacadeInterface $stubFacade */ $stubFacade = $this->generateAdapterStub(400, 'EUR'); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR_OR_EQUAL, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::INFERIOR_OR_EQUAL, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 400.00, - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -297,7 +297,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test inferior operator is working * - * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching * */ public function testMatchingConditionInferiorEquals2() @@ -305,14 +305,14 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** @var FacadeInterface $stubFacade */ $stubFacade = $this->generateAdapterStub(399, 'EUR'); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR_OR_EQUAL, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::INFERIOR_OR_EQUAL, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 400.00, - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -325,7 +325,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test inferior operator is working * - * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching * */ public function testNotMatchingConditionInferiorEquals() @@ -333,14 +333,14 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** @var FacadeInterface $stubFacade */ $stubFacade = $this->generateAdapterStub(401, 'EUR'); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR_OR_EQUAL, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::INFERIOR_OR_EQUAL, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 400.00, - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -353,7 +353,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test equals operator is working * - * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching * */ public function testMatchingConditionEqual() @@ -361,14 +361,14 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** @var FacadeInterface $stubFacade */ $stubFacade = $this->generateAdapterStub(400, 'EUR'); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::EQUAL, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::EQUAL, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 400.00, - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -381,7 +381,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test equals operator is working * - * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching * */ public function testNotMatchingConditionEqual() @@ -389,14 +389,14 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** @var FacadeInterface $stubFacade */ $stubFacade = $this->generateAdapterStub(399, 'EUR'); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::EQUAL, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::EQUAL, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 400.00, - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -409,7 +409,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test superior operator is working * - * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching * */ public function testMatchingConditionSuperiorEquals() @@ -417,14 +417,14 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** @var FacadeInterface $stubFacade */ $stubFacade = $this->generateAdapterStub(401, 'EUR'); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR_OR_EQUAL, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 400.00, - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -437,7 +437,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test superior operator is working * - * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching * */ public function testMatchingConditionSuperiorEquals2() @@ -445,14 +445,14 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** @var FacadeInterface $stubFacade */ $stubFacade = $this->generateAdapterStub(400, 'EUR'); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR_OR_EQUAL, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 400.00, - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -465,7 +465,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test superior operator is working * - * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching * */ public function testNotMatchingConditionSuperiorEquals() @@ -473,14 +473,14 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** @var FacadeInterface $stubFacade */ $stubFacade = $this->generateAdapterStub(399, 'EUR'); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR_OR_EQUAL, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 400.00, - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -493,7 +493,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test superior operator is working * - * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching * */ public function testMatchingConditionSuperior() @@ -501,14 +501,14 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** @var FacadeInterface $stubFacade */ $stubFacade = $this->generateAdapterStub(401, 'EUR'); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 400.00, - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -521,7 +521,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test superior operator is working * - * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching * */ public function testNotMatchingConditionSuperior() @@ -529,14 +529,14 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** @var FacadeInterface $stubFacade */ $stubFacade = $this->generateAdapterStub(399, 'EUR'); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 400.00, - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -549,7 +549,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check currency is checked * - * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching * */ public function testMatchingConditionCurrency() @@ -557,14 +557,14 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** @var FacadeInterface $stubFacade */ $stubFacade = $this->generateAdapterStub(400, 'EUR'); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::EQUAL, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::EQUAL, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 400.00, - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -577,7 +577,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check currency is checked * - * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForTotalAmount::isMatching * */ public function testNotMatchingConditionCurrency() @@ -585,14 +585,14 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** @var FacadeInterface $stubFacade */ $stubFacade = $this->generateAdapterStub(400.00, 'EUR'); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::EQUAL, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::EQUAL, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 400.00, - MatchForTotalAmountManager::INPUT2 => 'USD'); + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'USD'); $condition1->setValidatorsFromForm($operators, $values); $isValid = $condition1->isMatching(); @@ -605,7 +605,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check unknown currency * - * @covers Thelia\Condition\ConditionManagerAbstract::isCurrencyValid + * @covers Thelia\Condition\ConditionAbstract::isCurrencyValid * @expectedException \Thelia\Exception\InvalidConditionValueException * */ @@ -634,14 +634,14 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($currencies)); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::EQUAL, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::EQUAL, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 400.00, - MatchForTotalAmountManager::INPUT2 => 'UNK'); + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'UNK'); $condition1->setValidatorsFromForm($operators, $values); @@ -672,7 +672,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check invalid currency * - * @covers Thelia\Condition\ConditionManagerAbstract::isPriceValid + * @covers Thelia\Condition\ConditionAbstract::isPriceValid * @expectedException \Thelia\Exception\InvalidConditionValueException * */ @@ -701,14 +701,14 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($currencies)); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::EQUAL, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::EQUAL, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 'notfloat', - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => 'notfloat', + MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); @@ -739,7 +739,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check invalid currency * - * @covers Thelia\Condition\ConditionManagerAbstract::isPriceValid + * @covers Thelia\Condition\ConditionAbstract::isPriceValid * @expectedException \Thelia\Exception\InvalidConditionValueException * */ @@ -768,14 +768,14 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($currencies)); - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::EQUAL, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::EQUAL, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 0.00, - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => 0.00, + MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); @@ -855,7 +855,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check getName i18n * - * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::getName + * @covers Thelia\Condition\Implementation\MatchForTotalAmount::getName * */ public function testGetName() @@ -863,7 +863,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase $stubFacade = $this->generateFacadeStub(399, 'EUR', 'Cart total amount'); /** @var FacadeInterface $stubFacade */ - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $actual = $condition1->getName(); $expected = 'Cart total amount'; @@ -873,7 +873,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check tooltip i18n * - * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::getToolTip + * @covers Thelia\Condition\Implementation\MatchForTotalAmount::getToolTip * */ public function testGetToolTip() @@ -881,14 +881,14 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase $stubFacade = $this->generateFacadeStub(399, 'EUR', 'If cart total amount is %operator% %amount% %currency%'); /** @var FacadeInterface $stubFacade */ - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::EQUAL, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::EQUAL, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 400.00, - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $actual = $condition1->getToolTip(); @@ -899,7 +899,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** * Check validator * - * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::generateInputs + * @covers Thelia\Condition\Implementation\MatchForTotalAmount::generateInputs * */ public function testGetValidator() @@ -907,21 +907,21 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase $stubFacade = $this->generateFacadeStub(399, 'EUR', 'Price'); /** @var FacadeInterface $stubFacade */ - $condition1 = new MatchForTotalAmountManager($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::EQUAL, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::EQUAL, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 400.00, - MatchForTotalAmountManager::INPUT2 => 'EUR'); + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); $actual = $condition1->getValidators(); $validators = array( 'inputs' => array( - MatchForTotalAmountManager::INPUT1 => array( + MatchForTotalAmount::INPUT1 => array( 'title' => 'Price', 'availableOperators' => array( '<' => 'Price', @@ -936,7 +936,7 @@ class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase 'value' => '', 'selectedOperator' => '' ), - MatchForTotalAmountManager::INPUT2 => array( + MatchForTotalAmount::INPUT2 => array( 'title' => 'Price', 'availableOperators' => array('==' => 'Price'), 'availableValues' => array( diff --git a/core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesManagerTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesManagerTest.php index f59cd41b7..f33ef0468 100644 --- a/core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesManagerTest.php +++ b/core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesManagerTest.php @@ -33,13 +33,13 @@ use Thelia\Coupon\FacadeInterface; * Date: 8/19/13 * Time: 3:24 PM * - * Unit Test MatchForXArticlesManager Class + * Unit Test MatchForXArticles Class * * @package Constraint * @author Guillaume MOREL * */ -class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase +class MatchForXArticlesTest extends \PHPUnit_Framework_TestCase { /** @@ -54,7 +54,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase /** * Check if validity test on BackOffice inputs are working * - * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::setValidators + * @covers Thelia\Condition\Implementation\MatchForXArticles::setValidators * @expectedException \Thelia\Exception\InvalidConditionOperatorException */ public function testInValidBackOfficeInputOperator() @@ -72,12 +72,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase ->method('getConditionEvaluator') ->will($this->returnValue(new ConditionEvaluator())); - $condition1 = new MatchForXArticlesManager($stubFacade); + $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticlesManager::INPUT1 => Operators::IN + MatchForXArticles::INPUT1 => Operators::IN ); $values = array( - MatchForXArticlesManager::INPUT1 => 5 + MatchForXArticles::INPUT1 => 5 ); $condition1->setValidatorsFromForm($operators, $values); @@ -91,7 +91,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase /** * Check if validity test on BackOffice inputs are working * - * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::setValidators + * @covers Thelia\Condition\Implementation\MatchForXArticles::setValidators * @expectedException \Thelia\Exception\InvalidConditionValueException */ public function testInValidBackOfficeInputValue() @@ -108,12 +108,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase ->method('getConditionEvaluator') ->will($this->returnValue(new ConditionEvaluator())); - $condition1 = new MatchForXArticlesManager($stubFacade); + $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR + MatchForXArticles::INPUT1 => Operators::SUPERIOR ); $values = array( - MatchForXArticlesManager::INPUT1 => 'X' + MatchForXArticles::INPUT1 => 'X' ); $condition1->setValidatorsFromForm($operators, $values); @@ -127,7 +127,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test inferior operator is working * - * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching * */ public function testMatchingRuleInferior() @@ -144,12 +144,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase ->method('getConditionEvaluator') ->will($this->returnValue(new ConditionEvaluator())); - $condition1 = new MatchForXArticlesManager($stubFacade); + $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticlesManager::INPUT1 => Operators::INFERIOR + MatchForXArticles::INPUT1 => Operators::INFERIOR ); $values = array( - MatchForXArticlesManager::INPUT1 => 5 + MatchForXArticles::INPUT1 => 5 ); $condition1->setValidatorsFromForm($operators, $values); @@ -163,7 +163,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test inferior operator is working * - * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching * */ public function testNotMatchingRuleInferior() @@ -180,12 +180,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase ->method('getConditionEvaluator') ->will($this->returnValue(new ConditionEvaluator())); - $condition1 = new MatchForXArticlesManager($stubFacade); + $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticlesManager::INPUT1 => Operators::INFERIOR + MatchForXArticles::INPUT1 => Operators::INFERIOR ); $values = array( - MatchForXArticlesManager::INPUT1 => 4, + MatchForXArticles::INPUT1 => 4, ); $condition1->setValidatorsFromForm($operators, $values); @@ -199,7 +199,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test inferior operator is working * - * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching * */ public function testMatchingRuleInferiorEquals() @@ -216,12 +216,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase ->method('getConditionEvaluator') ->will($this->returnValue(new ConditionEvaluator())); - $condition1 = new MatchForXArticlesManager($stubFacade); + $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticlesManager::INPUT1 => Operators::INFERIOR_OR_EQUAL, + MatchForXArticles::INPUT1 => Operators::INFERIOR_OR_EQUAL, ); $values = array( - MatchForXArticlesManager::INPUT1 => 5, + MatchForXArticles::INPUT1 => 5, ); $condition1->setValidatorsFromForm($operators, $values); @@ -235,7 +235,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test inferior operator is working * - * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching * */ public function testMatchingRuleInferiorEquals2() @@ -252,12 +252,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase ->method('getConditionEvaluator') ->will($this->returnValue(new ConditionEvaluator())); - $condition1 = new MatchForXArticlesManager($stubFacade); + $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticlesManager::INPUT1 => Operators::INFERIOR_OR_EQUAL + MatchForXArticles::INPUT1 => Operators::INFERIOR_OR_EQUAL ); $values = array( - MatchForXArticlesManager::INPUT1 => 4 + MatchForXArticles::INPUT1 => 4 ); $condition1->setValidatorsFromForm($operators, $values); @@ -271,7 +271,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test inferior operator is working * - * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching * */ public function testNotMatchingRuleInferiorEquals() @@ -288,12 +288,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase ->method('getConditionEvaluator') ->will($this->returnValue(new ConditionEvaluator())); - $condition1 = new MatchForXArticlesManager($stubFacade); + $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticlesManager::INPUT1 => Operators::INFERIOR_OR_EQUAL + MatchForXArticles::INPUT1 => Operators::INFERIOR_OR_EQUAL ); $values = array( - MatchForXArticlesManager::INPUT1 => 3 + MatchForXArticles::INPUT1 => 3 ); $condition1->setValidatorsFromForm($operators, $values); @@ -307,7 +307,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test equals operator is working * - * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching * */ public function testMatchingRuleEqual() @@ -324,12 +324,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase ->method('getConditionEvaluator') ->will($this->returnValue(new ConditionEvaluator())); - $condition1 = new MatchForXArticlesManager($stubFacade); + $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticlesManager::INPUT1 => Operators::EQUAL + MatchForXArticles::INPUT1 => Operators::EQUAL ); $values = array( - MatchForXArticlesManager::INPUT1 => 4 + MatchForXArticles::INPUT1 => 4 ); $condition1->setValidatorsFromForm($operators, $values); @@ -343,7 +343,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test equals operator is working * - * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching * */ public function testNotMatchingRuleEqual() @@ -360,12 +360,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase ->method('getConditionEvaluator') ->will($this->returnValue(new ConditionEvaluator())); - $condition1 = new MatchForXArticlesManager($stubFacade); + $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticlesManager::INPUT1 => Operators::EQUAL + MatchForXArticles::INPUT1 => Operators::EQUAL ); $values = array( - MatchForXArticlesManager::INPUT1 => 5 + MatchForXArticles::INPUT1 => 5 ); $condition1->setValidatorsFromForm($operators, $values); @@ -379,7 +379,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test superior operator is working * - * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching * */ public function testMatchingRuleSuperiorEquals() @@ -396,12 +396,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase ->method('getConditionEvaluator') ->will($this->returnValue(new ConditionEvaluator())); - $condition1 = new MatchForXArticlesManager($stubFacade); + $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL + MatchForXArticles::INPUT1 => Operators::SUPERIOR_OR_EQUAL ); $values = array( - MatchForXArticlesManager::INPUT1 => 4 + MatchForXArticles::INPUT1 => 4 ); $condition1->setValidatorsFromForm($operators, $values); @@ -415,7 +415,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test superior operator is working * - * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching * */ public function testMatchingRuleSuperiorEquals2() @@ -432,12 +432,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase ->method('getConditionEvaluator') ->will($this->returnValue(new ConditionEvaluator())); - $condition1 = new MatchForXArticlesManager($stubFacade); + $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL + MatchForXArticles::INPUT1 => Operators::SUPERIOR_OR_EQUAL ); $values = array( - MatchForXArticlesManager::INPUT1 => 3 + MatchForXArticles::INPUT1 => 3 ); $condition1->setValidatorsFromForm($operators, $values); @@ -451,7 +451,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test superior operator is working * - * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching * */ public function testNotMatchingRuleSuperiorEquals() @@ -468,12 +468,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase ->method('getConditionEvaluator') ->will($this->returnValue(new ConditionEvaluator())); - $condition1 = new MatchForXArticlesManager($stubFacade); + $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL + MatchForXArticles::INPUT1 => Operators::SUPERIOR_OR_EQUAL ); $values = array( - MatchForXArticlesManager::INPUT1 => 5 + MatchForXArticles::INPUT1 => 5 ); $condition1->setValidatorsFromForm($operators, $values); @@ -487,7 +487,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test superior operator is working * - * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching * */ public function testMatchingRuleSuperior() @@ -504,12 +504,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase ->method('getConditionEvaluator') ->will($this->returnValue(new ConditionEvaluator())); - $condition1 = new MatchForXArticlesManager($stubFacade); + $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR + MatchForXArticles::INPUT1 => Operators::SUPERIOR ); $values = array( - MatchForXArticlesManager::INPUT1 => 3 + MatchForXArticles::INPUT1 => 3 ); $condition1->setValidatorsFromForm($operators, $values); @@ -523,7 +523,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase /** * Check if test superior operator is working * - * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * @covers Thelia\Condition\Implementation\MatchForXArticles::isMatching * */ public function testNotMatchingRuleSuperior() @@ -540,12 +540,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase ->method('getConditionEvaluator') ->will($this->returnValue(new ConditionEvaluator())); - $condition1 = new MatchForXArticlesManager($stubFacade); + $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR + MatchForXArticles::INPUT1 => Operators::SUPERIOR ); $values = array( - MatchForXArticlesManager::INPUT1 => 4 + MatchForXArticles::INPUT1 => 4 ); $condition1->setValidatorsFromForm($operators, $values); @@ -570,12 +570,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase ->method('getConditionEvaluator') ->will($this->returnValue(new ConditionEvaluator())); - $condition1 = new MatchForXArticlesManager($stubFacade); + $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR + MatchForXArticles::INPUT1 => Operators::SUPERIOR ); $values = array( - MatchForXArticlesManager::INPUT1 => 4 + MatchForXArticles::INPUT1 => 4 ); $condition1->setValidatorsFromForm($operators, $values); @@ -606,17 +606,17 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase ->method('getConditionEvaluator') ->will($this->returnValue(new ConditionEvaluator())); - $condition1 = new MatchForXArticlesManager($stubFacade); + $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR + MatchForXArticles::INPUT1 => Operators::SUPERIOR ); $values = array( - MatchForXArticlesManager::INPUT1 => 4 + MatchForXArticles::INPUT1 => 4 ); $condition1->setValidatorsFromForm($operators, $values); $expected = array( - MatchForXArticlesManager::INPUT1 => array( + MatchForXArticles::INPUT1 => array( Operators::INFERIOR, Operators::INFERIOR_OR_EQUAL, Operators::EQUAL, @@ -674,7 +674,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase /** * Check getName i18n * - * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::getName + * @covers Thelia\Condition\Implementation\MatchForXArticles::getName * */ public function testGetName() @@ -682,7 +682,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase $stubFacade = $this->generateFacadeStub(399, 'EUR', 'Number of articles in cart'); /** @var FacadeInterface $stubFacade */ - $condition1 = new MatchForXArticlesManager($stubFacade); + $condition1 = new MatchForXArticles($stubFacade); $actual = $condition1->getName(); $expected = 'Number of articles in cart'; @@ -692,7 +692,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase /** * Check tooltip i18n * - * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::getToolTip + * @covers Thelia\Condition\Implementation\MatchForXArticles::getToolTip * */ public function testGetToolTip() @@ -700,12 +700,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase $stubFacade = $this->generateFacadeStub(399, 'EUR', 'If cart products quantity is superior to 4'); /** @var FacadeInterface $stubFacade */ - $condition1 = new MatchForXArticlesManager($stubFacade); + $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR + MatchForXArticles::INPUT1 => Operators::SUPERIOR ); $values = array( - MatchForXArticlesManager::INPUT1 => 4 + MatchForXArticles::INPUT1 => 4 ); $condition1->setValidatorsFromForm($operators, $values); @@ -717,7 +717,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase /** * Check validator * - * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::generateInputs + * @covers Thelia\Condition\Implementation\MatchForXArticles::generateInputs * */ public function testGetValidator() @@ -725,12 +725,12 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase $stubFacade = $this->generateFacadeStub(399, 'EUR', 'Price'); /** @var FacadeInterface $stubFacade */ - $condition1 = new MatchForXArticlesManager($stubFacade); + $condition1 = new MatchForXArticles($stubFacade); $operators = array( - MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR + MatchForXArticles::INPUT1 => Operators::SUPERIOR ); $values = array( - MatchForXArticlesManager::INPUT1 => 4 + MatchForXArticles::INPUT1 => 4 ); $condition1->setValidatorsFromForm($operators, $values); @@ -738,7 +738,7 @@ class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase $validators = array( 'inputs' => array( - MatchForXArticlesManager::INPUT1 => array( + MatchForXArticles::INPUT1 => array( 'title' => 'Price', 'availableOperators' => array( '<' => 'Price', diff --git a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php index 8a52bd1c7..97804e9da 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php @@ -25,9 +25,9 @@ namespace Thelia\Coupon; use Thelia\Condition\ConditionCollection; use Thelia\Condition\ConditionEvaluator; use Thelia\Condition\ConditionFactory; -use Thelia\Condition\Implementation\MatchForTotalAmountManager; +use Thelia\Condition\Implementation\MatchForTotalAmount; use Thelia\Condition\Operators; -use Thelia\Coupon\Type\RemoveXAmountManager; +use Thelia\Coupon\Type\RemoveXAmount; use Thelia\Model\Coupon; use Thelia\Model\CurrencyQuery; @@ -131,25 +131,25 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $date = new \DateTime(); $coupon1->setExpirationDate($date->setTimestamp(strtotime("today + 3 months"))); - $condition1 = new MatchForTotalAmountManager($facade); + $condition1 = new MatchForTotalAmount($facade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 40.00, - MatchForTotalAmountManager::INPUT2 => 'EUR' + MatchForTotalAmount::INPUT1 => 40.00, + MatchForTotalAmount::INPUT2 => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); - $condition2 = new MatchForTotalAmountManager($facade); + $condition2 = new MatchForTotalAmount($facade); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::INFERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 400.00, - MatchForTotalAmountManager::INPUT2 => 'EUR' + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR' ); $condition2->setValidatorsFromForm($operators, $values); @@ -178,36 +178,67 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua } /** - * @covers Thelia\Coupon\CouponFactory::buildCouponFromCode + * @covers Thelia\Coupon\CouponFactory::buildCouponManagerFromCode */ public function testBuildCouponFromCode() { $stubFacade = $this->generateFacadeStub(); - $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container') - ->disableOriginalConstructor() - ->getMock(); + $stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container'); $conditionFactory = new ConditionFactory($stubContainer); - $expected = $this->generateCouponModel($stubFacade, $conditionFactory); + $couponModel = $this->generateCouponModel($stubFacade, $conditionFactory); $stubFacade->expects($this->any()) ->method('findOneCouponByCode') - ->will($this->returnValue($expected)); - $stubContainer->expects($this->at(0)) - ->method('get') - ->will($this->returnValue($stubFacade)); + ->will($this->returnValue($couponModel)); - $couponManager = new RemoveXAmountManager(); - $stubContainer->expects($this->at(1)) + $couponManager = new RemoveXAmount($stubFacade); + + + $condition1 = new MatchForTotalAmount($stubFacade); + $operators = array( + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmount::INPUT1 => 40.00, + MatchForTotalAmount::INPUT2 => 'EUR' + ); + $condition1->setValidatorsFromForm($operators, $values); + + $condition2 = new MatchForTotalAmount($stubFacade); + $operators = array( + MatchForTotalAmount::INPUT1 => Operators::INFERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR' + ); + $condition2->setValidatorsFromForm($operators, $values); + + $conditions = new ConditionCollection(); + $conditions->add($condition1); + $conditions->add($condition2); + $stubConditionFactory = $this->getMockBuilder('\Thelia\Condition\ConditionFactory') + ->disableOriginalConstructor() + ->getMock(); + $stubConditionFactory->expects($this->any()) + ->method('unserializeConditionCollection') + ->will($this->returnValue($conditions)); + + + $stubContainer->expects($this->any()) ->method('get') - ->will($this->returnValue($couponManager)); + ->will($this->onConsecutiveCalls($stubFacade, $couponManager, $stubConditionFactory)); + $stubContainer->expects($this->any()) ->method('has') ->will($this->returnValue(true)); - $factory = new CouponFactory($stubContainer); - $actual = $factory->buildCouponFromCode('XMAS'); + $expected = $couponManager; + $actual = $factory->buildCouponManagerFromCode('XMAS'); $this->assertEquals($expected, $actual); } diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountManagerTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountManagerTest.php index 48c3405b1..cdfa7c875 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountManagerTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountManagerTest.php @@ -28,17 +28,17 @@ namespace Thelia\Coupon\Type; * Date: 8/19/13 * Time: 3:24 PM * - * Unit Test RemoveXAmountManager Class + * Unit Test RemoveXAmount Class * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-11-17 at 18:59:24. * * @package Coupon * @author Guillaume MOREL * */ -class RemoveXAmountManagerTest extends \PHPUnit_Framework_TestCase +class RemoveXAmountTest extends \PHPUnit_Framework_TestCase { /** - * @var RemoveXAmountManager + * @var RemoveXAmount */ protected $object; @@ -48,7 +48,7 @@ class RemoveXAmountManagerTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { -// $this->object = new RemoveXAmountManager; +// $this->object = new RemoveXAmount; } /** @@ -60,7 +60,7 @@ class RemoveXAmountManagerTest extends \PHPUnit_Framework_TestCase } /** - * @covers Thelia\Coupon\Type\RemoveXAmountManager::set + * @covers Thelia\Coupon\Type\RemoveXAmount::set * @todo Implement testSet(). */ public function testSet() @@ -72,7 +72,7 @@ class RemoveXAmountManagerTest extends \PHPUnit_Framework_TestCase } /** - * @covers Thelia\Coupon\Type\RemoveXAmountManager::getName + * @covers Thelia\Coupon\Type\RemoveXAmount::getName * @todo Implement testGetName(). */ public function testGetName() @@ -84,7 +84,7 @@ class RemoveXAmountManagerTest extends \PHPUnit_Framework_TestCase } /** - * @covers Thelia\Coupon\Type\RemoveXAmountManager::getToolTip + * @covers Thelia\Coupon\Type\RemoveXAmount::getToolTip * @todo Implement testGetToolTip(). */ public function testGetToolTip() diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentManagerTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentManagerTest.php index 09326ab2a..28123ea83 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentManagerTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentManagerTest.php @@ -28,17 +28,17 @@ namespace Thelia\Coupon\Type; * Date: 8/19/13 * Time: 3:24 PM * - * Unit Test RemoveXPercentManager Class + * Unit Test RemoveXPercent Class * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-11-17 at 18:59:24. * * @package Coupon * @author Guillaume MOREL * */ -class RemoveXPercentManagerTest extends \PHPUnit_Framework_TestCase +class RemoveXPercentTest extends \PHPUnit_Framework_TestCase { /** - * @var RemoveXPercentManager + * @var RemoveXPercent */ protected $object; @@ -48,7 +48,7 @@ class RemoveXPercentManagerTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { -// $this->object = new RemoveXPercentManager; +// $this->object = new RemoveXPercent; } /** @@ -60,7 +60,7 @@ class RemoveXPercentManagerTest extends \PHPUnit_Framework_TestCase } /** - * @covers Thelia\Coupon\Type\RemoveXPercentManager::set + * @covers Thelia\Coupon\Type\RemoveXPercent::set * @todo Implement testSet(). */ public function testSet() @@ -72,7 +72,7 @@ class RemoveXPercentManagerTest extends \PHPUnit_Framework_TestCase } /** - * @covers Thelia\Coupon\Type\RemoveXPercentManager::exec + * @covers Thelia\Coupon\Type\RemoveXPercent::exec * @todo Implement testExec(). */ public function testExec() @@ -84,7 +84,7 @@ class RemoveXPercentManagerTest extends \PHPUnit_Framework_TestCase } /** - * @covers Thelia\Coupon\Type\RemoveXPercentManager::getName + * @covers Thelia\Coupon\Type\RemoveXPercent::getName * @todo Implement testGetName(). */ public function testGetName() @@ -96,7 +96,7 @@ class RemoveXPercentManagerTest extends \PHPUnit_Framework_TestCase } /** - * @covers Thelia\Coupon\Type\RemoveXPercentManager::getToolTip + * @covers Thelia\Coupon\Type\RemoveXPercent::getToolTip * @todo Implement testGetToolTip(). */ public function testGetToolTip() diff --git a/install/faker.php b/install/faker.php index d7ddd3b44..30a55f397 100755 --- a/install/faker.php +++ b/install/faker.php @@ -1,9 +1,9 @@ setExpirationDate($date->setTimestamp(strtotime("today + 3 months"))); - $condition1 = new MatchForTotalAmountManager($adapter); + $condition1 = new MatchForTotalAmount($adapter); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 40.00, - MatchForTotalAmountManager::INPUT2 => 'EUR' + MatchForTotalAmount::INPUT1 => 40.00, + MatchForTotalAmount::INPUT2 => 'EUR' ); $condition1->setValidatorsFromForm($operators, $values); - $condition2 = new MatchForTotalAmountManager($adapter); + $condition2 = new MatchForTotalAmount($adapter); $operators = array( - MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR, - MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmount::INPUT1 => Operators::INFERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); $values = array( - MatchForTotalAmountManager::INPUT1 => 400.00, - MatchForTotalAmountManager::INPUT2 => 'EUR' + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR' ); $condition2->setValidatorsFromForm($operators, $values); @@ -727,12 +727,12 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $date = new \DateTime(); $coupon2->setExpirationDate($date->setTimestamp(strtotime("today + 1 months"))); - $condition1 = new MatchForXArticlesManager($adapter); + $condition1 = new MatchForXArticles($adapter); $operators = array( - MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR, + MatchForXArticles::INPUT1 => Operators::SUPERIOR, ); $values = array( - MatchForXArticlesManager::INPUT1 => 4, + MatchForXArticles::INPUT1 => 4, ); $condition1->setValidatorsFromForm($operators, $values); $conditions = new ConditionCollection(); @@ -771,7 +771,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $date = new \DateTime(); $coupon3->setExpirationDate($date->setTimestamp(strtotime("today + 2 months"))); - $condition1 = new MatchForEveryoneManager($adapter); + $condition1 = new MatchForEveryone($adapter); $operators = array(); $values = array(); $condition1->setValidatorsFromForm($operators, $values); diff --git a/install/faker_add_ecotax.php b/install/faker_add_ecotax.php index 4a9c8de39..0bb6838d9 100755 --- a/install/faker_add_ecotax.php +++ b/install/faker_add_ecotax.php @@ -1,9 +1,9 @@ Date: Sat, 23 Nov 2013 20:21:52 +0100 Subject: [PATCH 05/23] Fix generated unit test stub files --- core/lib/Thelia/Tests/Coupon/BaseFacadeTest.php | 5 ----- core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php | 4 ---- core/lib/Thelia/Tests/Coupon/CouponManagerTest.php | 5 ----- core/lib/Thelia/Tests/Coupon/Type/CouponAbstractTest.php | 5 ----- .../Thelia/Tests/Coupon/Type/RemoveXAmountManagerTest.php | 5 ----- .../Thelia/Tests/Coupon/Type/RemoveXPercentManagerTest.php | 5 ----- 6 files changed, 29 deletions(-) diff --git a/core/lib/Thelia/Tests/Coupon/BaseFacadeTest.php b/core/lib/Thelia/Tests/Coupon/BaseFacadeTest.php index 75ec32382..6e1619aac 100644 --- a/core/lib/Thelia/Tests/Coupon/BaseFacadeTest.php +++ b/core/lib/Thelia/Tests/Coupon/BaseFacadeTest.php @@ -37,10 +37,6 @@ namespace Thelia\Coupon; */ class BaseFacadeTest extends \PHPUnit_Framework_TestCase { - /** - * @var BaseFacade - */ - protected $object; /** * Sets up the fixture, for example, opens a network connection. @@ -48,7 +44,6 @@ class BaseFacadeTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->object = new BaseFacade; } /** diff --git a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php index 97804e9da..218b70611 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php @@ -45,10 +45,6 @@ use Thelia\Model\CurrencyQuery; */ class CouponFactoryTest extends \PHPUnit_Framework_TestCase { - /** - * @var CouponFactory - */ - protected $object; /** * Sets up the fixture, for example, opens a network connection. diff --git a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php index 2a33271bf..07c6bc597 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php @@ -37,10 +37,6 @@ namespace Thelia\Coupon; */ class CouponManagerTest extends \PHPUnit_Framework_TestCase { - /** - * @var CouponManager - */ - protected $object; /** * Sets up the fixture, for example, opens a network connection. @@ -48,7 +44,6 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->object = new CouponManager; } /** diff --git a/core/lib/Thelia/Tests/Coupon/Type/CouponAbstractTest.php b/core/lib/Thelia/Tests/Coupon/Type/CouponAbstractTest.php index 82a4fc0a4..184f1ef29 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/CouponAbstractTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/CouponAbstractTest.php @@ -37,10 +37,6 @@ namespace Thelia\Coupon\Type; */ class CouponAbstractTest extends \PHPUnit_Framework_TestCase { - /** - * @var CouponAbstract - */ - protected $object; /** * Sets up the fixture, for example, opens a network connection. @@ -48,7 +44,6 @@ class CouponAbstractTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { -// $this->object = new CouponAbstract(); } /** diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountManagerTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountManagerTest.php index cdfa7c875..c15fa7379 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountManagerTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountManagerTest.php @@ -37,10 +37,6 @@ namespace Thelia\Coupon\Type; */ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase { - /** - * @var RemoveXAmount - */ - protected $object; /** * Sets up the fixture, for example, opens a network connection. @@ -48,7 +44,6 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { -// $this->object = new RemoveXAmount; } /** diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentManagerTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentManagerTest.php index 28123ea83..fad80a389 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentManagerTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentManagerTest.php @@ -37,10 +37,6 @@ namespace Thelia\Coupon\Type; */ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase { - /** - * @var RemoveXPercent - */ - protected $object; /** * Sets up the fixture, for example, opens a network connection. @@ -48,7 +44,6 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { -// $this->object = new RemoveXPercent; } /** From f40476e3ea827f7b2d9d10947254933ea482497a Mon Sep 17 00:00:00 2001 From: gmorel Date: Sat, 23 Nov 2013 22:15:45 +0100 Subject: [PATCH 06/23] Coupon not found by the factory now just return false --- core/lib/Thelia/Action/Coupon.php | 59 ++++--- core/lib/Thelia/Coupon/CouponFactory.php | 5 +- .../Thelia/Tests/Coupon/CouponFactoryTest.php | 165 ++++++++++++++++++ 3 files changed, 196 insertions(+), 33 deletions(-) diff --git a/core/lib/Thelia/Action/Coupon.php b/core/lib/Thelia/Action/Coupon.php index 4ac8481f7..a4188c2fc 100755 --- a/core/lib/Thelia/Action/Coupon.php +++ b/core/lib/Thelia/Action/Coupon.php @@ -94,6 +94,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface public function consume(CouponConsumeEvent $event) { $totalDiscount = 0; + $isValid = false; /** @var CouponFactory $couponFactory */ $couponFactory = $this->container->get('thelia.coupon.factory'); @@ -104,40 +105,40 @@ class Coupon extends BaseAction implements EventSubscriberInterface /** @var CouponInterface $coupon */ $coupon = $couponFactory->buildCouponManagerFromCode($event->getCode()); - $isValid = $coupon->isMatching(); + if ($coupon) { + $isValid = $coupon->isMatching(); + if ($isValid) { + /** @var Request $request */ + $request = $this->container->get('request'); + $consumedCoupons = $request->getSession()->getConsumedCoupons(); - if ($isValid) { - /** @var Request $request */ - $request = $this->container->get('request'); - $consumedCoupons = $request->getSession()->getConsumedCoupons(); + if (!isset($consumedCoupons) || !$consumedCoupons) { + $consumedCoupons = array(); + } - if (!isset($consumedCoupons) || !$consumedCoupons) { - $consumedCoupons = array(); + // Prevent accumulation of the same Coupon on a Checkout + $consumedCoupons[$event->getCode()] = $event->getCode(); + + $request->getSession()->setConsumedCoupons($consumedCoupons); + + $totalDiscount = $couponManager->getDiscount(); + // @todo insert false product in cart with the name of the coupon and the discount as negative price + + // Decrement coupon quantity + // @todo move this part in after order event + $couponQuery = CouponQuery::create(); + $couponModel = $couponQuery->findOneByCode($coupon->getCode()); + $couponManager->decrementeQuantity($couponModel); + + $request + ->getSession() + ->getCart() + ->setDiscount($totalDiscount) + ->save(); } - - // Prevent accumulation of the same Coupon on a Checkout - $consumedCoupons[$event->getCode()] = $event->getCode(); - - $request->getSession()->setConsumedCoupons($consumedCoupons); - - $totalDiscount = $couponManager->getDiscount(); - // @todo insert false product in cart with the name of the coupon and the discount as negative price - - // Decrement coupon quantity - // @todo move this part in after order event - $couponQuery = CouponQuery::create(); - $couponModel = $couponQuery->findOneByCode($coupon->getCode()); - $couponManager->decrementeQuantity($couponModel); - - $request - ->getSession() - ->getCart() - ->setDiscount($totalDiscount) - ->save() - ; - } + $event->setIsValid($isValid); $event->setDiscount($totalDiscount); } diff --git a/core/lib/Thelia/Coupon/CouponFactory.php b/core/lib/Thelia/Coupon/CouponFactory.php index e528a1d49..fbbfa6a8a 100644 --- a/core/lib/Thelia/Coupon/CouponFactory.php +++ b/core/lib/Thelia/Coupon/CouponFactory.php @@ -68,7 +68,6 @@ class CouponFactory * * @throws \Thelia\Exception\CouponExpiredException * @throws \Thelia\Exception\InvalidConditionException - * @throws \Symfony\Component\Translation\Exception\NotFoundResourceException * @return CouponInterface ready to be processed */ public function buildCouponManagerFromCode($couponCode) @@ -76,9 +75,7 @@ class CouponFactory /** @var Coupon $couponModel */ $couponModel = $this->facade->findOneCouponByCode($couponCode); if ($couponModel === null) { - throw new NotFoundResourceException( - 'Coupon ' . $couponCode . ' not found in Database' - ); + return false; } if ($couponModel->getExpirationDate() < new \DateTime()) { diff --git a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php index 218b70611..0baa4753a 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php @@ -238,4 +238,169 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $this->assertEquals($expected, $actual); } + + /** + * @covers Thelia\Coupon\CouponFactory::buildCouponManagerFromCode + */ + public function testBuildCouponFromCodeUnknownCode() + { + $stubFacade = $this->generateFacadeStub(); + + $stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container'); + + $conditionFactory = new ConditionFactory($stubContainer); + $stubFacade->expects($this->any()) + ->method('findOneCouponByCode') + ->will($this->returnValue(null)); + + $couponManager = new RemoveXAmount($stubFacade); + + + + $stubContainer->expects($this->any()) + ->method('get') + ->will($this->onConsecutiveCalls($stubFacade, $couponManager)); + + $stubContainer->expects($this->any()) + ->method('has') + ->will($this->returnValue(true)); + + $factory = new CouponFactory($stubContainer); + $actual = $factory->buildCouponManagerFromCode('XMAS'); + $expected = false; + + $this->assertEquals($expected, $actual); + + } + + /** + * @covers Thelia\Coupon\CouponFactory::buildCouponManagerFromCode + * @expectedException \Thelia\Exception\CouponExpiredException + */ + public function testBuildCouponFromCodeExpiredCoupon() + { + $stubFacade = $this->generateFacadeStub(); + + $stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container'); + + $conditionFactory = new ConditionFactory($stubContainer); + $couponModel = $this->generateCouponModel($stubFacade, $conditionFactory); + $date = new \DateTime(); + $couponModel->setExpirationDate($date->setTimestamp(strtotime("today - 3 months"))); + $stubFacade->expects($this->any()) + ->method('findOneCouponByCode') + ->will($this->returnValue($couponModel)); + + $couponManager = new RemoveXAmount($stubFacade); + + + $condition1 = new MatchForTotalAmount($stubFacade); + $operators = array( + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmount::INPUT1 => 40.00, + MatchForTotalAmount::INPUT2 => 'EUR' + ); + $condition1->setValidatorsFromForm($operators, $values); + + $condition2 = new MatchForTotalAmount($stubFacade); + $operators = array( + MatchForTotalAmount::INPUT1 => Operators::INFERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR' + ); + $condition2->setValidatorsFromForm($operators, $values); + + $conditions = new ConditionCollection(); + $conditions->add($condition1); + $conditions->add($condition2); + $stubConditionFactory = $this->getMockBuilder('\Thelia\Condition\ConditionFactory') + ->disableOriginalConstructor() + ->getMock(); + $stubConditionFactory->expects($this->any()) + ->method('unserializeConditionCollection') + ->will($this->returnValue($conditions)); + + + $stubContainer->expects($this->any()) + ->method('get') + ->will($this->onConsecutiveCalls($stubFacade, $couponManager, $stubConditionFactory)); + + $stubContainer->expects($this->any()) + ->method('has') + ->will($this->returnValue(true)); + + $factory = new CouponFactory($stubContainer); + $actual = $factory->buildCouponManagerFromCode('XMAS'); + + } + + /** + * @covers Thelia\Coupon\CouponFactory::buildCouponManagerFromCode + * @expectedException \Thelia\Exception\InvalidConditionException + */ + public function testBuildCouponFromCodeNoConditionCoupon() + { + $stubFacade = $this->generateFacadeStub(); + + $stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container'); + + $conditionFactory = new ConditionFactory($stubContainer); + $couponModel = $this->generateCouponModel($stubFacade, $conditionFactory); + $stubFacade->expects($this->any()) + ->method('findOneCouponByCode') + ->will($this->returnValue($couponModel)); + + $couponManager = new RemoveXAmount($stubFacade); + + + $condition1 = new MatchForTotalAmount($stubFacade); + $operators = array( + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmount::INPUT1 => 40.00, + MatchForTotalAmount::INPUT2 => 'EUR' + ); + $condition1->setValidatorsFromForm($operators, $values); + + $condition2 = new MatchForTotalAmount($stubFacade); + $operators = array( + MatchForTotalAmount::INPUT1 => Operators::INFERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR' + ); + $condition2->setValidatorsFromForm($operators, $values); + + $conditions = new ConditionCollection(); + $stubConditionFactory = $this->getMockBuilder('\Thelia\Condition\ConditionFactory') + ->disableOriginalConstructor() + ->getMock(); + $stubConditionFactory->expects($this->any()) + ->method('unserializeConditionCollection') + ->will($this->returnValue($conditions)); + + + $stubContainer->expects($this->any()) + ->method('get') + ->will($this->onConsecutiveCalls($stubFacade, $couponManager, $stubConditionFactory)); + + $stubContainer->expects($this->any()) + ->method('has') + ->will($this->returnValue(true)); + + $factory = new CouponFactory($stubContainer); + $expected = $couponManager; + $actual = $factory->buildCouponManagerFromCode('XMAS'); + + } } From 4447dbcd9a352521c967c20d7558f10fb5d05c8f Mon Sep 17 00:00:00 2001 From: gmorel Date: Sat, 23 Nov 2013 22:29:15 +0100 Subject: [PATCH 07/23] Coupon : Fix the error if a given coupon leads to an unknown service id --- core/lib/Thelia/Coupon/CouponFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/Thelia/Coupon/CouponFactory.php b/core/lib/Thelia/Coupon/CouponFactory.php index fbbfa6a8a..99388a7e0 100644 --- a/core/lib/Thelia/Coupon/CouponFactory.php +++ b/core/lib/Thelia/Coupon/CouponFactory.php @@ -84,7 +84,7 @@ class CouponFactory /** @var CouponInterface $couponInterface */ $couponInterface = $this->buildCouponManagerFromModel($couponModel); - if ($couponInterface->getConditions()->isEmpty()) { + if ($couponInterface && $couponInterface->getConditions()->isEmpty()) { throw new InvalidConditionException( get_class($couponInterface) ); From bcad9b5da12a0cf3d9a73ce1554691353949bdd2 Mon Sep 17 00:00:00 2001 From: gmorel Date: Sat, 23 Nov 2013 22:31:18 +0100 Subject: [PATCH 08/23] Coupon : rename --- core/lib/Thelia/Action/Coupon.php | 2 +- core/lib/Thelia/Coupon/CouponFactory.php | 6 +++--- .../Thelia/Tests/Coupon/CouponFactoryTest.php | 16 ++++++++-------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/lib/Thelia/Action/Coupon.php b/core/lib/Thelia/Action/Coupon.php index a4188c2fc..90dded5a8 100755 --- a/core/lib/Thelia/Action/Coupon.php +++ b/core/lib/Thelia/Action/Coupon.php @@ -103,7 +103,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface $couponManager = $this->container->get('thelia.coupon.manager'); /** @var CouponInterface $coupon */ - $coupon = $couponFactory->buildCouponManagerFromCode($event->getCode()); + $coupon = $couponFactory->buildCouponFromCode($event->getCode()); if ($coupon) { $isValid = $coupon->isMatching(); diff --git a/core/lib/Thelia/Coupon/CouponFactory.php b/core/lib/Thelia/Coupon/CouponFactory.php index 99388a7e0..05f47ae7c 100644 --- a/core/lib/Thelia/Coupon/CouponFactory.php +++ b/core/lib/Thelia/Coupon/CouponFactory.php @@ -70,7 +70,7 @@ class CouponFactory * @throws \Thelia\Exception\InvalidConditionException * @return CouponInterface ready to be processed */ - public function buildCouponManagerFromCode($couponCode) + public function buildCouponFromCode($couponCode) { /** @var Coupon $couponModel */ $couponModel = $this->facade->findOneCouponByCode($couponCode); @@ -83,7 +83,7 @@ class CouponFactory } /** @var CouponInterface $couponInterface */ - $couponInterface = $this->buildCouponManagerFromModel($couponModel); + $couponInterface = $this->buildCouponFromModel($couponModel); if ($couponInterface && $couponInterface->getConditions()->isEmpty()) { throw new InvalidConditionException( get_class($couponInterface) @@ -100,7 +100,7 @@ class CouponFactory * * @return CouponInterface ready to use CouponInterface object instance */ - protected function buildCouponManagerFromModel(Coupon $model) + protected function buildCouponFromModel(Coupon $model) { $isCumulative = ($model->getIsCumulative() == 1 ? true : false); $isRemovingPostage = ($model->getIsRemovingPostage() == 1 ? true : false); diff --git a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php index 0baa4753a..696a453a5 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php @@ -174,7 +174,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua } /** - * @covers Thelia\Coupon\CouponFactory::buildCouponManagerFromCode + * @covers Thelia\Coupon\CouponFactory::buildCouponFromCode */ public function testBuildCouponFromCode() { @@ -234,13 +234,13 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $factory = new CouponFactory($stubContainer); $expected = $couponManager; - $actual = $factory->buildCouponManagerFromCode('XMAS'); + $actual = $factory->buildCouponFromCode('XMAS'); $this->assertEquals($expected, $actual); } /** - * @covers Thelia\Coupon\CouponFactory::buildCouponManagerFromCode + * @covers Thelia\Coupon\CouponFactory::buildCouponFromCode */ public function testBuildCouponFromCodeUnknownCode() { @@ -266,7 +266,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua ->will($this->returnValue(true)); $factory = new CouponFactory($stubContainer); - $actual = $factory->buildCouponManagerFromCode('XMAS'); + $actual = $factory->buildCouponFromCode('XMAS'); $expected = false; $this->assertEquals($expected, $actual); @@ -274,7 +274,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua } /** - * @covers Thelia\Coupon\CouponFactory::buildCouponManagerFromCode + * @covers Thelia\Coupon\CouponFactory::buildCouponFromCode * @expectedException \Thelia\Exception\CouponExpiredException */ public function testBuildCouponFromCodeExpiredCoupon() @@ -336,12 +336,12 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua ->will($this->returnValue(true)); $factory = new CouponFactory($stubContainer); - $actual = $factory->buildCouponManagerFromCode('XMAS'); + $actual = $factory->buildCouponFromCode('XMAS'); } /** - * @covers Thelia\Coupon\CouponFactory::buildCouponManagerFromCode + * @covers Thelia\Coupon\CouponFactory::buildCouponFromCode * @expectedException \Thelia\Exception\InvalidConditionException */ public function testBuildCouponFromCodeNoConditionCoupon() @@ -400,7 +400,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $factory = new CouponFactory($stubContainer); $expected = $couponManager; - $actual = $factory->buildCouponManagerFromCode('XMAS'); + $actual = $factory->buildCouponFromCode('XMAS'); } } From 2884b0a3b7bbdaf01a4ef1ffdd6e265517ed1c78 Mon Sep 17 00:00:00 2001 From: gmorel Date: Sat, 23 Nov 2013 22:33:30 +0100 Subject: [PATCH 09/23] Coupon : spelling --- core/lib/Thelia/Action/Coupon.php | 2 +- core/lib/Thelia/Coupon/CouponManager.php | 2 +- core/lib/Thelia/Tests/Coupon/CouponManagerTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/lib/Thelia/Action/Coupon.php b/core/lib/Thelia/Action/Coupon.php index 90dded5a8..b68b27572 100755 --- a/core/lib/Thelia/Action/Coupon.php +++ b/core/lib/Thelia/Action/Coupon.php @@ -128,7 +128,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface // @todo move this part in after order event $couponQuery = CouponQuery::create(); $couponModel = $couponQuery->findOneByCode($coupon->getCode()); - $couponManager->decrementeQuantity($couponModel); + $couponManager->decrementQuantity($couponModel); $request ->getSession() diff --git a/core/lib/Thelia/Coupon/CouponManager.php b/core/lib/Thelia/Coupon/CouponManager.php index 4bc3aed0e..4f075f989 100644 --- a/core/lib/Thelia/Coupon/CouponManager.php +++ b/core/lib/Thelia/Coupon/CouponManager.php @@ -239,7 +239,7 @@ class CouponManager * * @return bool */ - public function decrementeQuantity(Coupon $coupon) + public function decrementQuantity(Coupon $coupon) { $ret = true; try { diff --git a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php index 07c6bc597..d89f4c81c 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php @@ -115,7 +115,7 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase } /** - * @covers Thelia\Coupon\CouponManager::decrementeQuantity + * @covers Thelia\Coupon\CouponManager::decrementQuantity * @todo Implement testDecrementeQuantity(). */ public function testDecrementeQuantity() From 20e004b9f5a0e928af7fbf25e326737d3c39b2a8 Mon Sep 17 00:00:00 2001 From: gmorel Date: Sat, 23 Nov 2013 23:06:32 +0100 Subject: [PATCH 10/23] Coupon : Bug fix when coupon max usage was not correctly decremented --- core/lib/Thelia/Coupon/CouponManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/Thelia/Coupon/CouponManager.php b/core/lib/Thelia/Coupon/CouponManager.php index 4f075f989..145bc60f2 100644 --- a/core/lib/Thelia/Coupon/CouponManager.php +++ b/core/lib/Thelia/Coupon/CouponManager.php @@ -248,7 +248,7 @@ class CouponManager if ($oldMaxUsage > 0) { $oldMaxUsage--; - $coupon->setMaxUsage($$oldMaxUsage); + $coupon->setMaxUsage($oldMaxUsage); $coupon->save(); } From 69a72cd5558656d63268c00c897b90233a7897a1 Mon Sep 17 00:00:00 2001 From: gmorel Date: Sat, 23 Nov 2013 23:23:58 +0100 Subject: [PATCH 11/23] Coupon : Add ability to know usage left after decremental --- core/lib/Thelia/Coupon/CouponManager.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/lib/Thelia/Coupon/CouponManager.php b/core/lib/Thelia/Coupon/CouponManager.php index 145bc60f2..ea41a4f03 100644 --- a/core/lib/Thelia/Coupon/CouponManager.php +++ b/core/lib/Thelia/Coupon/CouponManager.php @@ -237,20 +237,21 @@ class CouponManager * * @param \Thelia\Model\Coupon $coupon Coupon consumed * - * @return bool + * @return int Usage left after decremental */ public function decrementQuantity(Coupon $coupon) { - $ret = true; + $ret = -1; try { - $oldMaxUsage = $coupon->getMaxUsage(); + $usageLeft = $coupon->getMaxUsage(); - if ($oldMaxUsage > 0) { - $oldMaxUsage--; - $coupon->setMaxUsage($oldMaxUsage); + if ($usageLeft > 0) { + $usageLeft--; + $coupon->setMaxUsage($usageLeft); $coupon->save(); + $ret = $usageLeft; } } catch(\Exception $e) { From 25934b80b946828116aa8fdcd8c55d9c800acf15 Mon Sep 17 00:00:00 2001 From: gmorel Date: Sat, 23 Nov 2013 23:56:06 +0100 Subject: [PATCH 12/23] Coupon : buildCouponFromModel becomes public --- core/lib/Thelia/Coupon/CouponFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/Thelia/Coupon/CouponFactory.php b/core/lib/Thelia/Coupon/CouponFactory.php index 05f47ae7c..2c1befd2c 100644 --- a/core/lib/Thelia/Coupon/CouponFactory.php +++ b/core/lib/Thelia/Coupon/CouponFactory.php @@ -100,7 +100,7 @@ class CouponFactory * * @return CouponInterface ready to use CouponInterface object instance */ - protected function buildCouponFromModel(Coupon $model) + public function buildCouponFromModel(Coupon $model) { $isCumulative = ($model->getIsCumulative() == 1 ? true : false); $isRemovingPostage = ($model->getIsRemovingPostage() == 1 ? true : false); From 469a07cdb3fac41a67efea506595f15db351fee1 Mon Sep 17 00:00:00 2001 From: gmorel Date: Sun, 24 Nov 2013 00:26:16 +0100 Subject: [PATCH 13/23] Coupon : Adding unit tests --- .../Thelia/Tests/Coupon/CouponFactoryTest.php | 3 +- .../Thelia/Tests/Coupon/CouponManagerTest.php | 365 ++++++++++++++++-- 2 files changed, 331 insertions(+), 37 deletions(-) diff --git a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php index 696a453a5..b70bdf247 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php @@ -269,7 +269,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $actual = $factory->buildCouponFromCode('XMAS'); $expected = false; - $this->assertEquals($expected, $actual); + $this->assertEquals($expected, $actual, 'CouponFactory->buildCouponFromCode should return false if the given code is unknown'); } @@ -399,7 +399,6 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua ->will($this->returnValue(true)); $factory = new CouponFactory($stubContainer); - $expected = $couponManager; $actual = $factory->buildCouponFromCode('XMAS'); } diff --git a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php index d89f4c81c..c3f558557 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php @@ -22,6 +22,14 @@ /**********************************************************************************/ namespace Thelia\Coupon; +use Thelia\Condition\ConditionCollection; +use Thelia\Condition\ConditionEvaluator; +use Thelia\Condition\ConditionFactory; +use Thelia\Condition\Implementation\MatchForTotalAmount; +use Thelia\Condition\Operators; +use Thelia\Coupon\Type\RemoveXAmount; +use Thelia\Model\Coupon; +use Thelia\Model\CurrencyQuery; /** * Created by JetBrains PhpStorm. @@ -54,6 +62,71 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase { } + + /** + * Generate a valid Coupon model + */ + public function generateCouponModel($facade, ConditionFactory $conditionFactory) + { + // Coupons + $coupon1 = new Coupon(); + $coupon1->setCode('XMAS'); + $coupon1->setType('thelia.coupon.type.remove_x_amount'); + $coupon1->setTitle('Christmas coupon'); + $coupon1->setShortDescription('Coupon for Christmas removing 10€ if your total checkout is more than 40€'); + $coupon1->setDescription('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras at luctus tellus. Integer turpis mauris, aliquet vitae risus tristique, pellentesque vestibulum urna. Vestibulum sodales laoreet lectus dictum suscipit. Praesent vulputate, sem id varius condimentum, quam magna tempor elit, quis venenatis ligula nulla eget libero. Cras egestas euismod tellus, id pharetra leo suscipit quis. Donec lacinia ac lacus et ultricies. Nunc in porttitor neque. Proin at quam congue, consectetur orci sed, congue nulla. Nulla eleifend nunc ligula, nec pharetra elit tempus quis. Vivamus vel mauris sed est dictum blandit. Maecenas blandit dapibus velit ut sollicitudin. In in euismod mauris, consequat viverra magna. Cras velit velit, sollicitudin commodo tortor gravida, tempus varius nulla. + +Donec rhoncus leo mauris, id porttitor ante luctus tempus. Curabitur quis augue feugiat, ullamcorper mauris ac, interdum mi. Quisque aliquam lorem vitae felis lobortis, id interdum turpis mattis. Vestibulum diam massa, ornare congue blandit quis, facilisis at nisl. In tortor metus, venenatis non arcu nec, sollicitudin ornare nisl. Nunc erat risus, varius nec urna at, iaculis lacinia elit. Aenean ut felis tempus, tincidunt odio non, sagittis nisl. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec vitae hendrerit elit. Nunc sit amet gravida risus, euismod lobortis massa. Nam a erat mauris. Nam a malesuada lorem. Nulla id accumsan dolor, sed rhoncus tellus. Quisque dictum felis sed leo auctor, at volutpat lectus viverra. Morbi rutrum, est ac aliquam imperdiet, nibh sem sagittis justo, ac mattis magna lacus eu nulla. + +Duis interdum lectus nulla, nec pellentesque sapien condimentum at. Suspendisse potenti. Sed eu purus tellus. Nunc quis rhoncus metus. Fusce vitae tellus enim. Interdum et malesuada fames ac ante ipsum primis in faucibus. Etiam tempor porttitor erat vitae iaculis. Sed est elit, consequat non ornare vitae, vehicula eget lectus. Etiam consequat sapien mauris, eget consectetur magna imperdiet eget. Nunc sollicitudin luctus velit, in commodo nulla adipiscing fermentum. Fusce nisi sapien, posuere vitae metus sit amet, facilisis sollicitudin dui. Fusce ultricies auctor enim sit amet iaculis. Morbi at vestibulum enim, eget adipiscing eros. + +Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentesque elit erat, lacinia sed semper ac, sagittis vel elit. Nam eu convallis est. Curabitur rhoncus odio vitae consectetur pellentesque. Nam vitae arcu nec ante scelerisque dignissim vel nec neque. Suspendisse augue nulla, mollis eget dui et, tempor facilisis erat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac diam ipsum. Donec convallis dui ultricies velit auctor, non lobortis nulla ultrices. Morbi vitae dignissim ante, sit amet lobortis tortor. Nunc dapibus condimentum augue, in molestie neque congue non. + +Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.'); + $coupon1->setAmount(10.00); + $coupon1->setIsUsed(true); + $coupon1->setIsEnabled(true); + $date = new \DateTime(); + $coupon1->setExpirationDate($date->setTimestamp(strtotime("today + 3 months"))); + + $condition1 = new MatchForTotalAmount($facade); + $operators = array( + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmount::INPUT1 => 40.00, + MatchForTotalAmount::INPUT2 => 'EUR' + ); + $condition1->setValidatorsFromForm($operators, $values); + + $condition2 = new MatchForTotalAmount($facade); + $operators = array( + MatchForTotalAmount::INPUT1 => Operators::INFERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR' + ); + $condition2->setValidatorsFromForm($operators, $values); + + $conditions = new ConditionCollection(); + $conditions->add($condition1); + $conditions->add($condition2); + + $serializedConditions = $conditionFactory->serializeConditionCollection($conditions); + $coupon1->setSerializedConditions($serializedConditions); + + + $coupon1->setMaxUsage(40); + $coupon1->setIsCumulative(true); + $coupon1->setIsRemovingPostage(false); + $coupon1->setIsAvailableOnSpecialOffers(true); + + return $coupon1; + } + /** * @covers Thelia\Coupon\CouponManager::getDiscount * @todo Implement testGetDiscount(). @@ -68,61 +141,283 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase /** * @covers Thelia\Coupon\CouponManager::addAvailableCoupon - * @todo Implement testAddAvailableCoupon(). - */ - public function testAddAvailableCoupon() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** * @covers Thelia\Coupon\CouponManager::getAvailableCoupons - * @todo Implement testGetAvailableCoupons(). */ public function testGetAvailableCoupons() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $stubFacade = $this->generateFacadeStub(); + $stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container'); + + $conditionFactory = new ConditionFactory($stubContainer); + + + + $stubFacade->expects($this->any()) + ->method('getCurrentCoupons') + ->will($this->returnValue(array())); + + $conditions = new ConditionCollection(); + $stubConditionFactory = $this->getMockBuilder('\Thelia\Condition\ConditionFactory') + ->disableOriginalConstructor() + ->getMock(); + $stubConditionFactory->expects($this->any()) + ->method('unserializeConditionCollection') + ->will($this->returnValue($conditions)); + + $couponManager = new RemoveXAmount($stubFacade); + $stubContainer->expects($this->any()) + ->method('get') + ->will($this->onConsecutiveCalls($stubFacade, $couponManager, $stubConditionFactory, $stubFacade)); + $stubContainer->expects($this->any()) + ->method('has') + ->will($this->returnValue(true)); + + $couponFactory = new CouponFactory($stubContainer); + $model1 = $this->generateCouponModel($stubFacade, $conditionFactory); + $coupon1 = $couponFactory->buildCouponFromModel($model1); + $coupon2 = clone $coupon1; + + + $couponManager = new CouponManager($stubContainer); + $couponManager->addAvailableCoupon($coupon1); + $couponManager->addAvailableCoupon($coupon2); + $actual = $couponManager->getAvailableCoupons(); + $expected = array($coupon1, $coupon2); + + $this->assertEquals($expected, $actual); } /** * @covers Thelia\Coupon\CouponManager::addAvailableCondition - * @todo Implement testAddAvailableCondition(). - */ - public function testAddAvailableCondition() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** * @covers Thelia\Coupon\CouponManager::getAvailableConditions - * @todo Implement testGetAvailableConditions(). */ public function testGetAvailableConditions() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' + $stubFacade = $this->generateFacadeStub(); + $stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container'); + + $condition1 = new MatchForTotalAmount($stubFacade); + $operators = array( + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); + $values = array( + MatchForTotalAmount::INPUT1 => 40.00, + MatchForTotalAmount::INPUT2 => 'EUR' + ); + $condition1->setValidatorsFromForm($operators, $values); + + $condition2 = new MatchForTotalAmount($stubFacade); + $operators = array( + MatchForTotalAmount::INPUT1 => Operators::INFERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR' + ); + $condition2->setValidatorsFromForm($operators, $values); + + $conditions = new ConditionCollection(); + $conditions->add($condition1); + $conditions->add($condition2); + + $stubFacade->expects($this->any()) + ->method('getCurrentCoupons') + ->will($this->returnValue(array())); + + $stubContainer->expects($this->any()) + ->method('get') + ->will($this->onConsecutiveCalls($stubFacade)); + + + $couponManager = new CouponManager($stubContainer); + $couponManager->addAvailableCondition($condition1); + $couponManager->addAvailableCondition($condition2); + $actual = $couponManager->getAvailableConditions(); + $expected = array($condition1, $condition2); + + $this->assertEquals($expected, $actual); } /** * @covers Thelia\Coupon\CouponManager::decrementQuantity - * @todo Implement testDecrementeQuantity(). */ public function testDecrementeQuantity() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' + $stubFacade = $this->generateFacadeStub(); + $stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container'); + + $coupon = new RemoveXAmount($stubFacade); + $date = new \DateTime(); + $coupon->set($stubFacade, 'XMAS', '', '', '', 21.00, true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) ); + + $condition1 = new MatchForTotalAmount($stubFacade); + $operators = array( + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); + $values = array( + MatchForTotalAmount::INPUT1 => 40.00, + MatchForTotalAmount::INPUT2 => 'EUR' + ); + $condition1->setValidatorsFromForm($operators, $values); + + $condition2 = new MatchForTotalAmount($stubFacade); + $operators = array( + MatchForTotalAmount::INPUT1 => Operators::INFERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR' + ); + $condition2->setValidatorsFromForm($operators, $values); + + $conditions = new ConditionCollection(); + $conditions->add($condition1); + $conditions->add($condition2); + $coupon->setConditions($conditions); + + $stubFacade->expects($this->any()) + ->method('getCurrentCoupons') + ->will($this->returnValue(array($coupon))); + + $stubContainer->expects($this->any()) + ->method('get') + ->will($this->onConsecutiveCalls($stubFacade)); + + + $couponManager = new CouponManager($stubContainer); + + + $stubModel = $this->getMockBuilder('\Thelia\Model\Coupon') + ->disableOriginalConstructor() + ->getMock(); + $stubModel->expects($this->any()) + ->method('getMaxUsage') + ->will($this->returnValue(21)); + $stubModel->expects($this->any()) + ->method('setMaxUsage') + ->will($this->returnValue(true)); + + $actual = $couponManager->decrementQuantity($stubModel); + $expected = 20; + + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Coupon\CouponManager::decrementQuantity + */ + public function testDecrementeQuantityIllimited() + { + $stubFacade = $this->generateFacadeStub(); + $stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container'); + + $coupon = new RemoveXAmount($stubFacade); + $date = new \DateTime(); + $coupon->set($stubFacade, 'XMAS', '', '', '', 21.00, true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) ); + + $condition1 = new MatchForTotalAmount($stubFacade); + $operators = array( + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmount::INPUT1 => 40.00, + MatchForTotalAmount::INPUT2 => 'EUR' + ); + $condition1->setValidatorsFromForm($operators, $values); + + $condition2 = new MatchForTotalAmount($stubFacade); + $operators = array( + MatchForTotalAmount::INPUT1 => Operators::INFERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR' + ); + $condition2->setValidatorsFromForm($operators, $values); + + $conditions = new ConditionCollection(); + $conditions->add($condition1); + $conditions->add($condition2); + $coupon->setConditions($conditions); + + $stubFacade->expects($this->any()) + ->method('getCurrentCoupons') + ->will($this->returnValue(array($coupon))); + + $stubContainer->expects($this->any()) + ->method('get') + ->will($this->onConsecutiveCalls($stubFacade)); + + + $couponManager = new CouponManager($stubContainer); + + + $stubModel = $this->getMockBuilder('\Thelia\Model\Coupon') + ->disableOriginalConstructor() + ->getMock(); + $stubModel->expects($this->any()) + ->method('getMaxUsage') + ->will($this->returnValue(-1)); + $stubModel->expects($this->any()) + ->method('setMaxUsage') + ->will($this->returnValue(true)); + + $actual = $couponManager->decrementQuantity($stubModel); + $expected = -1; + + $this->assertEquals($expected, $actual); + } + + /** + * Generate adapter stub + * + * @param int $cartTotalPrice Cart total price + * @param string $checkoutCurrency Checkout currency + * @param string $i18nOutput Output from each translation + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ + public function generateFacadeStub($cartTotalPrice = 400, $checkoutCurrency = 'EUR', $i18nOutput = '') + { + $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade') + ->disableOriginalConstructor() + ->getMock(); + + $currencies = CurrencyQuery::create(); + $currencies = $currencies->find(); + $stubFacade->expects($this->any()) + ->method('getAvailableCurrencies') + ->will($this->returnValue($currencies)); + + $stubFacade->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue($cartTotalPrice)); + + $stubFacade->expects($this->any()) + ->method('getCheckoutCurrency') + ->will($this->returnValue($checkoutCurrency)); + + $stubFacade->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator') + ->disableOriginalConstructor() + ->getMock(); + $stubTranslator->expects($this->any()) + ->method('trans') + ->will($this->returnValue($i18nOutput)); + + $stubFacade->expects($this->any()) + ->method('getTranslator') + ->will($this->returnValue($stubTranslator)); + + return $stubFacade; } } From 2caa9ea7bd9b73cb6d3da53ba833335d634b2c27 Mon Sep 17 00:00:00 2001 From: gmorel Date: Sun, 24 Nov 2013 01:07:49 +0100 Subject: [PATCH 14/23] Coupon : Adding unit tests --- .../Thelia/Tests/Coupon/CouponManagerTest.php | 52 ++++++++++++++++--- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php index c3f558557..5b6bfeee7 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php @@ -121,7 +121,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $coupon1->setMaxUsage(40); $coupon1->setIsCumulative(true); - $coupon1->setIsRemovingPostage(false); + $coupon1->setIsRemovingPostage(true); $coupon1->setIsAvailableOnSpecialOffers(true); return $coupon1; @@ -129,14 +129,54 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua /** * @covers Thelia\Coupon\CouponManager::getDiscount - * @todo Implement testGetDiscount(). + * @covers Thelia\Coupon\CouponManager::isCouponRemovingPostage + * @covers Thelia\Coupon\CouponManager::sortCoupons + * @covers Thelia\Coupon\CouponManager::getEffect */ public function testGetDiscount() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $stubFacade = $this->generateFacadeStub(); + $stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container'); + + $conditionFactory = new ConditionFactory($stubContainer); + + $conditions = new ConditionCollection(); + $stubConditionFactory = $this->getMockBuilder('\Thelia\Condition\ConditionFactory') + ->disableOriginalConstructor() + ->getMock(); + $stubConditionFactory->expects($this->any()) + ->method('unserializeConditionCollection') + ->will($this->returnValue($conditions)); + + $couponManager = new RemoveXAmount($stubFacade); + $stubContainer->expects($this->any()) + ->method('get') + ->will($this->onConsecutiveCalls($stubFacade, $couponManager, $stubConditionFactory, $stubFacade)); + $stubContainer->expects($this->any()) + ->method('has') + ->will($this->returnValue(true)); + + $couponFactory = new CouponFactory($stubContainer); + $model1 = $this->generateCouponModel($stubFacade, $conditionFactory); + $coupon1 = $couponFactory->buildCouponFromModel($model1); + + $stubFacade->expects($this->any()) + ->method('getCurrentCoupons') + ->will($this->returnValue(array($coupon1))); + $stubFacade->expects($this->any()) + ->method('getCheckoutPostagePrice') + ->will($this->returnValue(35.00)); + $stubFacade->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue(122.53)); + + $couponManager = new CouponManager($stubContainer); + $couponManager->addAvailableCoupon($coupon1); +// $couponManager->addAvailableCoupon($coupon2); + $actual = $couponManager->getDiscount(); + $expected = 45.00; + + $this->assertEquals($expected, $actual); } /** From b738bde56f2ae908227c95528f6d91ec9dc93d01 Mon Sep 17 00:00:00 2001 From: gmorel Date: Sun, 24 Nov 2013 17:55:06 +0100 Subject: [PATCH 15/23] Coupon : Adding unit tests --- .../Thelia/Tests/Coupon/CouponManagerTest.php | 74 +++++++++++++++++-- 1 file changed, 68 insertions(+), 6 deletions(-) diff --git a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php index 5b6bfeee7..c36ce97ae 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php @@ -133,7 +133,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua * @covers Thelia\Coupon\CouponManager::sortCoupons * @covers Thelia\Coupon\CouponManager::getEffect */ - public function testGetDiscount() + public function testGetDiscountCumulativeRemovingPostage() { $stubFacade = $this->generateFacadeStub(); $stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container'); @@ -151,30 +151,92 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $couponManager = new RemoveXAmount($stubFacade); $stubContainer->expects($this->any()) ->method('get') - ->will($this->onConsecutiveCalls($stubFacade, $couponManager, $stubConditionFactory, $stubFacade)); + ->will($this->onConsecutiveCalls($stubFacade, $couponManager, $stubConditionFactory, clone $couponManager, $stubConditionFactory, $stubFacade)); $stubContainer->expects($this->any()) ->method('has') ->will($this->returnValue(true)); $couponFactory = new CouponFactory($stubContainer); $model1 = $this->generateCouponModel($stubFacade, $conditionFactory); + $model1->setAmount(21.00); $coupon1 = $couponFactory->buildCouponFromModel($model1); + $model2 = $this->generateCouponModel($stubFacade, $conditionFactory); + $model2->setCode('XMAS2')->setIsRemovingPostage(true)->setAmount(21.50); + $coupon2 = $couponFactory->buildCouponFromModel($model2); + $stubFacade->expects($this->any()) ->method('getCurrentCoupons') - ->will($this->returnValue(array($coupon1))); + ->will($this->returnValue(array($coupon1, $coupon2))); $stubFacade->expects($this->any()) ->method('getCheckoutPostagePrice') - ->will($this->returnValue(35.00)); + ->will($this->returnValue(8.30)); $stubFacade->expects($this->any()) ->method('getCartTotalPrice') ->will($this->returnValue(122.53)); $couponManager = new CouponManager($stubContainer); $couponManager->addAvailableCoupon($coupon1); -// $couponManager->addAvailableCoupon($coupon2); + $couponManager->addAvailableCoupon($coupon2); $actual = $couponManager->getDiscount(); - $expected = 45.00; + $expected = 50.80; + + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Coupon\CouponManager::getDiscount + * @covers Thelia\Coupon\CouponManager::isCouponRemovingPostage + * @covers Thelia\Coupon\CouponManager::sortCoupons + * @covers Thelia\Coupon\CouponManager::getEffect + */ + public function testGetDiscountNonCumulativeNotRemovingPostage() + { + $stubFacade = $this->generateFacadeStub(); + $stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container'); + + $conditionFactory = new ConditionFactory($stubContainer); + + $conditions = new ConditionCollection(); + $stubConditionFactory = $this->getMockBuilder('\Thelia\Condition\ConditionFactory') + ->disableOriginalConstructor() + ->getMock(); + $stubConditionFactory->expects($this->any()) + ->method('unserializeConditionCollection') + ->will($this->returnValue($conditions)); + + $couponManager = new RemoveXAmount($stubFacade); + $stubContainer->expects($this->any()) + ->method('get') + ->will($this->onConsecutiveCalls($stubFacade, $couponManager, $stubConditionFactory, clone $couponManager, $stubConditionFactory, $stubFacade)); + $stubContainer->expects($this->any()) + ->method('has') + ->will($this->returnValue(true)); + + $couponFactory = new CouponFactory($stubContainer); + $model1 = $this->generateCouponModel($stubFacade, $conditionFactory); + $model1->setAmount(21.00); + $coupon1 = $couponFactory->buildCouponFromModel($model1); + + $model2 = $this->generateCouponModel($stubFacade, $conditionFactory); + $model2->setCode('XMAS2')->setIsRemovingPostage(false)->setAmount(21.50)->setIsCumulative(false); + $coupon2 = $couponFactory->buildCouponFromModel($model2); + + $stubFacade->expects($this->any()) + ->method('getCurrentCoupons') + ->will($this->returnValue(array($coupon1, $coupon2))); + $stubFacade->expects($this->any()) + ->method('getCheckoutPostagePrice') + ->will($this->returnValue(8.30)); + $stubFacade->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue(122.53)); + + $couponManager = new CouponManager($stubContainer); + $couponManager->addAvailableCoupon($coupon1); + $couponManager->addAvailableCoupon($coupon2); + $actual = $couponManager->getDiscount(); + $expected = 21.50; $this->assertEquals($expected, $actual); } From c71cba93e2ebde8839194446e7fe0160089e58ba Mon Sep 17 00:00:00 2001 From: gmorel Date: Sun, 24 Nov 2013 21:44:51 +0100 Subject: [PATCH 16/23] Coupon : Adding unit tests --- .../Thelia/Tests/Coupon/CouponManagerTest.php | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php index c36ce97ae..bf4b9f1e9 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php @@ -241,6 +241,61 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $this->assertEquals($expected, $actual); } + /** + * @covers Thelia\Coupon\CouponManager::getDiscount + * @covers Thelia\Coupon\CouponManager::isCouponRemovingPostage + * @covers Thelia\Coupon\CouponManager::sortCoupons + * @covers Thelia\Coupon\CouponManager::getEffect + */ + public function testGetDiscountGreaterThanCartAmount() + { + $stubFacade = $this->generateFacadeStub(12.25); + $stubFacade->expects($this->any()) + ->method('getCheckoutPostagePrice') + ->will($this->returnValue(8.30)); + + $stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container'); + + $conditionFactory = new ConditionFactory($stubContainer); + + $conditions = new ConditionCollection(); + $stubConditionFactory = $this->getMockBuilder('\Thelia\Condition\ConditionFactory') + ->disableOriginalConstructor() + ->getMock(); + $stubConditionFactory->expects($this->any()) + ->method('unserializeConditionCollection') + ->will($this->returnValue($conditions)); + + $couponManager = new RemoveXAmount($stubFacade); + $stubContainer->expects($this->any()) + ->method('get') + ->will($this->onConsecutiveCalls($stubFacade, $couponManager, $stubConditionFactory, clone $couponManager, $stubConditionFactory, $stubFacade)); + $stubContainer->expects($this->any()) + ->method('has') + ->will($this->returnValue(true)); + + $couponFactory = new CouponFactory($stubContainer); + $model1 = $this->generateCouponModel($stubFacade, $conditionFactory); + $model1->setAmount(21.00); + $coupon1 = $couponFactory->buildCouponFromModel($model1); + + $model2 = $this->generateCouponModel($stubFacade, $conditionFactory); + $model2->setCode('XMAS2')->setIsRemovingPostage(false)->setAmount(21.50)->setIsCumulative(false); + $coupon2 = $couponFactory->buildCouponFromModel($model2); + + $stubFacade->expects($this->any()) + ->method('getCurrentCoupons') + ->will($this->returnValue(array($coupon1, $coupon2))); + + $couponManager = new CouponManager($stubContainer); + $couponManager->addAvailableCoupon($coupon1); + $couponManager->addAvailableCoupon($coupon2); + $actual = $couponManager->getDiscount(); + $expected = 12.25; + + $this->assertEquals($expected, $actual); + } + /** * @covers Thelia\Coupon\CouponManager::addAvailableCoupon * @covers Thelia\Coupon\CouponManager::getAvailableCoupons From ffbd53fcebc82084bb78e4149905a8b1b84a2d91 Mon Sep 17 00:00:00 2001 From: gmorel Date: Sun, 24 Nov 2013 22:05:58 +0100 Subject: [PATCH 17/23] Coupon : Fix namespace issues --- core/lib/Thelia/Condition/ConditionCollection.php | 2 +- core/lib/Thelia/Condition/ConditionEvaluator.php | 1 + core/lib/Thelia/Condition/ConditionFactory.php | 1 + .../Thelia/Condition/Implementation/ConditionAbstract.php | 5 ++++- .../Thelia/Condition/Implementation/ConditionInterface.php | 3 ++- .../lib/Thelia/Condition/Implementation/MatchForEveryone.php | 2 +- .../Thelia/Condition/Implementation/MatchForTotalAmount.php | 2 +- .../Thelia/Condition/Implementation/MatchForXArticles.php | 2 +- core/lib/Thelia/Controller/Admin/CouponController.php | 2 +- core/lib/Thelia/Core/Template/Loop/Coupon.php | 2 +- core/lib/Thelia/Coupon/CouponFactory.php | 1 - core/lib/Thelia/Coupon/CouponManager.php | 2 +- 12 files changed, 15 insertions(+), 10 deletions(-) diff --git a/core/lib/Thelia/Condition/ConditionCollection.php b/core/lib/Thelia/Condition/ConditionCollection.php index 1a31a5f92..14b4076f6 100644 --- a/core/lib/Thelia/Condition/ConditionCollection.php +++ b/core/lib/Thelia/Condition/ConditionCollection.php @@ -24,7 +24,7 @@ namespace Thelia\Condition; use Symfony\Component\DependencyInjection\ContainerInterface; -use Thelia\Condition\ConditionInterface; +use Thelia\Condition\Implementation\ConditionInterface; /** * Created by JetBrains PhpStorm. diff --git a/core/lib/Thelia/Condition/ConditionEvaluator.php b/core/lib/Thelia/Condition/ConditionEvaluator.php index 956694b09..49e566158 100644 --- a/core/lib/Thelia/Condition/ConditionEvaluator.php +++ b/core/lib/Thelia/Condition/ConditionEvaluator.php @@ -24,6 +24,7 @@ namespace Thelia\Condition; use Symfony\Component\DependencyInjection\ContainerInterface; +use Thelia\Condition\Implementation\ConditionInterface; use Thelia\Condition\Operators; use Thelia\Condition\ConditionCollection; diff --git a/core/lib/Thelia/Condition/ConditionFactory.php b/core/lib/Thelia/Condition/ConditionFactory.php index 68eec8083..b472dcb0f 100644 --- a/core/lib/Thelia/Condition/ConditionFactory.php +++ b/core/lib/Thelia/Condition/ConditionFactory.php @@ -24,6 +24,7 @@ namespace Thelia\Condition; use Symfony\Component\DependencyInjection\ContainerInterface; +use Thelia\Condition\Implementation\ConditionInterface; use Thelia\Coupon\FacadeInterface; use Thelia\Condition\ConditionCollection; diff --git a/core/lib/Thelia/Condition/Implementation/ConditionAbstract.php b/core/lib/Thelia/Condition/Implementation/ConditionAbstract.php index b00dae73a..71bd2f60e 100644 --- a/core/lib/Thelia/Condition/Implementation/ConditionAbstract.php +++ b/core/lib/Thelia/Condition/Implementation/ConditionAbstract.php @@ -21,9 +21,12 @@ /* */ /**********************************************************************************/ -namespace Thelia\Condition; +namespace Thelia\Condition\Implementation; use Symfony\Component\Intl\Exception\NotImplementedException; +use Thelia\Condition\ConditionEvaluator; +use Thelia\Condition\Operators; +use Thelia\Condition\SerializableCondition; use Thelia\Core\Translation\Translator; use Thelia\Coupon\FacadeInterface; use Thelia\Exception\InvalidConditionValueException; diff --git a/core/lib/Thelia/Condition/Implementation/ConditionInterface.php b/core/lib/Thelia/Condition/Implementation/ConditionInterface.php index dbb65c57b..10759eaa7 100644 --- a/core/lib/Thelia/Condition/Implementation/ConditionInterface.php +++ b/core/lib/Thelia/Condition/Implementation/ConditionInterface.php @@ -21,8 +21,9 @@ /* */ /**********************************************************************************/ -namespace Thelia\Condition; +namespace Thelia\Condition\Implementation; +use Thelia\Condition\SerializableCondition; use Thelia\Core\Translation\Translator; use Thelia\Coupon\FacadeInterface; diff --git a/core/lib/Thelia/Condition/Implementation/MatchForEveryone.php b/core/lib/Thelia/Condition/Implementation/MatchForEveryone.php index ffd3d3f6f..22d696339 100644 --- a/core/lib/Thelia/Condition/Implementation/MatchForEveryone.php +++ b/core/lib/Thelia/Condition/Implementation/MatchForEveryone.php @@ -24,7 +24,7 @@ namespace Thelia\Condition\Implementation; use InvalidArgumentException; -use Thelia\Condition\ConditionAbstract; +use Thelia\Condition\Implementation\ConditionAbstract; /** * Created by JetBrains PhpStorm. diff --git a/core/lib/Thelia/Condition/Implementation/MatchForTotalAmount.php b/core/lib/Thelia/Condition/Implementation/MatchForTotalAmount.php index 527f1871d..09b63ef00 100644 --- a/core/lib/Thelia/Condition/Implementation/MatchForTotalAmount.php +++ b/core/lib/Thelia/Condition/Implementation/MatchForTotalAmount.php @@ -24,7 +24,7 @@ namespace Thelia\Condition\Implementation; use Symfony\Component\Intl\Exception\NotImplementedException; -use Thelia\Condition\ConditionAbstract; +use Thelia\Condition\Implementation\ConditionAbstract; use Thelia\Condition\Operators; use Thelia\Exception\InvalidConditionOperatorException; use Thelia\Model\Currency; diff --git a/core/lib/Thelia/Condition/Implementation/MatchForXArticles.php b/core/lib/Thelia/Condition/Implementation/MatchForXArticles.php index b7fc479cd..f1c1ebaac 100644 --- a/core/lib/Thelia/Condition/Implementation/MatchForXArticles.php +++ b/core/lib/Thelia/Condition/Implementation/MatchForXArticles.php @@ -24,7 +24,7 @@ namespace Thelia\Condition\Implementation; use InvalidArgumentException; -use Thelia\Condition\ConditionAbstract; +use Thelia\Condition\Implementation\ConditionAbstract; use Thelia\Condition\Operators; use Thelia\Exception\InvalidConditionOperatorException; use Thelia\Exception\InvalidConditionValueException; diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php index d302b6008..b382dbb30 100755 --- a/core/lib/Thelia/Controller/Admin/CouponController.php +++ b/core/lib/Thelia/Controller/Admin/CouponController.php @@ -26,7 +26,7 @@ namespace Thelia\Controller\Admin; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Router; use Thelia\Condition\ConditionFactory; -use Thelia\Condition\ConditionInterface; +use Thelia\Condition\Implementation\ConditionInterface; use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent; use Thelia\Core\Event\TheliaEvents; diff --git a/core/lib/Thelia/Core/Template/Loop/Coupon.php b/core/lib/Thelia/Core/Template/Loop/Coupon.php index 88c9b92a0..e211103da 100755 --- a/core/lib/Thelia/Core/Template/Loop/Coupon.php +++ b/core/lib/Thelia/Core/Template/Loop/Coupon.php @@ -26,7 +26,7 @@ namespace Thelia\Core\Template\Loop; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Util\PropelModelPager; use Thelia\Condition\ConditionFactory; -use Thelia\Condition\ConditionInterface; +use Thelia\Condition\Implementation\ConditionInterface; use Thelia\Core\HttpFoundation\Request; use Thelia\Core\Template\Element\BaseI18nLoop; use Thelia\Core\Template\Element\LoopResult; diff --git a/core/lib/Thelia/Coupon/CouponFactory.php b/core/lib/Thelia/Coupon/CouponFactory.php index 2c1befd2c..214dd0d9c 100644 --- a/core/lib/Thelia/Coupon/CouponFactory.php +++ b/core/lib/Thelia/Coupon/CouponFactory.php @@ -24,7 +24,6 @@ namespace Thelia\Coupon; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\Translation\Exception\NotFoundResourceException; use Thelia\Condition\ConditionFactory; use Thelia\Coupon\Type\CouponInterface; use Thelia\Exception\CouponExpiredException; diff --git a/core/lib/Thelia/Coupon/CouponManager.php b/core/lib/Thelia/Coupon/CouponManager.php index ea41a4f03..c4eff7888 100644 --- a/core/lib/Thelia/Coupon/CouponManager.php +++ b/core/lib/Thelia/Coupon/CouponManager.php @@ -24,7 +24,7 @@ namespace Thelia\Coupon; use Symfony\Component\DependencyInjection\ContainerInterface; -use Thelia\Condition\ConditionInterface; +use Thelia\Condition\Implementation\ConditionInterface; use Thelia\Coupon\Type\CouponInterface; use Thelia\Model\Coupon; From 19aa1c798d6ddab89d41a92990b72a67a6d33196 Mon Sep 17 00:00:00 2001 From: gmorel Date: Sun, 24 Nov 2013 22:27:26 +0100 Subject: [PATCH 18/23] Coupon : Fix namespace issues --- core/lib/Thelia/Action/Coupon.php | 2 +- .../Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php | 2 +- install/faker_add_ecotax.php | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/core/lib/Thelia/Action/Coupon.php b/core/lib/Thelia/Action/Coupon.php index b68b27572..1b77eb488 100755 --- a/core/lib/Thelia/Action/Coupon.php +++ b/core/lib/Thelia/Action/Coupon.php @@ -25,7 +25,7 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Condition\ConditionFactory; -use Thelia\Condition\ConditionInterface; +use Thelia\Condition\Implementation\ConditionInterface; use Thelia\Core\Event\Coupon\CouponConsumeEvent; use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent; use Thelia\Core\Event\TheliaEvents; diff --git a/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php b/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php index 374643fda..19edf4e45 100644 --- a/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php @@ -23,7 +23,7 @@ namespace Thelia\Core\Event\Coupon; use Thelia\Core\Event\ActionEvent; -use Thelia\Coupon\ConditionCollection; +use Thelia\Condition\ConditionCollection; use Thelia\Model\Coupon; /** diff --git a/install/faker_add_ecotax.php b/install/faker_add_ecotax.php index 0bb6838d9..e158fcbfc 100755 --- a/install/faker_add_ecotax.php +++ b/install/faker_add_ecotax.php @@ -1,12 +1,8 @@ Date: Mon, 25 Nov 2013 21:35:35 +0100 Subject: [PATCH 19/23] Coupon : Add unit test for coupon removing X Amount & X Percent --- .../Coupon/Type/RemoveXAmountManagerTest.php | 181 ++++++++++++++---- .../Coupon/Type/RemoveXPercentManagerTest.php | 143 ++++++++++++-- 2 files changed, 271 insertions(+), 53 deletions(-) diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountManagerTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountManagerTest.php index c15fa7379..bd63265e0 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountManagerTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountManagerTest.php @@ -22,6 +22,12 @@ /**********************************************************************************/ namespace Thelia\Coupon\Type; +use Thelia\Condition\ConditionCollection; +use Thelia\Condition\ConditionEvaluator; +use Thelia\Condition\Implementation\MatchForTotalAmount; +use Thelia\Condition\Operators; +use Thelia\Coupon\FacadeInterface; +use Thelia\Model\CurrencyQuery; /** * Created by JetBrains PhpStorm. @@ -46,6 +52,145 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase { } + /** + * Generate adapter stub + * + * @param int $cartTotalPrice Cart total price + * @param string $checkoutCurrency Checkout currency + * @param string $i18nOutput Output from each translation + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ + public function generateFacadeStub($cartTotalPrice = 400, $checkoutCurrency = 'EUR', $i18nOutput = '') + { + $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade') + ->disableOriginalConstructor() + ->getMock(); + + $currencies = CurrencyQuery::create(); + $currencies = $currencies->find(); + $stubFacade->expects($this->any()) + ->method('getAvailableCurrencies') + ->will($this->returnValue($currencies)); + + $stubFacade->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue($cartTotalPrice)); + + $stubFacade->expects($this->any()) + ->method('getCheckoutCurrency') + ->will($this->returnValue($checkoutCurrency)); + + $stubFacade->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator') + ->disableOriginalConstructor() + ->getMock(); + $stubTranslator->expects($this->any()) + ->method('trans') + ->will($this->returnValue($i18nOutput)); + + $stubFacade->expects($this->any()) + ->method('getTranslator') + ->will($this->returnValue($stubTranslator)); + + return $stubFacade; + } + + /** + * @covers Thelia\Coupon\Type\RemoveXAmount::set + */ + public function testSet() + { + $stubFacade = $this->generateFacadeStub(); + + $coupon = new RemoveXAmount($stubFacade); + $date = new \DateTime(); + $description = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras at luctus tellus. Integer turpis mauris, aliquet vitae risus tristique, pellentesque vestibulum urna. Vestibulum sodales laoreet lectus dictum suscipit. Praesent vulputate, sem id varius condimentum, quam magna tempor elit, quis venenatis ligula nulla eget libero. Cras egestas euismod tellus, id pharetra leo suscipit quis. Donec lacinia ac lacus et ultricies. Nunc in porttitor neque. Proin at quam congue, consectetur orci sed, congue nulla. Nulla eleifend nunc ligula, nec pharetra elit tempus quis. Vivamus vel mauris sed est dictum blandit. Maecenas blandit dapibus velit ut sollicitudin. In in euismod mauris, consequat viverra magna. Cras velit velit, sollicitudin commodo tortor gravida, tempus varius nulla. + + Donec rhoncus leo mauris, id porttitor ante luctus tempus. Curabitur quis augue feugiat, ullamcorper mauris ac, interdum mi. Quisque aliquam lorem vitae felis lobortis, id interdum turpis mattis. Vestibulum diam massa, ornare congue blandit quis, facilisis at nisl. In tortor metus, venenatis non arcu nec, sollicitudin ornare nisl. Nunc erat risus, varius nec urna at, iaculis lacinia elit. Aenean ut felis tempus, tincidunt odio non, sagittis nisl. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec vitae hendrerit elit. Nunc sit amet gravida risus, euismod lobortis massa. Nam a erat mauris. Nam a malesuada lorem. Nulla id accumsan dolor, sed rhoncus tellus. Quisque dictum felis sed leo auctor, at volutpat lectus viverra. Morbi rutrum, est ac aliquam imperdiet, nibh sem sagittis justo, ac mattis magna lacus eu nulla. + + Duis interdum lectus nulla, nec pellentesque sapien condimentum at. Suspendisse potenti. Sed eu purus tellus. Nunc quis rhoncus metus. Fusce vitae tellus enim. Interdum et malesuada fames ac ante ipsum primis in faucibus. Etiam tempor porttitor erat vitae iaculis. Sed est elit, consequat non ornare vitae, vehicula eget lectus. Etiam consequat sapien mauris, eget consectetur magna imperdiet eget. Nunc sollicitudin luctus velit, in commodo nulla adipiscing fermentum. Fusce nisi sapien, posuere vitae metus sit amet, facilisis sollicitudin dui. Fusce ultricies auctor enim sit amet iaculis. Morbi at vestibulum enim, eget adipiscing eros. + + Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentesque elit erat, lacinia sed semper ac, sagittis vel elit. Nam eu convallis est. Curabitur rhoncus odio vitae consectetur pellentesque. Nam vitae arcu nec ante scelerisque dignissim vel nec neque. Suspendisse augue nulla, mollis eget dui et, tempor facilisis erat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac diam ipsum. Donec convallis dui ultricies velit auctor, non lobortis nulla ultrices. Morbi vitae dignissim ante, sit amet lobortis tortor. Nunc dapibus condimentum augue, in molestie neque congue non. + + Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.'; + + $coupon->set($stubFacade, 'XMAS', 'XMAS Coupon', 'Coupon for Springbreak removing 10€ if you have a cart between 40.00€ and 400.00€ (excluded)', $description, 10.00, true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) ); + + $condition1 = new MatchForTotalAmount($stubFacade); + $operators = array( + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmount::INPUT1 => 40.00, + MatchForTotalAmount::INPUT2 => 'EUR' + ); + $condition1->setValidatorsFromForm($operators, $values); + + $condition2 = new MatchForTotalAmount($stubFacade); + $operators = array( + MatchForTotalAmount::INPUT1 => Operators::INFERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR' + ); + $condition2->setValidatorsFromForm($operators, $values); + + $conditions = new ConditionCollection(); + $conditions->add($condition1); + $conditions->add($condition2); + $coupon->setConditions($conditions); + + $this->assertEquals('XMAS', $coupon->getCode()); + $this->assertEquals('XMAS Coupon', $coupon->getTitle()); + $this->assertEquals('Coupon for Springbreak removing 10€ if you have a cart between 40.00€ and 400.00€ (excluded)', $coupon->getShortDescription()); + $this->assertEquals($description, $coupon->getDescription()); + $this->assertEquals(true, $coupon->isCumulative()); + $this->assertEquals(true, $coupon->isRemovingPostage()); + $this->assertEquals(true, $coupon->isAvailableOnSpecialOffers()); + $this->assertEquals(true, $coupon->isEnabled()); + + $this->assertEquals(254, $coupon->getMaxUsage()); + $this->assertEquals($date, $coupon->getExpirationDate()); + } + + /** + * @covers Thelia\Coupon\Type\RemoveXAmount::getName + */ + public function testGetName() + { + $stubFacade = $this->generateFacadeStub(399, 'EUR', 'Remove X amount to total cart'); + + /** @var FacadeInterface $stubFacade */ + $coupon = new RemoveXAmount($stubFacade); + + $actual = $coupon->getName(); + $expected = 'Remove X amount to total cart'; + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Coupon\Type\RemoveXAmount::getToolTip + */ + public function testGetToolTip() + { + $tooltip = 'This coupon will remove the entered amount to the customer total checkout. If the discount is superior to the total checkout price the customer will only pay the postage. Unless if the coupon is set to remove postage too.'; + $stubFacade = $this->generateFacadeStub(399, 'EUR', $tooltip); + + /** @var FacadeInterface $stubFacade */ + $coupon = new RemoveXAmount($stubFacade); + + $actual = $coupon->getToolTip(); + $expected = $tooltip; + $this->assertEquals($expected, $actual); + } + /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. @@ -53,40 +198,4 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase protected function tearDown() { } - - /** - * @covers Thelia\Coupon\Type\RemoveXAmount::set - * @todo Implement testSet(). - */ - public function testSet() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Thelia\Coupon\Type\RemoveXAmount::getName - * @todo Implement testGetName(). - */ - public function testGetName() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Thelia\Coupon\Type\RemoveXAmount::getToolTip - * @todo Implement testGetToolTip(). - */ - public function testGetToolTip() - { - // 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/Type/RemoveXPercentManagerTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentManagerTest.php index fad80a389..7b8e6db91 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentManagerTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentManagerTest.php @@ -22,6 +22,12 @@ /**********************************************************************************/ namespace Thelia\Coupon\Type; +use Thelia\Condition\ConditionCollection; +use Thelia\Condition\ConditionEvaluator; +use Thelia\Condition\Implementation\MatchForTotalAmount; +use Thelia\Condition\Operators; +use Thelia\Coupon\FacadeInterface; +use Thelia\Model\CurrencyQuery; /** * Created by JetBrains PhpStorm. @@ -47,23 +53,111 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase } /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. + * Generate adapter stub + * + * @param int $cartTotalPrice Cart total price + * @param string $checkoutCurrency Checkout currency + * @param string $i18nOutput Output from each translation + * + * @return \PHPUnit_Framework_MockObject_MockObject */ - protected function tearDown() + public function generateFacadeStub($cartTotalPrice = 400, $checkoutCurrency = 'EUR', $i18nOutput = '') { + $stubFacade = $this->getMockBuilder('\Thelia\Coupon\BaseFacade') + ->disableOriginalConstructor() + ->getMock(); + + $currencies = CurrencyQuery::create(); + $currencies = $currencies->find(); + $stubFacade->expects($this->any()) + ->method('getAvailableCurrencies') + ->will($this->returnValue($currencies)); + + $stubFacade->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue($cartTotalPrice)); + + $stubFacade->expects($this->any()) + ->method('getCheckoutCurrency') + ->will($this->returnValue($checkoutCurrency)); + + $stubFacade->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator') + ->disableOriginalConstructor() + ->getMock(); + $stubTranslator->expects($this->any()) + ->method('trans') + ->will($this->returnValue($i18nOutput)); + + $stubFacade->expects($this->any()) + ->method('getTranslator') + ->will($this->returnValue($stubTranslator)); + + return $stubFacade; } /** * @covers Thelia\Coupon\Type\RemoveXPercent::set - * @todo Implement testSet(). */ public function testSet() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' + $stubFacade = $this->generateFacadeStub(); + + $coupon = new RemoveXPercent($stubFacade); + $date = new \DateTime(); + $description = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras at luctus tellus. Integer turpis mauris, aliquet vitae risus tristique, pellentesque vestibulum urna. Vestibulum sodales laoreet lectus dictum suscipit. Praesent vulputate, sem id varius condimentum, quam magna tempor elit, quis venenatis ligula nulla eget libero. Cras egestas euismod tellus, id pharetra leo suscipit quis. Donec lacinia ac lacus et ultricies. Nunc in porttitor neque. Proin at quam congue, consectetur orci sed, congue nulla. Nulla eleifend nunc ligula, nec pharetra elit tempus quis. Vivamus vel mauris sed est dictum blandit. Maecenas blandit dapibus velit ut sollicitudin. In in euismod mauris, consequat viverra magna. Cras velit velit, sollicitudin commodo tortor gravida, tempus varius nulla. + + Donec rhoncus leo mauris, id porttitor ante luctus tempus. Curabitur quis augue feugiat, ullamcorper mauris ac, interdum mi. Quisque aliquam lorem vitae felis lobortis, id interdum turpis mattis. Vestibulum diam massa, ornare congue blandit quis, facilisis at nisl. In tortor metus, venenatis non arcu nec, sollicitudin ornare nisl. Nunc erat risus, varius nec urna at, iaculis lacinia elit. Aenean ut felis tempus, tincidunt odio non, sagittis nisl. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec vitae hendrerit elit. Nunc sit amet gravida risus, euismod lobortis massa. Nam a erat mauris. Nam a malesuada lorem. Nulla id accumsan dolor, sed rhoncus tellus. Quisque dictum felis sed leo auctor, at volutpat lectus viverra. Morbi rutrum, est ac aliquam imperdiet, nibh sem sagittis justo, ac mattis magna lacus eu nulla. + + Duis interdum lectus nulla, nec pellentesque sapien condimentum at. Suspendisse potenti. Sed eu purus tellus. Nunc quis rhoncus metus. Fusce vitae tellus enim. Interdum et malesuada fames ac ante ipsum primis in faucibus. Etiam tempor porttitor erat vitae iaculis. Sed est elit, consequat non ornare vitae, vehicula eget lectus. Etiam consequat sapien mauris, eget consectetur magna imperdiet eget. Nunc sollicitudin luctus velit, in commodo nulla adipiscing fermentum. Fusce nisi sapien, posuere vitae metus sit amet, facilisis sollicitudin dui. Fusce ultricies auctor enim sit amet iaculis. Morbi at vestibulum enim, eget adipiscing eros. + + Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentesque elit erat, lacinia sed semper ac, sagittis vel elit. Nam eu convallis est. Curabitur rhoncus odio vitae consectetur pellentesque. Nam vitae arcu nec ante scelerisque dignissim vel nec neque. Suspendisse augue nulla, mollis eget dui et, tempor facilisis erat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac diam ipsum. Donec convallis dui ultricies velit auctor, non lobortis nulla ultrices. Morbi vitae dignissim ante, sit amet lobortis tortor. Nunc dapibus condimentum augue, in molestie neque congue non. + + Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.'; + + $coupon->set($stubFacade, 'XMAS', 'XMAS Coupon', 'Coupon for Springbreak removing 10% if you have a cart between 40.00€ and 400.00€ (excluded)', $description, 10.00, true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) ); + + $condition1 = new MatchForTotalAmount($stubFacade); + $operators = array( + MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL ); + $values = array( + MatchForTotalAmount::INPUT1 => 40.00, + MatchForTotalAmount::INPUT2 => 'EUR' + ); + $condition1->setValidatorsFromForm($operators, $values); + + $condition2 = new MatchForTotalAmount($stubFacade); + $operators = array( + MatchForTotalAmount::INPUT1 => Operators::INFERIOR, + MatchForTotalAmount::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmount::INPUT1 => 400.00, + MatchForTotalAmount::INPUT2 => 'EUR' + ); + $condition2->setValidatorsFromForm($operators, $values); + + $conditions = new ConditionCollection(); + $conditions->add($condition1); + $conditions->add($condition2); + $coupon->setConditions($conditions); + + $this->assertEquals('XMAS', $coupon->getCode()); + $this->assertEquals('XMAS Coupon', $coupon->getTitle()); + $this->assertEquals('Coupon for Springbreak removing 10% if you have a cart between 40.00€ and 400.00€ (excluded)', $coupon->getShortDescription()); + $this->assertEquals($description, $coupon->getDescription()); + $this->assertEquals(true, $coupon->isCumulative()); + $this->assertEquals(true, $coupon->isRemovingPostage()); + $this->assertEquals(true, $coupon->isAvailableOnSpecialOffers()); + $this->assertEquals(true, $coupon->isEnabled()); + + $this->assertEquals(254, $coupon->getMaxUsage()); + $this->assertEquals($date, $coupon->getExpirationDate()); } /** @@ -80,25 +174,40 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase /** * @covers Thelia\Coupon\Type\RemoveXPercent::getName - * @todo Implement testGetName(). */ public function testGetName() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $stubFacade = $this->generateFacadeStub(399, 'EUR', 'Remove X percent to total cart'); + + /** @var FacadeInterface $stubFacade */ + $coupon = new RemoveXPercent($stubFacade); + + $actual = $coupon->getName(); + $expected = 'Remove X percent to total cart'; + $this->assertEquals($expected, $actual); } /** * @covers Thelia\Coupon\Type\RemoveXPercent::getToolTip - * @todo Implement testGetToolTip(). */ public function testGetToolTip() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $tooltip = 'This coupon will remove the entered percentage to the customer total checkout. If the discount is superior to the total checkout price the customer will only pay the postage. Unless if the coupon is set to remove postage too.'; + $stubFacade = $this->generateFacadeStub(399, 'EUR', $tooltip); + + /** @var FacadeInterface $stubFacade */ + $coupon = new RemoveXPercent($stubFacade); + + $actual = $coupon->getToolTip(); + $expected = $tooltip; + $this->assertEquals($expected, $actual); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { } } From 2a926e52114bf717dbf2ad19c314703cdfd743f0 Mon Sep 17 00:00:00 2001 From: gmorel Date: Mon, 25 Nov 2013 22:09:40 +0100 Subject: [PATCH 20/23] Coupon : Add unit test for coupon removing X Amount & X Percent --- ...eryoneManagerTest.php => MatchForEveryoneTest.php} | 0 ...untManagerTest.php => MatchForTotalAmountTest.php} | 0 ...iclesManagerTest.php => MatchForXArticlesTest.php} | 0 ...veXAmountManagerTest.php => RemoveXAmountTest.php} | 11 +++++++++++ ...XPercentManagerTest.php => RemoveXPercentTest.php} | 0 5 files changed, 11 insertions(+) rename core/lib/Thelia/Tests/Condition/Implementation/{MatchForEveryoneManagerTest.php => MatchForEveryoneTest.php} (100%) rename core/lib/Thelia/Tests/Condition/Implementation/{MatchForTotalAmountManagerTest.php => MatchForTotalAmountTest.php} (100%) rename core/lib/Thelia/Tests/Condition/Implementation/{MatchForXArticlesManagerTest.php => MatchForXArticlesTest.php} (100%) rename core/lib/Thelia/Tests/Coupon/Type/{RemoveXAmountManagerTest.php => RemoveXAmountTest.php} (94%) rename core/lib/Thelia/Tests/Coupon/Type/{RemoveXPercentManagerTest.php => RemoveXPercentTest.php} (100%) diff --git a/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneManagerTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneTest.php similarity index 100% rename from core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneManagerTest.php rename to core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneTest.php diff --git a/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountManagerTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountTest.php similarity index 100% rename from core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountManagerTest.php rename to core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountTest.php diff --git a/core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesManagerTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesTest.php similarity index 100% rename from core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesManagerTest.php rename to core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesTest.php diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountManagerTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php similarity index 94% rename from core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountManagerTest.php rename to core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php index bd63265e0..41aad15ff 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountManagerTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php @@ -101,6 +101,17 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase /** * @covers Thelia\Coupon\Type\RemoveXAmount::set + * @covers Thelia\Coupon\Type\CouponAbstract::getCode + * @covers Thelia\Coupon\Type\CouponAbstract::getTitle + * @covers Thelia\Coupon\Type\CouponAbstract::getShortDescription + * @covers Thelia\Coupon\Type\CouponAbstract::getDescription + * @covers Thelia\Coupon\Type\CouponAbstract::isCumulative + * @covers Thelia\Coupon\Type\CouponAbstract::isRemovingPostage + * @covers Thelia\Coupon\Type\CouponAbstract::isAvailableOnSpecialOffers + * @covers Thelia\Coupon\Type\CouponAbstract::isEnabled + * @covers Thelia\Coupon\Type\CouponAbstract::getMaxUsage + * @covers Thelia\Coupon\Type\CouponAbstract::getExpirationDate + * @covers Thelia\Coupon\Type\CouponAbstract::setConditions */ public function testSet() { diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentManagerTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php similarity index 100% rename from core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentManagerTest.php rename to core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php From e2db36e23b57d35f789371ded7402f691fcc4f43 Mon Sep 17 00:00:00 2001 From: gmorel Date: Mon, 25 Nov 2013 22:42:16 +0100 Subject: [PATCH 21/23] Coupon : Add unit test for coupon removing X Amount & X Percent --- .../Tests/Coupon/Type/RemoveXAmountTest.php | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php index 41aad15ff..ce298c97a 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php @@ -102,16 +102,16 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase /** * @covers Thelia\Coupon\Type\RemoveXAmount::set * @covers Thelia\Coupon\Type\CouponAbstract::getCode - * @covers Thelia\Coupon\Type\CouponAbstract::getTitle - * @covers Thelia\Coupon\Type\CouponAbstract::getShortDescription - * @covers Thelia\Coupon\Type\CouponAbstract::getDescription - * @covers Thelia\Coupon\Type\CouponAbstract::isCumulative - * @covers Thelia\Coupon\Type\CouponAbstract::isRemovingPostage - * @covers Thelia\Coupon\Type\CouponAbstract::isAvailableOnSpecialOffers - * @covers Thelia\Coupon\Type\CouponAbstract::isEnabled - * @covers Thelia\Coupon\Type\CouponAbstract::getMaxUsage - * @covers Thelia\Coupon\Type\CouponAbstract::getExpirationDate - * @covers Thelia\Coupon\Type\CouponAbstract::setConditions + * @covers Thelia\Coupon\Type\RemoveXAmount::getTitle + * @covers Thelia\Coupon\Type\RemoveXAmount::getShortDescription + * @covers Thelia\Coupon\Type\RemoveXAmount::getDescription + * @covers Thelia\Coupon\Type\RemoveXAmount::isCumulative + * @covers Thelia\Coupon\Type\RemoveXAmount::isRemovingPostage + * @covers Thelia\Coupon\Type\RemoveXAmount::isAvailableOnSpecialOffers + * @covers Thelia\Coupon\Type\RemoveXAmount::isEnabled + * @covers Thelia\Coupon\Type\RemoveXAmount::getMaxUsage + * @covers Thelia\Coupon\Type\RemoveXAmount::getExpirationDate + * @covers Thelia\Coupon\Type\RemoveXAmount::setConditions */ public function testSet() { From d0ccfc732af22eea0d9436fe3ab61d90c3e1fb67 Mon Sep 17 00:00:00 2001 From: gmorel Date: Mon, 25 Nov 2013 22:58:19 +0100 Subject: [PATCH 22/23] Coupon : Add unit test for coupon removing X Amount & X Percent --- .../Condition/ConditionOrganizerTest.php | 53 ------------------- .../MatchForTotalAmountTest.php | 6 +-- .../Tests/Coupon/Type/RemoveXAmountTest.php | 2 + .../Tests/Coupon/Type/RemoveXPercentTest.php | 13 +---- 4 files changed, 7 insertions(+), 67 deletions(-) delete mode 100644 core/lib/Thelia/Tests/Condition/ConditionOrganizerTest.php diff --git a/core/lib/Thelia/Tests/Condition/ConditionOrganizerTest.php b/core/lib/Thelia/Tests/Condition/ConditionOrganizerTest.php deleted file mode 100644 index 0591df0ab..000000000 --- a/core/lib/Thelia/Tests/Condition/ConditionOrganizerTest.php +++ /dev/null @@ -1,53 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Coupon; -use Thelia\Condition\ConditionOrganizer; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Unit Test ConditionOrganizer Class - * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-11-17 at 18:59:24. - * - * @package Condition - * @author Guillaume MOREL - * - */ -class ConditionOrganizerTest extends \PHPUnit_Framework_TestCase -{ - - /** - * @covers Thelia\Coupon\RuleOrganizer::organize - * @todo Implement testOrganize(). - */ - public function testOrganize() - { - // 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/Condition/Implementation/MatchForTotalAmountTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountTest.php index 0390536c5..d28bf198d 100644 --- a/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountTest.php +++ b/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountTest.php @@ -605,7 +605,7 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase /** * Check unknown currency * - * @covers Thelia\Condition\ConditionAbstract::isCurrencyValid + * @covers Thelia\Condition\Implementation\ConditionAbstract::isCurrencyValid * @expectedException \Thelia\Exception\InvalidConditionValueException * */ @@ -672,7 +672,7 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase /** * Check invalid currency * - * @covers Thelia\Condition\ConditionAbstract::isPriceValid + * @covers Thelia\Condition\Implementation\ConditionAbstract::isPriceValid * @expectedException \Thelia\Exception\InvalidConditionValueException * */ @@ -739,7 +739,7 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase /** * Check invalid currency * - * @covers Thelia\Condition\ConditionAbstract::isPriceValid + * @covers Thelia\Condition\Implementation\ConditionAbstract::isPriceValid * @expectedException \Thelia\Exception\InvalidConditionValueException * */ diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php index ce298c97a..41971d4a6 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php @@ -169,6 +169,8 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase $this->assertEquals(254, $coupon->getMaxUsage()); $this->assertEquals($date, $coupon->getExpirationDate()); + + $this->assertEquals(10.00, $coupon->exec()); } /** diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php index 7b8e6db91..475e46aba 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php @@ -101,6 +101,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase /** * @covers Thelia\Coupon\Type\RemoveXPercent::set + * @covers Thelia\Coupon\Type\RemoveXPercent::exec */ public function testSet() { @@ -158,18 +159,8 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase $this->assertEquals(254, $coupon->getMaxUsage()); $this->assertEquals($date, $coupon->getExpirationDate()); - } - /** - * @covers Thelia\Coupon\Type\RemoveXPercent::exec - * @todo Implement testExec(). - */ - public function testExec() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->assertEquals(40.00, $coupon->exec()); } /** From ef818c19ce6d992648dc7b3860fe1ae09c4c04ef Mon Sep 17 00:00:00 2001 From: gmorel Date: Mon, 25 Nov 2013 23:04:29 +0100 Subject: [PATCH 23/23] Coupon : Add unit test for coupon removing X Amount & X Percent --- .../Tests/Coupon/Type/CouponAbstractTest.php | 260 ------------------ 1 file changed, 260 deletions(-) delete mode 100644 core/lib/Thelia/Tests/Coupon/Type/CouponAbstractTest.php diff --git a/core/lib/Thelia/Tests/Coupon/Type/CouponAbstractTest.php b/core/lib/Thelia/Tests/Coupon/Type/CouponAbstractTest.php deleted file mode 100644 index 184f1ef29..000000000 --- a/core/lib/Thelia/Tests/Coupon/Type/CouponAbstractTest.php +++ /dev/null @@ -1,260 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Coupon\Type; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Unit Test CouponAbstract Class - * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-11-17 at 18:59:24. - * - * @package Coupon - * @author Guillaume MOREL - * - */ -class CouponAbstractTest extends \PHPUnit_Framework_TestCase -{ - - /** - * Sets up the fixture, for example, opens a network connection. - * This method is called before a test is executed. - */ - protected function setUp() - { - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - } - - /** - * @covers Thelia\Coupon\Type\CouponAbstract::setOrganizer - * @todo Implement testSetOrganizer(). - */ - public function testSetOrganizer() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Thelia\Coupon\Type\CouponAbstract::getCode - * @todo Implement testGetCode(). - */ - public function testGetCode() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Thelia\Coupon\Type\CouponAbstract::getTitle - * @todo Implement testGetTitle(). - */ - public function testGetTitle() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Thelia\Coupon\Type\CouponAbstract::getShortDescription - * @todo Implement testGetShortDescription(). - */ - public function testGetShortDescription() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Thelia\Coupon\Type\CouponAbstract::getDescription - * @todo Implement testGetDescription(). - */ - public function testGetDescription() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Thelia\Coupon\Type\CouponAbstract::isCumulative - * @todo Implement testIsCumulative(). - */ - public function testIsCumulative() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Thelia\Coupon\Type\CouponAbstract::isRemovingPostage - * @todo Implement testIsRemovingPostage(). - */ - public function testIsRemovingPostage() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Thelia\Coupon\Type\CouponAbstract::exec - * @todo Implement testExec(). - */ - public function testExec() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Thelia\Coupon\Type\CouponAbstract::getConditions - * @todo Implement testGetConditions(). - */ - public function testGetConditions() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Thelia\Coupon\Type\CouponAbstract::setConditions - * @todo Implement testSetConditions(). - */ - public function testSetConditions() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Thelia\Coupon\Type\CouponAbstract::getExpirationDate - * @todo Implement testGetExpirationDate(). - */ - public function testGetExpirationDate() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Thelia\Coupon\Type\CouponAbstract::isAvailableOnSpecialOffers - * @todo Implement testIsAvailableOnSpecialOffers(). - */ - public function testIsAvailableOnSpecialOffers() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Thelia\Coupon\Type\CouponAbstract::isEnabled - * @todo Implement testIsEnabled(). - */ - public function testIsEnabled() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Thelia\Coupon\Type\CouponAbstract::getMaxUsage - * @todo Implement testGetMaxUsage(). - */ - public function testGetMaxUsage() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Thelia\Coupon\Type\CouponAbstract::isExpired - * @todo Implement testIsExpired(). - */ - public function testIsExpired() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Thelia\Coupon\Type\CouponAbstract::getServiceId - * @todo Implement testGetServiceId(). - */ - public function testGetServiceId() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Thelia\Coupon\Type\CouponAbstract::isMatching - * @todo Implement testIsMatching(). - */ - public function testIsMatching() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } -}