public function testSetDefaultValues() { $workflowItem = $this->getMockBuilder('Oro\\Bundle\\WorkflowBundle\\Entity\\WorkflowItem')->disableOriginalConstructor()->getMock(); $defaultValues = array('test' => 'value'); $this->contextAccessor->expects($this->once())->method('getValue')->with($workflowItem, 'value')->will($this->returnValue('testValue')); $data = $this->getMockBuilder('Oro\\Bundle\\WorkflowBundle\\Model\\WorkflowData')->disableOriginalConstructor()->getMock(); $data->expects($this->once())->method('set')->with('test', 'testValue'); $event = $this->getMockBuilder('Symfony\\Component\\Form\\FormEvent')->disableOriginalConstructor()->getMock(); $event->expects($this->once())->method('getData')->will($this->returnValue($data)); $this->listener->initialize($workflowItem, $defaultValues); $this->listener->setDefaultValues($event); }
/** * Adds required event listeners * * @param FormBuilderInterface $builder * @param array $options */ protected function addEventListeners(FormBuilderInterface $builder, array $options) { if (!empty($options['attribute_default_values'])) { $this->defaultValuesListener->initialize($options['workflow_item'], $options['attribute_default_values']); $builder->addEventSubscriber($this->defaultValuesListener); } if (!empty($options['init_actions'])) { $this->initActionsListener->initialize($options['workflow_item'], $options['init_actions']); $builder->addEventSubscriber($this->initActionsListener); } if (!empty($options['attribute_fields'])) { $this->requiredAttributesListener->initialize(array_keys($options['attribute_fields'])); $builder->addEventSubscriber($this->requiredAttributesListener); } }