/** * @param string $workflowItemDefinition * @param string $activeDefinition * @param bool $result * @dataProvider getActiveWorkflowDataProvider */ public function testIsResetAllowed($workflowItemDefinition, $activeDefinition, $result) { $entity = new \DateTime('now'); $entityId = 1; $entityClass = get_class($entity); $workflowItem = null === $workflowItemDefinition ? null : $this->createWorkflowItem($workflowItemDefinition); if (null === $activeDefinition) { $workflow = null; } else { $workflow = $this->getMockBuilder('Oro\\Bundle\\WorkflowBundle\\Model\\Workflow')->disableOriginalConstructor()->setMethods(null)->getMock(); $workflow->setName($activeDefinition); } $this->doctrineHelper->expects($this->any())->method('getEntityClass')->with($entity)->will($this->returnValue($entityClass)); $this->doctrineHelper->expects($this->any())->method('getSingleEntityIdentifier')->with($entity)->will($this->returnValue($entityId)); $workflowItemsRepository = $this->getMockBuilder('Oro\\Bundle\\WorkflowBundle\\Entity\\Repository\\WorkflowItemRepository')->disableOriginalConstructor()->setMethods(array('findByEntityMetadata'))->getMock(); $workflowItemsRepository->expects($this->once())->method('findByEntityMetadata')->with($entityClass, $entityId)->will($this->returnValue($workflowItem)); $this->registry->expects($this->any())->method('getRepository')->with('OroWorkflowBundle:WorkflowItem')->will($this->returnValue($workflowItemsRepository)); $this->workflowRegistry->expects($this->once())->method('getActiveWorkflowByEntityClass')->with($entityClass)->will($this->returnValue($workflow)); $this->assertEquals($result, $this->workflowManager->isResetAllowed($entity)); }
/** * Check that entity workflow item is equal to the active workflow item. * * @param object $entity * @return bool */ public function isResetAllowed($entity) { return $this->workflowManager->isResetAllowed($entity); }