本文整理汇总了PHP中Rule::setAction方法的典型用法代码示例。如果您正苦于以下问题:PHP Rule::setAction方法的具体用法?PHP Rule::setAction怎么用?PHP Rule::setAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rule
的用法示例。
在下文中一共展示了Rule::setAction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: performActionAfterRule
/** @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);
}