示例#1
0
 public function getResources()
 {
     return parent::getResources();
 }
 protected function assertAclIsConfiguredAsExpected(\Phalcon\Acl\Adapter\Memory $acl, \Phalcon\Config $config)
 {
     // assert default action
     $this->assertEquals(\Phalcon\Acl::DENY, $acl->getDefaultAction());
     // assert resources
     $resources = $acl->getResources();
     $this->assertInternalType('array', $resources);
     $indexResource = $resources[0];
     $testResource = $resources[1];
     $this->assertEquals('index', $indexResource->getName());
     $this->assertEquals('test', $testResource->getName());
     $this->assertEquals($config->acl->resource->index->description, $indexResource->getDescription());
     $this->assertEquals($config->acl->resource->test->description, $testResource->getDescription());
     // assert roles
     $roles = $acl->getRoles();
     $this->assertInternalType('array', $roles);
     $guestRole = $roles[0];
     $userRole = $roles[1];
     $this->assertEquals('guest', $guestRole->getName());
     $this->assertEquals('user', $userRole->getName());
     $this->assertEquals($config->acl->role->guest->description, $guestRole->getDescription());
     $this->assertEquals($config->acl->role->user->description, $userRole->getDescription());
     // assert guest rules
     $this->assertTrue($acl->isAllowed('guest', 'index', 'index'));
     $this->assertFalse($acl->isAllowed('guest', 'test', 'index'));
     // assert user rules
     // inherited from guest
     $this->assertTrue($acl->isAllowed('user', 'index', 'index'));
     $this->assertTrue($acl->isAllowed('user', 'test', 'index'));
 }