Exemple #1
0
 public function testSettingRules()
 {
     $rule = new OrderTotalRule();
     $rule->initialize('>=', 80);
     $promotion = new Promotion('Name');
     $promotion->setRules(array($rule));
     $this->assertTrue($promotion->isEligible(new TestPromotionSubject()));
 }
Exemple #2
0
 public function testOrderTotal()
 {
     $rule = new OrderTotalRule();
     // Equal
     $rule->initialize('=', 100);
     $this->assertTrue($rule->isValid($this->getSubject()));
     $rule->val(20);
     $this->assertFalse($rule->isValid($this->getSubject()));
     // Greater than
     $rule->op('>')->val(80);
     $this->assertTrue($rule->isValid($this->getSubject()));
     $rule->val(100);
     $this->assertFalse($rule->isValid($this->getSubject()));
     // Lesser than
     $rule->op('<')->val(150);
     $this->assertTrue($rule->isValid($this->getSubject()));
     $rule->val(90);
     $this->assertFalse($rule->isValid($this->getSubject()));
 }