Coupon : rename
This commit is contained in:
@@ -103,7 +103,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
|||||||
$couponManager = $this->container->get('thelia.coupon.manager');
|
$couponManager = $this->container->get('thelia.coupon.manager');
|
||||||
|
|
||||||
/** @var CouponInterface $coupon */
|
/** @var CouponInterface $coupon */
|
||||||
$coupon = $couponFactory->buildCouponManagerFromCode($event->getCode());
|
$coupon = $couponFactory->buildCouponFromCode($event->getCode());
|
||||||
|
|
||||||
if ($coupon) {
|
if ($coupon) {
|
||||||
$isValid = $coupon->isMatching();
|
$isValid = $coupon->isMatching();
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class CouponFactory
|
|||||||
* @throws \Thelia\Exception\InvalidConditionException
|
* @throws \Thelia\Exception\InvalidConditionException
|
||||||
* @return CouponInterface ready to be processed
|
* @return CouponInterface ready to be processed
|
||||||
*/
|
*/
|
||||||
public function buildCouponManagerFromCode($couponCode)
|
public function buildCouponFromCode($couponCode)
|
||||||
{
|
{
|
||||||
/** @var Coupon $couponModel */
|
/** @var Coupon $couponModel */
|
||||||
$couponModel = $this->facade->findOneCouponByCode($couponCode);
|
$couponModel = $this->facade->findOneCouponByCode($couponCode);
|
||||||
@@ -83,7 +83,7 @@ class CouponFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @var CouponInterface $couponInterface */
|
/** @var CouponInterface $couponInterface */
|
||||||
$couponInterface = $this->buildCouponManagerFromModel($couponModel);
|
$couponInterface = $this->buildCouponFromModel($couponModel);
|
||||||
if ($couponInterface && $couponInterface->getConditions()->isEmpty()) {
|
if ($couponInterface && $couponInterface->getConditions()->isEmpty()) {
|
||||||
throw new InvalidConditionException(
|
throw new InvalidConditionException(
|
||||||
get_class($couponInterface)
|
get_class($couponInterface)
|
||||||
@@ -100,7 +100,7 @@ class CouponFactory
|
|||||||
*
|
*
|
||||||
* @return CouponInterface ready to use CouponInterface object instance
|
* @return CouponInterface ready to use CouponInterface object instance
|
||||||
*/
|
*/
|
||||||
protected function buildCouponManagerFromModel(Coupon $model)
|
protected function buildCouponFromModel(Coupon $model)
|
||||||
{
|
{
|
||||||
$isCumulative = ($model->getIsCumulative() == 1 ? true : false);
|
$isCumulative = ($model->getIsCumulative() == 1 ? true : false);
|
||||||
$isRemovingPostage = ($model->getIsRemovingPostage() == 1 ? true : false);
|
$isRemovingPostage = ($model->getIsRemovingPostage() == 1 ? true : false);
|
||||||
|
|||||||
@@ -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()
|
public function testBuildCouponFromCode()
|
||||||
{
|
{
|
||||||
@@ -234,13 +234,13 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
|
|||||||
|
|
||||||
$factory = new CouponFactory($stubContainer);
|
$factory = new CouponFactory($stubContainer);
|
||||||
$expected = $couponManager;
|
$expected = $couponManager;
|
||||||
$actual = $factory->buildCouponManagerFromCode('XMAS');
|
$actual = $factory->buildCouponFromCode('XMAS');
|
||||||
|
|
||||||
$this->assertEquals($expected, $actual);
|
$this->assertEquals($expected, $actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers Thelia\Coupon\CouponFactory::buildCouponManagerFromCode
|
* @covers Thelia\Coupon\CouponFactory::buildCouponFromCode
|
||||||
*/
|
*/
|
||||||
public function testBuildCouponFromCodeUnknownCode()
|
public function testBuildCouponFromCodeUnknownCode()
|
||||||
{
|
{
|
||||||
@@ -266,7 +266,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
|
|||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
$factory = new CouponFactory($stubContainer);
|
$factory = new CouponFactory($stubContainer);
|
||||||
$actual = $factory->buildCouponManagerFromCode('XMAS');
|
$actual = $factory->buildCouponFromCode('XMAS');
|
||||||
$expected = false;
|
$expected = false;
|
||||||
|
|
||||||
$this->assertEquals($expected, $actual);
|
$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
|
* @expectedException \Thelia\Exception\CouponExpiredException
|
||||||
*/
|
*/
|
||||||
public function testBuildCouponFromCodeExpiredCoupon()
|
public function testBuildCouponFromCodeExpiredCoupon()
|
||||||
@@ -336,12 +336,12 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
|
|||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
$factory = new CouponFactory($stubContainer);
|
$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
|
* @expectedException \Thelia\Exception\InvalidConditionException
|
||||||
*/
|
*/
|
||||||
public function testBuildCouponFromCodeNoConditionCoupon()
|
public function testBuildCouponFromCodeNoConditionCoupon()
|
||||||
@@ -400,7 +400,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
|
|||||||
|
|
||||||
$factory = new CouponFactory($stubContainer);
|
$factory = new CouponFactory($stubContainer);
|
||||||
$expected = $couponManager;
|
$expected = $couponManager;
|
||||||
$actual = $factory->buildCouponManagerFromCode('XMAS');
|
$actual = $factory->buildCouponFromCode('XMAS');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user