コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public static function doSetUpBeforeClass()
 {
     static::$schemaTool = new SchemaTool(static::$em);
     static::$schemaTool->dropSchema(static::getTablesMetadata());
     static::$schemaTool->createSchema(static::getTablesMetadata());
     static::$encoder = static::$container->get('security.encoder_factory');
     static::$user = new User();
     static::$user->setEmail('*****@*****.**');
     static::$user->setPassword(static::$encoder->getEncoder(static::$user)->encodePassword('1234', static::$user->getSalt()));
     static::$user->setUsername('testUser');
     $entityPermissionCategory = new PermissionCategory();
     $entityPermissionCategory->setName('backend_user');
     $entityPermissionCategory->setTechnicalName('backend_user');
     static::$em->persist($entityPermissionCategory);
     $entityPermission = new Permission();
     $entityPermission->setRoleName('IS_AUTHENTICATED_FULLY');
     $entityPermission->setDescription('IS_AUTHENTICATED_FULLY');
     $entityPermission->setName('IS_AUTHENTICATED_FULLY');
     $entityPermission->setCategory($entityPermissionCategory);
     $entityPermission2 = new Permission();
     $entityPermission2->setRoleName('ROLE_MANAGE_PERMISSIONS');
     $entityPermission2->setDescription('ROLE_MANAGE_PERMISSIONS');
     $entityPermission2->setName('ROLE_MANAGE_PERMISSIONS');
     $entityPermission2->setCategory($entityPermissionCategory);
     $entityPermission3 = new Permission();
     $entityPermission3->setRoleName('ROLE_ACCESS_BACKEND_TOOLS_SECURITY_SECTION');
     $entityPermission3->setDescription('ROLE_ACCESS_BACKEND_TOOLS_SECURITY_SECTION');
     $entityPermission3->setName('ROLE_ACCESS_BACKEND_TOOLS_SECURITY_SECTION');
     $entityPermission3->setCategory($entityPermissionCategory);
     $entityPermission4 = new Permission();
     $entityPermission4->setRoleName('ROLE_MANAGE_USER_PROFILES');
     $entityPermission4->setDescription('ROLE_MANAGE_USER_PROFILES');
     $entityPermission4->setName('ROLE_MANAGE_USER_PROFILES');
     $entityPermission4->setCategory($entityPermissionCategory);
     static::$em->persist($entityPermission);
     static::$em->persist($entityPermission2);
     static::$em->persist($entityPermission3);
     static::$em->persist($entityPermission4);
     static::$em->flush();
     $group = new Group();
     $group->setRefName('BACKEND-USER');
     $group->setName('backend-user');
     $group->addPermission($entityPermission);
     $group->addPermission($entityPermission2);
     $group->addPermission($entityPermission3);
     $group->addPermission($entityPermission4);
     static::$user->addToGroup($group);
     static::$em->persist($group);
     static::$em->persist(static::$user);
     static::$em->flush();
 }