public function testEvents() { $attributeNames = array('test'); $values = array('test' => 'value'); $data = $this->getMockBuilder('Oro\\Bundle\\WorkflowBundle\\Model\\WorkflowData')->disableOriginalConstructor()->getMock(); $data->expects($this->once())->method('getValues')->with($attributeNames)->will($this->returnValue($values)); $event = $this->getMockBuilder('Symfony\\Component\\Form\\FormEvent')->disableOriginalConstructor()->getMock(); $event->expects($this->once())->method('getData')->will($this->returnValue($data)); $event->expects($this->once())->method('setData')->with($this->isInstanceOf('Oro\\Bundle\\WorkflowBundle\\Model\\WorkflowData')); $this->listener->initialize($attributeNames); $this->listener->onPreSetData($event); // Test submit data $formData = $this->getMockBuilder('Oro\\Bundle\\WorkflowBundle\\Model\\WorkflowData')->disableOriginalConstructor()->getMock(); $formData->expects($this->once())->method('getValues')->will($this->returnValue($values)); $data->expects($this->once())->method('add')->with($values); $submitEvent = $this->getMockBuilder('Symfony\\Component\\Form\\FormEvent')->disableOriginalConstructor()->getMock(); $submitEvent->expects($this->once())->method('getData')->will($this->returnValue($formData)); $submitEvent->expects($this->once())->method('setData')->with($this->isInstanceOf('Oro\\Bundle\\WorkflowBundle\\Model\\WorkflowData')); $this->listener->onSubmit($submitEvent); }