mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding test case for acl shell.
Fixing display of nodes with no alias when using 'cake acl view aro' Fixes #6393 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8177 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
a44e69e47f
commit
2cc00ac3e1
2 changed files with 135 additions and 2 deletions
|
@ -205,7 +205,7 @@ class AclShell extends Shell {
|
||||||
extract($this->__dataVars());
|
extract($this->__dataVars());
|
||||||
$data = array(
|
$data = array(
|
||||||
$class => array(
|
$class => array(
|
||||||
'id' => $this->args[1],
|
'id' => $this->args[1],
|
||||||
'parent_id' => $this->args[2]
|
'parent_id' => $this->args[2]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -336,7 +336,12 @@ class AclShell extends Shell {
|
||||||
}
|
}
|
||||||
$last = $n[$class]['rght'];
|
$last = $n[$class]['rght'];
|
||||||
$count = count($stack);
|
$count = count($stack);
|
||||||
$this->out(str_repeat(' ', $count) . "[" . $n[$class]['id'] . "]" . $n[$class]['alias']."\n");
|
$indent = str_repeat(' ', $count);
|
||||||
|
if ($n[$class]['alias']) {
|
||||||
|
$this->out($indent . "[" . $n[$class]['id'] . "]" . $n[$class]['alias']."\n");
|
||||||
|
} else {
|
||||||
|
$this->out($indent . "[" . $n[$class]['id'] . "]" . $n[$class]['model'] . '.' . $n[$class]['foreign_key'] . "\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$this->hr();
|
$this->hr();
|
||||||
}
|
}
|
||||||
|
|
128
cake/tests/cases/console/libs/acl.test.php
Normal file
128
cake/tests/cases/console/libs/acl.test.php
Normal file
|
@ -0,0 +1,128 @@
|
||||||
|
<?php
|
||||||
|
/* SVN FILE: $Id$ */
|
||||||
|
/**
|
||||||
|
* AclShell Test file
|
||||||
|
*
|
||||||
|
* PHP versions 4 and 5
|
||||||
|
*
|
||||||
|
* CakePHP : Rapid Development Framework (http://www.cakephp.org)
|
||||||
|
* Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under The MIT License
|
||||||
|
* Redistributions of files must retain the above copyright notice.
|
||||||
|
*
|
||||||
|
* @filesource
|
||||||
|
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||||
|
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.tests.cases.console.libs.tasks
|
||||||
|
* @since CakePHP v 1.2.0.7726
|
||||||
|
* @version $Revision$
|
||||||
|
* @modifiedby $LastChangedBy$
|
||||||
|
* @lastmodified $Date$
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
|
*/
|
||||||
|
App::import('Core', 'Shell');
|
||||||
|
|
||||||
|
if (!defined('DISABLE_AUTO_DISPATCH')) {
|
||||||
|
define('DISABLE_AUTO_DISPATCH', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!class_exists('ShellDispatcher')) {
|
||||||
|
ob_start();
|
||||||
|
$argv = false;
|
||||||
|
require CAKE . 'console' . DS . 'cake.php';
|
||||||
|
ob_end_clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!class_exists('AclShell')) {
|
||||||
|
require CAKE . 'console' . DS . 'libs' . DS . 'acl.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
Mock::generatePartial(
|
||||||
|
'ShellDispatcher', 'TestAclShellMockShellDispatcher',
|
||||||
|
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
|
||||||
|
);
|
||||||
|
Mock::generatePartial(
|
||||||
|
'AclShell', 'MockAclShell',
|
||||||
|
array('in', 'out', 'hr', 'createFile')
|
||||||
|
);
|
||||||
|
/**
|
||||||
|
* AclShellTest class
|
||||||
|
*
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.tests.cases.console.libs.tasks
|
||||||
|
*/
|
||||||
|
class AclShellTest extends CakeTestCase {
|
||||||
|
var $fixtures = array('core.aco', 'core.aro', 'core.aros_aco');
|
||||||
|
/**
|
||||||
|
* configure Configure for testcase
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
function startCase() {
|
||||||
|
$this->_aclDb = Configure::read('Acl.database');
|
||||||
|
$this->_aclClass = Configure::read('Acl.classname');
|
||||||
|
|
||||||
|
Configure::write('Acl.database', 'test_suite');
|
||||||
|
Configure::write('Acl.classname', 'DbAcl');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* restore Environment settings
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
function endCase() {
|
||||||
|
Configure::write('Acl.database', $this->_aclDb);
|
||||||
|
Configure::write('Acl.classname', $this->_aclClass);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* setUp method
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function startTest() {
|
||||||
|
$this->Dispatcher =& new TestAclShellMockShellDispatcher();
|
||||||
|
$this->Task =& new MockAclShell($this->Dispatcher);
|
||||||
|
$this->Task->Dispatch = new $this->Dispatcher;
|
||||||
|
$this->Task->params['datasource'] = 'test_suite';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tearDown method
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function endTest() {
|
||||||
|
ClassRegistry::flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test that model.foreign_key output works when looking at acl rows
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
function testViewWithModelForeignKeyOutput() {
|
||||||
|
$this->Task->command = 'view';
|
||||||
|
$this->Task->startup();
|
||||||
|
$data = array(
|
||||||
|
'parent_id' => null,
|
||||||
|
'model' => 'MyModel',
|
||||||
|
'foreign_key' => 2,
|
||||||
|
);
|
||||||
|
$this->Task->Acl->Aro->create($data);
|
||||||
|
$this->Task->Acl->Aro->save();
|
||||||
|
$this->Task->args[0] = 'aro';
|
||||||
|
|
||||||
|
$this->Task->expectAt(0, 'out', array('Aro tree:'));
|
||||||
|
$this->Task->expectAt(1, 'out', array(new PatternExpectation('/\[1\]ROOT/')));
|
||||||
|
$this->Task->expectAt(3, 'out', array(new PatternExpectation('/\[3\]Gandalf/')));
|
||||||
|
$this->Task->expectAt(5, 'out', array(new PatternExpectation('/\[5\]MyModel.2/')));
|
||||||
|
|
||||||
|
$this->Task->view();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
Loading…
Reference in a new issue