Merge branch 'master' of github.com:thelia/thelia

This commit is contained in:
Manuel Raynaud
2013-09-16 11:47:19 +02:00
6 changed files with 104 additions and 4 deletions

View File

@@ -69,10 +69,10 @@ class ConstraintValidator
/** /**
* Do variable comparison * Do variable comparison
* *
* @param mixed $v1 Variable 1 * @param mixed $v1 Variable 1
* @param string $o Operator * @param string $o Operator
* @param mixed $v2 Variable 2
* *
* @param mixed $v2 Variable 2
* @throws \Exception * @throws \Exception
* @return bool * @return bool
*/ */

View File

@@ -24,6 +24,7 @@
namespace Thelia\Constraint\Rule; namespace Thelia\Constraint\Rule;
use Symfony\Component\Intl\Exception\NotImplementedException; use Symfony\Component\Intl\Exception\NotImplementedException;
use Thelia\Constraint\ConstraintValidator;
use Thelia\Core\Translation\Translator; use Thelia\Core\Translation\Translator;
use Thelia\Coupon\CouponAdapterInterface; use Thelia\Coupon\CouponAdapterInterface;
use Thelia\Constraint\Validator\ComparableInterface; use Thelia\Constraint\Validator\ComparableInterface;
@@ -73,6 +74,9 @@ abstract class CouponRuleAbstract implements CouponRuleInterface
/** @var array Values set by Admin in BackOffice */ /** @var array Values set by Admin in BackOffice */
protected $values = array(); protected $values = array();
/** @var ConstraintValidator Constaints validator */
protected $constraintValidator = null;
/** /**
* Constructor * Constructor
* *

View File

@@ -65,6 +65,9 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getCheckoutCurrency') ->method('getCheckoutCurrency')
->will($this->returnValue('EUR')); ->will($this->returnValue('EUR'));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue($ConstraintValidator));
$rule1 = new AvailableForTotalAmountManager($stubAdapter); $rule1 = new AvailableForTotalAmountManager($stubAdapter);
$operators = array( $operators = array(
@@ -99,6 +102,9 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getCheckoutCurrency') ->method('getCheckoutCurrency')
->will($this->returnValue('EUR')); ->will($this->returnValue('EUR'));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue($ConstraintValidator));
$rule1 = new AvailableForTotalAmountManager($stubAdapter); $rule1 = new AvailableForTotalAmountManager($stubAdapter);
$operators = array( $operators = array(
@@ -136,6 +142,9 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getNbArticlesInCart') ->method('getNbArticlesInCart')
->will($this->returnValue(5)); ->will($this->returnValue(5));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue($ConstraintValidator));
$rule1 = new AvailableForTotalAmountManager($stubAdapter); $rule1 = new AvailableForTotalAmountManager($stubAdapter);
$operators = array( $operators = array(
@@ -183,6 +192,9 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getNbArticlesInCart') ->method('getNbArticlesInCart')
->will($this->returnValue(5)); ->will($this->returnValue(5));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue($ConstraintValidator));
$rule1 = new AvailableForTotalAmountManager($stubAdapter); $rule1 = new AvailableForTotalAmountManager($stubAdapter);
$operators = array( $operators = array(

View File

@@ -23,6 +23,7 @@
namespace Thelia\Coupon; namespace Thelia\Coupon;
use Thelia\Constraint\ConstraintValidator;
use Thelia\Constraint\Rule\AvailableForTotalAmountManager; use Thelia\Constraint\Rule\AvailableForTotalAmountManager;
use Thelia\Constraint\Rule\Operators; use Thelia\Constraint\Rule\Operators;
@@ -169,6 +170,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getCheckoutCurrency') ->method('getCheckoutCurrency')
->will($this->returnValue('EUR')); ->will($this->returnValue('EUR'));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForTotalAmountManager($stubAdapter); $rule1 = new AvailableForTotalAmountManager($stubAdapter);
$operators = array( $operators = array(
@@ -205,6 +209,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getCheckoutCurrency') ->method('getCheckoutCurrency')
->will($this->returnValue('EUR')); ->will($this->returnValue('EUR'));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForTotalAmountManager($stubAdapter); $rule1 = new AvailableForTotalAmountManager($stubAdapter);
$operators = array( $operators = array(
@@ -241,6 +248,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getCheckoutCurrency') ->method('getCheckoutCurrency')
->will($this->returnValue('EUR')); ->will($this->returnValue('EUR'));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForTotalAmountManager($stubAdapter); $rule1 = new AvailableForTotalAmountManager($stubAdapter);
$operators = array( $operators = array(
@@ -277,6 +287,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getCheckoutCurrency') ->method('getCheckoutCurrency')
->will($this->returnValue('EUR')); ->will($this->returnValue('EUR'));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForTotalAmountManager($stubAdapter); $rule1 = new AvailableForTotalAmountManager($stubAdapter);
$operators = array( $operators = array(
@@ -313,6 +326,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getCheckoutCurrency') ->method('getCheckoutCurrency')
->will($this->returnValue('EUR')); ->will($this->returnValue('EUR'));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForTotalAmountManager($stubAdapter); $rule1 = new AvailableForTotalAmountManager($stubAdapter);
$operators = array( $operators = array(
@@ -349,6 +365,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getCheckoutCurrency') ->method('getCheckoutCurrency')
->will($this->returnValue('EUR')); ->will($this->returnValue('EUR'));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForTotalAmountManager($stubAdapter); $rule1 = new AvailableForTotalAmountManager($stubAdapter);
$operators = array( $operators = array(
@@ -385,6 +404,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getCheckoutCurrency') ->method('getCheckoutCurrency')
->will($this->returnValue('EUR')); ->will($this->returnValue('EUR'));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForTotalAmountManager($stubAdapter); $rule1 = new AvailableForTotalAmountManager($stubAdapter);
$operators = array( $operators = array(
@@ -421,6 +443,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getCheckoutCurrency') ->method('getCheckoutCurrency')
->will($this->returnValue('EUR')); ->will($this->returnValue('EUR'));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForTotalAmountManager($stubAdapter); $rule1 = new AvailableForTotalAmountManager($stubAdapter);
$operators = array( $operators = array(
@@ -457,6 +482,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getCheckoutCurrency') ->method('getCheckoutCurrency')
->will($this->returnValue('EUR')); ->will($this->returnValue('EUR'));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForTotalAmountManager($stubAdapter); $rule1 = new AvailableForTotalAmountManager($stubAdapter);
$operators = array( $operators = array(
@@ -493,6 +521,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getCheckoutCurrency') ->method('getCheckoutCurrency')
->will($this->returnValue('EUR')); ->will($this->returnValue('EUR'));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForTotalAmountManager($stubAdapter); $rule1 = new AvailableForTotalAmountManager($stubAdapter);
$operators = array( $operators = array(
@@ -529,6 +560,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getCheckoutCurrency') ->method('getCheckoutCurrency')
->will($this->returnValue('EUR')); ->will($this->returnValue('EUR'));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForTotalAmountManager($stubAdapter); $rule1 = new AvailableForTotalAmountManager($stubAdapter);
$operators = array( $operators = array(
@@ -565,6 +599,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getCheckoutCurrency') ->method('getCheckoutCurrency')
->will($this->returnValue('EUR')); ->will($this->returnValue('EUR'));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForTotalAmountManager($stubAdapter); $rule1 = new AvailableForTotalAmountManager($stubAdapter);
$operators = array( $operators = array(
@@ -601,6 +638,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getCheckoutCurrency') ->method('getCheckoutCurrency')
->will($this->returnValue('EUR')); ->will($this->returnValue('EUR'));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForTotalAmountManager($stubAdapter); $rule1 = new AvailableForTotalAmountManager($stubAdapter);
$operators = array( $operators = array(
@@ -637,6 +677,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getCheckoutCurrency') ->method('getCheckoutCurrency')
->will($this->returnValue('EUR')); ->will($this->returnValue('EUR'));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForTotalAmountManager($stubAdapter); $rule1 = new AvailableForTotalAmountManager($stubAdapter);
$operators = array( $operators = array(

View File

@@ -23,6 +23,7 @@
namespace Thelia\Coupon; namespace Thelia\Coupon;
use Thelia\Constraint\ConstraintValidator;
use Thelia\Constraint\Rule\AvailableForXArticlesManager; use Thelia\Constraint\Rule\AvailableForXArticlesManager;
use Thelia\Constraint\Rule\Operators; use Thelia\Constraint\Rule\Operators;
use Thelia\Constraint\Rule\SerializableRule; use Thelia\Constraint\Rule\SerializableRule;
@@ -192,6 +193,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getNbArticlesInCart') ->method('getNbArticlesInCart')
->will($this->returnValue(4)); ->will($this->returnValue(4));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForXArticlesManager($stubAdapter); $rule1 = new AvailableForXArticlesManager($stubAdapter);
$operators = array( $operators = array(
@@ -224,6 +228,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getNbArticlesInCart') ->method('getNbArticlesInCart')
->will($this->returnValue(4)); ->will($this->returnValue(4));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForXArticlesManager($stubAdapter); $rule1 = new AvailableForXArticlesManager($stubAdapter);
$operators = array( $operators = array(
@@ -256,6 +263,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getNbArticlesInCart') ->method('getNbArticlesInCart')
->will($this->returnValue(4)); ->will($this->returnValue(4));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForXArticlesManager($stubAdapter); $rule1 = new AvailableForXArticlesManager($stubAdapter);
$operators = array( $operators = array(
@@ -288,6 +298,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getNbArticlesInCart') ->method('getNbArticlesInCart')
->will($this->returnValue(4)); ->will($this->returnValue(4));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForXArticlesManager($stubAdapter); $rule1 = new AvailableForXArticlesManager($stubAdapter);
$operators = array( $operators = array(
@@ -320,6 +333,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getNbArticlesInCart') ->method('getNbArticlesInCart')
->will($this->returnValue(4)); ->will($this->returnValue(4));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForXArticlesManager($stubAdapter); $rule1 = new AvailableForXArticlesManager($stubAdapter);
$operators = array( $operators = array(
@@ -352,6 +368,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getNbArticlesInCart') ->method('getNbArticlesInCart')
->will($this->returnValue(4)); ->will($this->returnValue(4));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForXArticlesManager($stubAdapter); $rule1 = new AvailableForXArticlesManager($stubAdapter);
$operators = array( $operators = array(
@@ -384,6 +403,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getNbArticlesInCart') ->method('getNbArticlesInCart')
->will($this->returnValue(4)); ->will($this->returnValue(4));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForXArticlesManager($stubAdapter); $rule1 = new AvailableForXArticlesManager($stubAdapter);
$operators = array( $operators = array(
@@ -416,6 +438,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getNbArticlesInCart') ->method('getNbArticlesInCart')
->will($this->returnValue(4)); ->will($this->returnValue(4));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForXArticlesManager($stubAdapter); $rule1 = new AvailableForXArticlesManager($stubAdapter);
$operators = array( $operators = array(
@@ -448,6 +473,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getNbArticlesInCart') ->method('getNbArticlesInCart')
->will($this->returnValue(4)); ->will($this->returnValue(4));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForXArticlesManager($stubAdapter); $rule1 = new AvailableForXArticlesManager($stubAdapter);
$operators = array( $operators = array(
@@ -480,6 +508,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getNbArticlesInCart') ->method('getNbArticlesInCart')
->will($this->returnValue(4)); ->will($this->returnValue(4));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForXArticlesManager($stubAdapter); $rule1 = new AvailableForXArticlesManager($stubAdapter);
$operators = array( $operators = array(
@@ -512,6 +543,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getNbArticlesInCart') ->method('getNbArticlesInCart')
->will($this->returnValue(4)); ->will($this->returnValue(4));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForXArticlesManager($stubAdapter); $rule1 = new AvailableForXArticlesManager($stubAdapter);
$operators = array( $operators = array(
@@ -544,6 +578,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getNbArticlesInCart') ->method('getNbArticlesInCart')
->will($this->returnValue(4)); ->will($this->returnValue(4));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForXArticlesManager($stubAdapter); $rule1 = new AvailableForXArticlesManager($stubAdapter);
$operators = array( $operators = array(
@@ -570,6 +607,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getNbArticlesInCart') ->method('getNbArticlesInCart')
->will($this->returnValue(4)); ->will($this->returnValue(4));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForXArticlesManager($stubAdapter); $rule1 = new AvailableForXArticlesManager($stubAdapter);
$operators = array( $operators = array(
@@ -602,6 +642,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
$stubAdapter->expects($this->any()) $stubAdapter->expects($this->any())
->method('getNbArticlesInCart') ->method('getNbArticlesInCart')
->will($this->returnValue(4)); ->will($this->returnValue(4));
$stubAdapter->expects($this->any())
->method('getConstraintValidator')
->will($this->returnValue(new ConstraintValidator()));
$rule1 = new AvailableForXArticlesManager($stubAdapter); $rule1 = new AvailableForXArticlesManager($stubAdapter);
$operators = array( $operators = array(

View File

@@ -1,7 +1,5 @@
<?php <?php
use Thelia\Constraint\ConstraintFactory; use Thelia\Constraint\ConstraintFactory;
use Thelia\Constraint\ConstraintManager;
use Thelia\Constraint\Rule\AvailableForTotalAmount;
use Thelia\Constraint\Rule\AvailableForTotalAmountManager; use Thelia\Constraint\Rule\AvailableForTotalAmountManager;
use Thelia\Constraint\Rule\AvailableForXArticlesManager; use Thelia\Constraint\Rule\AvailableForXArticlesManager;
use Thelia\Constraint\Rule\Operators; use Thelia\Constraint\Rule\Operators;