Phalcon\Test\Unit\Acl\Adapter\MemoryTest::testAclNegationOfInheritedRoles PHP Method

testAclNegationOfInheritedRoles() public method

Tests negation of inherited roles
Since: 2014-10-04
Author: Nikolaos Dimopoulos ([email protected])
    public function testAclNegationOfInheritedRoles()
    {
        $this->specify('Negation of inherited roles does not return the correct result', function () {
            $acl = new Memory();
            $acl->setDefaultAction(Acl::DENY);
            $acl->addRole('Guests');
            $acl->addRole('Members', 'Guests');
            $acl->addResource('Login', ['help', 'index']);
            $acl->allow('Guests', 'Login', '*');
            $acl->deny('Guests', 'Login', ['help']);
            $acl->deny('Members', 'Login', ['index']);
            $actual = (bool) $acl->isAllowed('Members', 'Login', 'index');
            expect($actual)->false();
            $actual = (bool) $acl->isAllowed('Guests', 'Login', 'index');
            expect($actual)->true();
            $actual = (bool) $acl->isAllowed('Guests', 'Login', 'help');
            expect($actual)->false();
        });
    }