protected function createActionDefinitions()
 {
     $actionDefinition1 = new ActionDefinition('test1', 'orderTopic1');
     $actionDefinition1->setEventName('v.action.test1');
     $actionDefinition1->setParameters(array('p1' => 'v1', 'p2' => 'v2'));
     $actionDefinition1->setVersion(2);
     $actionDefinition2 = new ActionDefinition('test2', 'orderTopic2');
     $actionDefinition1->setEventName('v.action.test2');
     $actionDefinition2->setParameters(array('p1' => 'v1', 'p2' => 'v2'));
     $actionDefinition1->setVersion(3);
     return array($actionDefinition1, $actionDefinition2);
 }
 public function testExecutionActionWithSuccess()
 {
     $actionDefinition = new ActionDefinition('action1');
     $actionDefinition->setEventName('v.action.action1.execute');
     $action = $this->handler->createAction($actionDefinition);
     //Register our action listener
     $this->dispatcher->addListener('v.action.action1.execute', array(new MyGoodActionEventListener(), 'onExecute'));
     //Fire ahoy!
     $this->handler->process($action, $actionDefinition);
     //Event dispatcher should have called the event listener, so let's have a look at the outcome
     $this->assertTrue($action->isCompleted());
 }
 public function execute(&$context)
 {
     $actionManager = $this->getContainer()->get('vespolina.action_manager');
     $actionDefinitions = array();
     $actionDefinitionFixtures = array(array('name' => 'notify_customer', 'topic' => 'order', 'eventName' => 'v.action.order.notification_customer'));
     foreach ($actionDefinitionFixtures as $fixture) {
         $actionDefinition = new ActionDefinition($fixture['name'], $fixture['topic']);
         $actionDefinition->setEventName($fixture['eventName']);
         $actionManager->addActionDefinition($actionDefinition);
         $actionManager->updateActionDefinition($actionDefinition);
         $actionDefinitions[] = $actionDefinition;
     }
     $this->getLogger()->addInfo('Setup ' . count($actionDefinitions) . ' action(s).');
 }
 public function testVersions()
 {
     $actionDefinition = new ActionDefinition('orderPaintForCarNewerVersion', 'car');
     $actionDefinition->setVersion(2);
     $this->assertEquals($actionDefinition->getVersion(), 2);
 }