public function testImport() { $step = new WorkflowStep(); $step->setName('step'); $definition = new WorkflowDefinition(); $definition->addStep($step); $this->entityAcl->setAttribute('attribute'); $this->entityAcl->setStep($step); $this->entityAcl->setEntityClass('TestEntity'); $this->entityAcl->setUpdatable(false); $this->entityAcl->setDeletable(false); $newEntityAcl = new WorkflowEntityAcl(); $newEntityAcl->setDefinition($definition); $this->assertEquals($newEntityAcl, $newEntityAcl->import($this->entityAcl)); $this->assertEquals('attribute', $newEntityAcl->getAttribute()); $this->assertEquals($step, $newEntityAcl->getStep()); $this->assertEquals('TestEntity', $newEntityAcl->getEntityClass()); $this->assertFalse($this->entityAcl->isUpdatable()); $this->assertFalse($this->entityAcl->isDeletable()); $this->assertEquals($this->entityAcl->getAttributeStepKey(), $newEntityAcl->getAttributeStepKey()); }
public function testImport() { $step = new WorkflowStep(); $step->setName('step'); $entityAcl = new WorkflowEntityAcl(); $entityAcl->setStep($step)->setAttribute('attribute'); $this->aclIdentity->setEntityId(123); $this->aclIdentity->setAcl($entityAcl); $newAclIdentity = new WorkflowEntityAclIdentity(); $newAclIdentity->setAcl($entityAcl); $this->assertEquals($newAclIdentity, $newAclIdentity->import($this->aclIdentity)); $this->assertEquals(123, $newAclIdentity->getEntityId()); $this->assertEquals($this->aclIdentity->getAclAttributeStepKey(), $newAclIdentity->getAclAttributeStepKey()); }
/** * @expectedException \Oro\Bundle\WorkflowBundle\Exception\WorkflowException * @expectedExceptionMessage Value of attribute "attribute" must be an object */ public function testUpdateAclIdentitiesNotAnObjectException() { $workflowName = 'test_workflow'; $step = new WorkflowStep(); $step->setName('step'); $attribute = new Attribute(); $attribute->setName('attribute')->setOption('class', 'TestEntity'); $entityAcl = new WorkflowEntityAcl(); $entityAcl->setStep($step)->setAttribute($attribute->getName()); $definition = new WorkflowDefinition(); $definition->setName($workflowName)->setSteps(array($step))->setEntityAcls(array($entityAcl)); $this->setWorkflow($workflowName, array($attribute)); $workflowItem = new WorkflowItem(); $workflowItem->setWorkflowName($workflowName)->setDefinition($definition)->setCurrentStep($step); $workflowItem->getData()->set($attribute->getName(), 'not_an_object'); $this->manager->updateAclIdentities($workflowItem); }
public function testSetGetAclIdentities() { $firstStep = new WorkflowStep(); $firstStep->setName('first_step'); $secondStep = new WorkflowStep(); $secondStep->setName('second_step'); $this->workflowDefinition->setSteps(array($firstStep, $secondStep)); $firstEntityAcl = new WorkflowEntityAcl(); $firstEntityAcl->setStep($firstStep)->setAttribute('first_attribute'); $secondEntityAcl = new WorkflowEntityAcl(); $secondEntityAcl->setStep($secondStep)->setAttribute('second_attribute'); // default $this->assertEmpty($this->workflowDefinition->getEntityAcls()->toArray()); // adding $this->workflowDefinition->setEntityAcls(array($firstEntityAcl)); $this->assertCount(1, $this->workflowDefinition->getEntityAcls()); $this->assertEquals($firstEntityAcl, $this->workflowDefinition->getEntityAcls()->first()); // merging $this->workflowDefinition->setEntityAcls(array($firstEntityAcl, $secondEntityAcl)); $this->assertCount(2, $this->workflowDefinition->getEntityAcls()); $entityAcls = array_values($this->workflowDefinition->getEntityAcls()->toArray()); $this->assertEquals($firstEntityAcl, $entityAcls[0]); $this->assertEquals($secondEntityAcl, $entityAcls[1]); // removing $this->workflowDefinition->setEntityAcls(array($secondEntityAcl)); $this->assertCount(1, $this->workflowDefinition->getEntityAcls()); $this->assertEquals($secondEntityAcl, $this->workflowDefinition->getEntityAcls()->first()); // resetting $this->workflowDefinition->setEntityAcls(array()); $this->assertEmpty($this->workflowDefinition->getEntityAcls()->toArray()); }