예제 #1
0
 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());
 }
예제 #2
0
 /**
  * @param int $expected
  * @param object $object
  * @param array $attributes
  * @param bool $updatable
  * @param bool $deletable
  * @dataProvider voteDataProvider
  */
 public function testVote($expected, $object, array $attributes = [], $updatable = true, $deletable = true)
 {
     $entityAcl = new WorkflowEntityAcl();
     $entityAcl->setEntityClass('WorkflowEntity')->setUpdatable($updatable)->setDeletable($deletable);
     $aclIdentity = new WorkflowEntityAclIdentity();
     $aclIdentity->setAcl($entityAcl);
     $identifier = null;
     if ($object instanceof WorkflowEntity) {
         $identifier = $object->getId();
         $this->setDoctrineHelper('WorkflowEntity', $identifier);
     } elseif ($object instanceof ObjectIdentity && filter_var($object->getIdentifier(), FILTER_VALIDATE_INT)) {
         $identifier = $object->getIdentifier();
     }
     $this->setRegistryRepositories([$entityAcl], 'WorkflowEntity', $identifier, [$aclIdentity]);
     $token = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface');
     $this->assertEquals($expected, $this->voter->vote($token, $object, $attributes));
 }