updated acl test debug method to display individual permissions

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6911 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
AD7six 2008-05-17 18:23:05 +00:00
parent 56ce3c0f1c
commit ec12b91657

View file

@ -107,7 +107,6 @@ class AclComponentTest extends CakeTestCase {
$this->Acl->Aco->create(array('parent_id' => $parent, 'alias' => 'PiecesOfFlair')); $this->Acl->Aco->create(array('parent_id' => $parent, 'alias' => 'PiecesOfFlair'));
$this->assertTrue($this->Acl->Aco->save()); $this->assertTrue($this->Acl->Aco->save());
} }
function testDbAclAllow() { function testDbAclAllow() {
@ -207,7 +206,6 @@ class AclComponentTest extends CakeTestCase {
$this->assertFalse($this->Acl->check('Milton', 'smash', 'read')); $this->assertFalse($this->Acl->check('Milton', 'smash', 'read'));
$this->Acl->inherit('Milton', 'smash', 'read'); $this->Acl->inherit('Milton', 'smash', 'read');
$this->assertTrue($this->Acl->check('Milton', 'smash', 'read')); $this->assertTrue($this->Acl->check('Milton', 'smash', 'read'));
} }
function testDbGrant() { function testDbGrant() {
@ -270,7 +268,6 @@ class AclComponentTest extends CakeTestCase {
//This method is not implemented in either INI_ACL or DB_ACL //This method is not implemented in either INI_ACL or DB_ACL
//$result = $this->Acl->getAco('tpsReports'); //$result = $this->Acl->getAco('tpsReports');
//$this->assertEqual($result, $expected); //$this->assertEqual($result, $expected);
} }
*/ */
function testIniReadConfigFile() { function testIniReadConfigFile() {
@ -344,6 +341,7 @@ class AclComponentTest extends CakeTestCase {
* *
* To check the overal ACL status at any time call $this->__debug(); * To check the overal ACL status at any time call $this->__debug();
* Generates a list of the current aro and aco structures and a grid dump of the permissions that are defined * Generates a list of the current aro and aco structures and a grid dump of the permissions that are defined
* Only designed to work with the db based ACL
* *
* @access private * @access private
* @return void * @return void
@ -353,12 +351,24 @@ class AclComponentTest extends CakeTestCase {
$this->Acl->Aco->displayField = 'alias'; $this->Acl->Aco->displayField = 'alias';
$aros = $this->Acl->Aro->find('list'); $aros = $this->Acl->Aro->find('list');
$acos = $this->Acl->Aco->find('list'); $acos = $this->Acl->Aco->find('list');
$permissions = array(); $rights = array('*', 'create', 'read', 'update', 'delete');
$permissions['Aros v Acos >'] = $acos; $permissions['Aros v Acos >'] = $acos;
foreach ($aros as $aro) { foreach ($aros as $aro) {
$row = array(); $row = array();
foreach ($acos as $aco) { foreach ($acos as $aco) {
$row[] = ($this->Acl->check($aro, $aco))?'y':'n'; $perms = '';
foreach ($rights as $right) {
if ($this->Acl->check($aro, $aco, $right)) {
if ($right == '*') {
$perms .= '****';
break;
}
$perms .= $right[0];
} elseif ($right != '*') {
$perms .= ' ';
}
}
$row[] = $perms;
} }
$permissions[$aro] = $row; $permissions[$aro] = $row;
} }
@ -381,10 +391,7 @@ class AclComponentTest extends CakeTestCase {
* @access private * @access private
* @return void * @return void
*/ */
function __pad($string = '', $len = 12) { function __pad($string = '', $len = 14) {
if (strlen($string) == 1) {
return ' ' . $string . ' ';
}
return str_pad($string, $len); return str_pad($string, $len);
} }
} }