/** * @param mixed $workflowIdentifier * @dataProvider activateWorkflowDataProvider */ public function testActivateWorkflow($workflowIdentifier) { if ($workflowIdentifier instanceof WorkflowDefinition) { $workflowName = $workflowIdentifier->getName(); $entityClass = $workflowIdentifier->getRelatedEntity(); } else { $workflowName = $workflowIdentifier; $entityClass = '\\DateTime'; $workflowDefinition = new WorkflowDefinition(); $workflowDefinition->setRelatedEntity($entityClass); /** @var Workflow $workflow */ $workflow = $this->getMockBuilder('Oro\\Bundle\\WorkflowBundle\\Model\\Workflow')->disableOriginalConstructor()->setMethods(null)->getMock(); $workflow->setName($workflowName); $workflow->setDefinition($workflowDefinition); $this->workflowRegistry->expects($this->once())->method('getWorkflow')->with($workflowIdentifier)->will($this->returnValue($workflow)); } $entityConfig = $this->getMock('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface'); $entityConfig->expects($this->once())->method('set')->with('active_workflow', $workflowName); $workflowConfigProvider = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Provider\\ConfigProvider')->disableOriginalConstructor()->getMock(); $workflowConfigProvider->expects($this->once())->method('hasConfig')->with($entityClass)->will($this->returnValue(true)); $workflowConfigProvider->expects($this->once())->method('getConfig')->with($entityClass)->will($this->returnValue($entityConfig)); $this->configManager->expects($this->once())->method('getProvider')->with('workflow')->will($this->returnValue($workflowConfigProvider)); $this->configManager->expects($this->once())->method('persist')->with($entityConfig); $this->configManager->expects($this->once())->method('flush'); $this->workflowManager->activateWorkflow($workflowIdentifier); }