Exemple #1
0
 /**
  * {@inheritDoc}
  */
 public function execute($context)
 {
     if (!$this->action) {
         $this->action = $this->assembler->assemble($this->configuration);
     }
     $this->action->execute($context);
 }
 public function testExecute()
 {
     $context = new \stdClass();
     $context->test = new \stdClass();
     $target = new PropertyPath('test');
     $em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $em->expects($this->once())->method('remove')->with($context->test);
     $this->registry->expects($this->once())->method('getManagerForClass')->with(get_class($context->test))->will($this->returnValue($em));
     $this->action->initialize([$target]);
     $this->action->execute($context);
 }
 public function testExecute()
 {
     $context = new \stdClass();
     $context->attr = new \stdClass();
     $context->integration = $this->getMockBuilder('Oro\\Bundle\\IntegrationBundle\\Entity\\Channel')->disableOriginalConstructor()->getMock();
     $this->defaultOwnerHelper->expects($this->once())->method('populateChannelOwner')->with($context->attr, $context->integration);
     $options = ['attribute' => new PropertyPath('attr'), 'integration' => new PropertyPath('integration')];
     $this->action->initialize($options);
     $this->action->execute($context);
 }
 public function testExecute()
 {
     $value = new PropertyPath('val');
     $attribute = new PropertyPath('attr');
     $context = new \stdClass();
     $context->val = 'Oro\\Bundle\\WorkflowBundle\\Tests\\Unit\\Model\\Action\\AssignConstantValueTest::TEST_CONSTANT';
     $context->attr = null;
     $this->action->initialize([$attribute, $value]);
     $this->action->execute($context);
     $this->assertEquals(self::TEST_CONSTANT, $context->attr);
 }
Exemple #5
0
 /**
  * Run transition process.
  *
  * @param WorkflowItem $workflowItem
  * @throws ForbiddenTransitionException
  */
 public function transit(WorkflowItem $workflowItem)
 {
     if ($this->isAllowed($workflowItem)) {
         $stepTo = $this->getStepTo();
         $workflowItem->setCurrentStep($workflowItem->getDefinition()->getStepByName($stepTo->getName()));
         if ($this->postAction) {
             $this->postAction->execute($workflowItem);
         }
     } else {
         throw new ForbiddenTransitionException(sprintf('Transition "%s" is not allowed.', $this->getName()));
     }
 }
 /**
  * Run transition process.
  *
  * @param WorkflowItem $workflowItem
  * @throws ForbiddenTransitionException
  */
 public function transit(WorkflowItem $workflowItem)
 {
     if ($this->isAllowed($workflowItem)) {
         $stepTo = $this->getStepTo();
         $workflowItem->setCurrentStepName($stepTo->getName());
         if ($stepTo->isFinal() || !$stepTo->hasAllowedTransitions()) {
             $workflowItem->setClosed(true);
         }
         if ($this->postAction) {
             $this->postAction->execute($workflowItem);
         }
     } else {
         throw new ForbiddenTransitionException(sprintf('Transition "%s" is not allowed.', $this->getName()));
     }
 }
 /**
  * @dataProvider optionsDataProvider
  * @param array $options
  */
 public function testExecute($options)
 {
     $context = array();
     $optionsData = array_values($options);
     if (is_array(current($optionsData))) {
         for ($i = 0; $i < count($optionsData); $i++) {
             $assignData = array_values($optionsData[$i]);
             $attribute = $assignData[0];
             $value = $assignData[1];
             $this->contextAccessor->expects($this->at($i))->method('setValue')->with($context, $attribute, $value);
         }
     } else {
         $attribute = $optionsData[0];
         $value = $optionsData[1];
         $this->contextAccessor->expects($this->once())->method('setValue')->with($context, $attribute, $value);
     }
     $this->action->initialize($options);
     $this->action->execute($context);
 }
 /**
  * Executes init actions
  */
 public function executeInitAction()
 {
     $this->initAction->execute($this->workflowItem);
 }
Exemple #9
0
 public function testSetCondition()
 {
     $condition = $this->getMockBuilder('Oro\\Bundle\\WorkflowBundle\\Model\\Condition\\ConditionInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->assignValue->expects($this->once())->method('setCondition')->with($condition);
     $this->action->setCondition($condition);
 }
Exemple #10
0
 public function testSetCondition()
 {
     $condition = $this->getMockBuilder('Oro\\Component\\ConfigExpression\\ExpressionInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->assignValue->expects($this->once())->method('setCondition')->with($condition);
     $this->action->setCondition($condition);
 }