/** * getAclRule * * @param $roleId * @param $resourceId * @param string $allowDeny * * @return AclRule * @throws \RcmUser\Exception\RcmUserException */ protected function getAclRule($roleId, $resourceId, $allowDeny = 'allow') { $rule = new AclRule(); $rule->setRoleId($roleId); $rule->setRule($allowDeny); $rule->setResourceId($resourceId); $rule->setPrivilege('read'); return $rule; }
/** * testArrayIterator * * @covers \RcmUser\Acl\Entity\AclRule::getIterator * * @return void */ public function testArrayIterator() { $aclRule = new AclRule(); $rule = 'allow'; $roleId = 'role'; $resource = 'someresource'; $privileges = ['someprivilege']; $aclRule->setRule($rule); $aclRule->setRoleId($roleId); $aclRule->setResourceId($resource); $aclRule->setPrivileges($privileges); $iter = $aclRule->getIterator(); $array1 = iterator_to_array($aclRule); $array2 = iterator_to_array($iter); $this->assertTrue($array1 == $array2, 'Iterator failed work.'); $this->assertTrue(is_array($array1), 'Iterator failed work.'); $this->assertArrayHasKey('rule', $array1, 'Iterator did not populate correctly.'); }