Example #1
0
 public function testExecute()
 {
     $action = $this->getMockBuilder('Oro\\Bundle\\WorkflowBundle\\Model\\Action\\ActionInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $action->expects($this->exactly(2))->method('execute')->with($this->testContext);
     $condition = $this->getMockBuilder('Oro\\Bundle\\WorkflowBundle\\Model\\Condition\\ConditionInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $condition->expects($this->never())->method('isAllowed');
     $this->assembler->expects($this->once())->method('assemble')->with($this->testConfiguration)->will($this->returnValue($action));
     $this->configurableAction->initialize($this->testConfiguration);
     $this->configurableAction->setCondition($condition);
     // run twice to test cached action
     $this->configurableAction->execute($this->testContext);
     $this->configurableAction->execute($this->testContext);
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function initialize(array $options)
 {
     if (empty($options[self::OPTION_KEY_ARRAY])) {
         throw new InvalidParameterException('Array parameter is required');
     } elseif (!is_array($options[self::OPTION_KEY_ARRAY]) && !$options[self::OPTION_KEY_ARRAY] instanceof PropertyPathInterface) {
         throw new InvalidParameterException('Array parameter must be either array or valid property definition');
     }
     if (!empty($options[self::OPTION_KEY_KEY]) && !$options[self::OPTION_KEY_KEY] instanceof PropertyPathInterface) {
         throw new InvalidParameterException('Key must be valid property definition');
     }
     if (empty($options[self::OPTION_KEY_VALUE])) {
         throw new InvalidParameterException('Value parameter is required');
     } elseif (!$options[self::OPTION_KEY_VALUE] instanceof PropertyPathInterface) {
         throw new InvalidParameterException('Value must be valid property definition');
     }
     if (empty($options[self::OPTION_KEY_ACTIONS])) {
         throw new InvalidParameterException('Actions parameter is required');
     } elseif (!is_array($options[self::OPTION_KEY_ACTIONS])) {
         throw new InvalidParameterException('Actions must be array');
     }
     $this->options = $options;
     $this->configurableAction->initialize($options[self::OPTION_KEY_ACTIONS]);
 }