Working : Coupon : Fix unit tests @todo refactor
This commit is contained in:
@@ -69,10 +69,10 @@ class ConstraintValidator
|
||||
/**
|
||||
* Do variable comparison
|
||||
*
|
||||
* @param mixed $v1 Variable 1
|
||||
* @param mixed $v1 Variable 1
|
||||
* @param string $o Operator
|
||||
* @param mixed $v2 Variable 2
|
||||
*
|
||||
* @param mixed $v2 Variable 2
|
||||
* @throws \Exception
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
namespace Thelia\Constraint\Rule;
|
||||
|
||||
use Symfony\Component\Intl\Exception\NotImplementedException;
|
||||
use Thelia\Constraint\ConstraintValidator;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Coupon\CouponAdapterInterface;
|
||||
use Thelia\Constraint\Validator\ComparableInterface;
|
||||
@@ -73,6 +74,9 @@ abstract class CouponRuleAbstract implements CouponRuleInterface
|
||||
/** @var array Values set by Admin in BackOffice */
|
||||
protected $values = array();
|
||||
|
||||
/** @var ConstraintValidator Constaints validator */
|
||||
protected $constraintValidator = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
||||
@@ -65,6 +65,9 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue($ConstraintValidator));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -99,6 +102,9 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue($ConstraintValidator));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -136,6 +142,9 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(5));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue($ConstraintValidator));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -183,6 +192,9 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(5));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue($ConstraintValidator));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace Thelia\Coupon;
|
||||
|
||||
use Thelia\Constraint\ConstraintValidator;
|
||||
use Thelia\Constraint\Rule\AvailableForTotalAmountManager;
|
||||
use Thelia\Constraint\Rule\Operators;
|
||||
|
||||
@@ -169,6 +170,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -205,6 +209,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -241,6 +248,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -277,6 +287,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -313,6 +326,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -349,6 +365,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -385,6 +404,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -421,6 +443,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -457,6 +482,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -493,6 +521,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -529,6 +560,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -565,6 +599,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -601,6 +638,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -637,6 +677,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace Thelia\Coupon;
|
||||
|
||||
use Thelia\Constraint\ConstraintValidator;
|
||||
use Thelia\Constraint\Rule\AvailableForXArticlesManager;
|
||||
use Thelia\Constraint\Rule\Operators;
|
||||
use Thelia\Constraint\Rule\SerializableRule;
|
||||
@@ -192,6 +193,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -224,6 +228,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -256,6 +263,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -288,6 +298,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -320,6 +333,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -352,6 +368,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -384,6 +403,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -416,6 +438,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -448,6 +473,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -480,6 +508,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -512,6 +543,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -544,6 +578,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -570,6 +607,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -602,6 +642,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
|
||||
Reference in New Issue
Block a user