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());
 }
Example #2
0
 /**
  * @param WorkflowDefinition $definition
  * @return WorkflowDefinition
  */
 public function import(WorkflowDefinition $definition)
 {
     $this->setName($definition->getName())->setLabel($definition->getLabel())->setRelatedEntity($definition->getRelatedEntity())->setEntityAttributeName($definition->getEntityAttributeName())->setConfiguration($definition->getConfiguration())->setSteps($definition->getSteps())->setStartStep($definition->getStartStep())->setStepsDisplayOrdered($definition->isStepsDisplayOrdered())->setEntityAcls($definition->getEntityAcls())->setSystem($definition->isSystem());
     return $this;
 }