Пример #1
0
 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());
 }
 /**
  * @param WorkflowDefinition $workflowDefinition
  * @param Workflow $workflow
  */
 protected function setSteps(WorkflowDefinition $workflowDefinition, Workflow $workflow)
 {
     $workflowSteps = array();
     foreach ($workflow->getStepManager()->getSteps() as $step) {
         $workflowStep = new WorkflowStep();
         $workflowStep->setName($step->getName())->setLabel($step->getLabel())->setStepOrder($step->getOrder())->setFinal($step->isFinal());
         $workflowSteps[] = $workflowStep;
     }
     $workflowDefinition->setSteps($workflowSteps);
 }