コード例 #1
0
ファイル: RuleTest.php プロジェクト: superruzafa/rules
 /** @test */
 public function performActionAfterRule()
 {
     $context = new Context();
     $condition = $this->getMockForAbstractClass('Superruzafa\\Rules\\Expression', array('evaluate'));
     $condition->expects($this->once())->method('evaluate')->with($context)->will($this->returnValue(false));
     $subruleAction = $this->getMockForAbstractClass('Superruzafa\\Rules\\Action', array('perform'));
     $subruleAction->expects($this->never())->method('perform');
     $subrule = new Rule();
     $subrule->setAction($subruleAction);
     $action = $this->getMockForAbstractClass('Superruzafa\\Rules\\Action', array('perform'));
     $action->expects($this->once())->method('perform')->with($context)->will($this->returnCallback(function (Context $context) {
         \PHPUnit_Framework_Assert::assertFalse($context->offsetExists('after-subrules'));
     }));
     $rule = new Rule();
     $rule->setCondition($condition)->setAction($action, Rule::AFTER_RULE)->appendRule($subrule)->execute($context);
 }