Beispiel #1
0
 private function configureACL()
 {
     $setup = new ACLSetup();
     $setup->setSecurityIdentityClass('Tests\\MyCLabs\\ACL\\Integration\\Model\\User');
     $setup->registerRoleClass('Tests\\MyCLabs\\ACL\\Integration\\Model\\ArticleEditorRole', 'articleEditor');
     $setup->registerRoleClass('Tests\\MyCLabs\\ACL\\Integration\\Model\\AllArticlesEditorRole', 'allArticlesEditor');
     $setup->registerRoleClass('Tests\\MyCLabs\\ACL\\Integration\\Model\\ArticlePublisherRole', 'articlePublisher');
     $setup->registerRoleClass('Tests\\MyCLabs\\ACL\\Integration\\Model\\CategoryManagerRole', 'categoryManager');
     $setup->registerRoleClass('Tests\\MyCLabs\\ACL\\Integration\\Issues\\Issue10\\AccountAdminRole', 'accountAdmin');
     $setup->setActionsClass('Tests\\MyCLabs\\ACL\\Integration\\Model\\Actions');
     return $setup;
 }
 public function setUp()
 {
     $paths = [__DIR__ . '/../../../src/Model', __DIR__ . '/Model'];
     $dbParams = ['driver' => 'pdo_sqlite', 'memory' => true];
     $setup = new ACLSetup();
     $setup->setSecurityIdentityClass('Tests\\MyCLabs\\ACL\\Unit\\Repository\\Model\\User');
     $setup->registerRoleClass('Tests\\MyCLabs\\ACL\\Unit\\Repository\\Model\\FileOwnerRole', 'fileOwner');
     // Create the entity manager
     $config = Setup::createAnnotationMetadataConfiguration($paths, true, null, new ArrayCache(), false);
     $this->em = EntityManager::create($dbParams, $config);
     $this->acl = new ACL($this->em);
     $setup->setUpEntityManager($this->em, function () {
         return $this->acl;
     });
     // Create the DB
     $tool = new SchemaTool($this->em);
     $tool->createSchema($this->em->getMetadataFactory()->getAllMetadata());
 }
Beispiel #3
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage The given class doesn't implement SecurityIdentityInterface
  */
 public function testSetInvalidSecurityIdentityClass()
 {
     $loader = new ACLSetup();
     $loader->setSecurityIdentityClass('foo', 'foo');
 }
Beispiel #4
0
use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\ORM\Tools\Setup;
use MyCLabs\ACL\ACL;
use MyCLabs\ACL\Doctrine\ACLSetup;
use Tests\MyCLabs\ACL\Performance\Model\Article;
use Tests\MyCLabs\ACL\Performance\Model\Category;
use Tests\MyCLabs\ACL\Performance\Model\User;
require_once __DIR__ . '/../../vendor/autoload.php';
// Create the entity manager
$paths = [__DIR__ . '/../../src/Model', __DIR__ . '/Model'];
$dbParams = ['driver' => 'pdo_sqlite', 'memory' => true];
$config = Setup::createAnnotationMetadataConfiguration($paths, true, null, new ArrayCache(), false);
$em = EntityManager::create($dbParams, $config);
// Create the ACL object
$acl = new ACL($em);
$setup = new ACLSetup();
$setup->setSecurityIdentityClass('Tests\\MyCLabs\\ACL\\Performance\\Model\\User');
$setup->registerRoleClass('Tests\\MyCLabs\\ACL\\Performance\\Model\\ArticleEditorRole', 'articleEditor');
$setup->registerRoleClass('Tests\\MyCLabs\\ACL\\Performance\\Model\\AllArticlesEditorRole', 'allArticlesEditor');
$setup->registerRoleClass('Tests\\MyCLabs\\ACL\\Performance\\Model\\CategoryManagerRole', 'categoryManager');
$setup->setUpEntityManager($em, function () use($acl) {
    return $acl;
});
// Create the schema
$tool = new SchemaTool($em);
$tool->createSchema($em->getMetadataFactory()->getAllMetadata());
// Necessary so that SQLite supports CASCADE DELETE
if ($dbParams['driver'] == 'pdo_sqlite') {
    $em->getConnection()->executeQuery('PRAGMA foreign_keys = ON');
}
$users = [];