Exemplo n.º 1
0
 private function getEditorUser()
 {
     $user = new User();
     $ace = new AccessControlEntry();
     $ace->setType('security');
     $ace->setEntityId(AccessControlEntry::LEVEL_CONTENT_ADMIN);
     $ace->setGrantedBy(new User());
     $user->addAce($ace);
     return $user;
 }
Exemplo n.º 2
0
 /**
  * @Given /^the administrator "([^"]*)" with the email "([^"]*)" and the password "([^"]*)"$/
  */
 public function createAdminUser($name, $email, $password)
 {
     $em = $this->getEntityManager();
     $user = $this->createUser($name, $email, $password);
     $ace = new AccessControlEntry();
     $ace->setUser($user);
     $ace->setEntityId(AccessControlEntry::LEVEL_FULL_ADMIN);
     $ace->setType('security');
     $ace->setGrantedBy($user);
     $ace->setCreatedAt(new \DateTime());
     $em->persist($ace);
     $em->flush();
 }
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     //Make the admin user an admin
     $e = new AccessControlEntry();
     $e->setUser($this->getReference('adminuser'));
     $e->setGrantedBy($this->getReference('testuser1'));
     $e->setEntityId('-2');
     $e->setCreatedAt(new \DateTime('2001-01-01'));
     $e->setType('security');
     $manager->persist($e);
     //Make user2 owner of all shows
     $shows = $manager->getRepository('ActsCamdramBundle:Show')->findAll();
     foreach ($shows as $show) {
         $e = new AccessControlEntry();
         $e->setUser($this->getReference('testuser2'));
         $e->setGrantedBy($this->getReference('adminuser'));
         $e->setEntityId($show->getId());
         $e->setCreatedAt(new \DateTime('2001-01-01'));
         $e->setType('show');
         $manager->persist($e);
     }
     $manager->flush();
 }
Exemplo n.º 4
0
 public function testGetEntityIdsByUser_ValidClass()
 {
     $user = new User();
     $user->setEmail('*****@*****.**');
     $ace1 = new AccessControlEntry();
     $ace1->setType('show');
     $ace1->setEntityId(32);
     $ace2 = new AccessControlEntry();
     $ace2->setType('show');
     $ace2->setEntityId(44);
     $aces = array($ace1, $ace2);
     $this->repository->expects($this->once())->method('findByUserAndType')->with($user, 'show')->will($this->returnValue($aces));
     $retAces = $this->aclProvider->getEntityIdsByUser($user, '\\Acts\\CamdramBundle\\Entity\\Show');
     $this->assertEquals(32, $retAces[0]);
     $this->assertEquals(44, $retAces[1]);
 }