public function testInsertBulk()
 {
     $user = new User();
     $this->em->persist($user);
     $resource = new File();
     $this->em->persist($resource);
     $role = new FileOwnerRole($user, $resource);
     $this->em->persist($role);
     $this->em->flush();
     $authorizations = [Authorization::create($role, Actions::all(), $resource)];
     /** @var AuthorizationRepository $repository */
     $repository = $this->em->getRepository('MyCLabs\\ACL\\Model\\Authorization');
     $repository->insertBulk($authorizations);
     // Check that the authorization was inserted and can be retrieved
     $inserted = $repository->findAll();
     $this->assertCount(1, $inserted);
     /** @var Authorization $authorization */
     $authorization = $inserted[0];
     $this->assertSame($role, $authorization->getRole());
     $this->assertSame($user, $authorization->getSecurityIdentity());
     $this->assertEquals($resource->getId(), $authorization->getEntityId());
     $this->assertEquals('Tests\\MyCLabs\\ACL\\Unit\\Repository\\Model\\File', $authorization->getEntityClass());
     $this->assertEquals(Actions::all(), $authorization->getActions());
     $this->assertNull($authorization->getParentAuthorization());
     $this->assertEquals(0, count($authorization->getChildAuthorizations()));
     $this->assertTrue($authorization->isCascadable());
 }
Example #2
0
 public function testAll()
 {
     $actions = Actions::all();
     $this->assertTrue($actions->view);
     $this->assertTrue($actions->edit);
     $this->assertTrue($actions->create);
     $this->assertTrue($actions->delete);
     $this->assertTrue($actions->undelete);
     $this->assertTrue($actions->allow);
 }