Coupon : Fix unit test
This commit is contained in:
@@ -134,6 +134,22 @@ class Coupon extends BaseCoupon
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Coupon amount
|
||||
*
|
||||
* @param float $amount Amount deduced from the Cart
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAmount($amount)
|
||||
{
|
||||
$effects = $this->unserializeEffects($this->getSerializedEffects());
|
||||
$effects['amount'] = floatval($amount);
|
||||
$this->setEffects($effects);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount removed from the coupon to the cart
|
||||
*
|
||||
|
||||
@@ -50,7 +50,7 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Test vatiable comparison
|
||||
* Test variable comparison
|
||||
*
|
||||
* @covers Thelia\Condition\ConditionEvaluator::variableOpComparison
|
||||
*/
|
||||
@@ -91,7 +91,7 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Test vatiable comparison
|
||||
* Test variable comparison
|
||||
*
|
||||
* @covers Thelia\Condition\ConditionEvaluator::variableOpComparison
|
||||
*/
|
||||
@@ -126,7 +126,7 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Test vatiable comparison
|
||||
* Test variable comparison
|
||||
*
|
||||
* @expectedException \Exception
|
||||
* @covers Thelia\Condition\ConditionEvaluator::variableOpComparison
|
||||
@@ -164,8 +164,8 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
|
||||
$collection->add($stubConditionTrue1);
|
||||
$collection->add($stubConditionTrue2);
|
||||
|
||||
$conitionEvaluator = new ConditionEvaluator();
|
||||
$actual = $conitionEvaluator->isMatching($collection);
|
||||
$conditionEvaluator = new ConditionEvaluator();
|
||||
$actual = $conditionEvaluator->isMatching($collection);
|
||||
|
||||
$this->assertTrue($actual);
|
||||
}
|
||||
@@ -195,8 +195,8 @@ class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase
|
||||
$collection->add($stubConditionTrue);
|
||||
$collection->add($stubConditionFalse);
|
||||
|
||||
$conitionEvaluator = new ConditionEvaluator();
|
||||
$actual = $conitionEvaluator->isMatching($collection);
|
||||
$conditionEvaluator = new ConditionEvaluator();
|
||||
$actual = $conditionEvaluator->isMatching($collection);
|
||||
|
||||
$this->assertFalse($actual);
|
||||
}
|
||||
|
||||
@@ -666,7 +666,7 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$collection->add($condition1);
|
||||
|
||||
$serialized = $conditionFactory->serializeConditionCollection($collection);
|
||||
$unserialized = $conditionFactory->unserializeConditionCollection($serialized);
|
||||
$conditionFactory->unserializeConditionCollection($serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -733,7 +733,7 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$collection->add($condition1);
|
||||
|
||||
$serialized = $conditionFactory->serializeConditionCollection($collection);
|
||||
$unserialized = $conditionFactory->unserializeConditionCollection($serialized);
|
||||
$conditionFactory->unserializeConditionCollection($serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -800,7 +800,7 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$collection->add($condition1);
|
||||
|
||||
$serialized = $conditionFactory->serializeConditionCollection($collection);
|
||||
$unserialized = $conditionFactory->unserializeConditionCollection($serialized);
|
||||
$conditionFactory->unserializeConditionCollection($serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -248,7 +248,6 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
|
||||
|
||||
$stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container');
|
||||
|
||||
$conditionFactory = new ConditionFactory($stubContainer);
|
||||
$stubFacade->expects($this->any())
|
||||
->method('findOneCouponByCode')
|
||||
->will($this->returnValue(null));
|
||||
@@ -336,7 +335,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$factory = new CouponFactory($stubContainer);
|
||||
$actual = $factory->buildCouponFromCode('XMAS');
|
||||
$factory->buildCouponFromCode('XMAS');
|
||||
|
||||
}
|
||||
|
||||
@@ -399,7 +398,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$factory = new CouponFactory($stubContainer);
|
||||
$actual = $factory->buildCouponFromCode('XMAS');
|
||||
$factory->buildCouponFromCode('XMAS');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,7 +407,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
|
||||
|
||||
$coupon = new RemoveXAmount($stubFacade);
|
||||
$date = new \DateTime();
|
||||
$coupon->set($stubFacade, 'XMAS', '', '', '', 21.00, true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) );
|
||||
$coupon->set($stubFacade, 'XMAS', '', '', '', array('amount' => 21.00), true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) );
|
||||
|
||||
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||
$operators = array(
|
||||
@@ -474,7 +474,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
|
||||
|
||||
$coupon = new RemoveXAmount($stubFacade);
|
||||
$date = new \DateTime();
|
||||
$coupon->set($stubFacade, 'XMAS', '', '', '', 21.00, true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) );
|
||||
$coupon->set($stubFacade, 'XMAS', '', '', '', array('amount' => 21.00), true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) );
|
||||
|
||||
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||
$operators = array(
|
||||
|
||||
@@ -129,7 +129,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
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")) );
|
||||
$coupon->set($stubFacade, 'XMAS', 'XMAS Coupon', 'Coupon for Springbreak removing 10€ if you have a cart between 40.00€ and 400.00€ (excluded)', $description, array('amount' => 10.00), true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) );
|
||||
|
||||
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||
$operators = array(
|
||||
|
||||
@@ -119,7 +119,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
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")) );
|
||||
$coupon->set($stubFacade, 'XMAS', 'XMAS Coupon', 'Coupon for Springbreak removing 10% if you have a cart between 40.00€ and 400.00€ (excluded)', $description, array('amount' => 0.00, 'percentage' => 10.00), true, true, true, true, 254, $date->setTimestamp(strtotime("today + 3 months")) );
|
||||
|
||||
$condition1 = new MatchForTotalAmount($stubFacade);
|
||||
$operators = array(
|
||||
|
||||
Reference in New Issue
Block a user