mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Fixing whitespacing on aco_fixture.
Adding tests to AclShell::grant() Refactoring __getParams()
This commit is contained in:
parent
6775e0997e
commit
9e36d1bedc
3 changed files with 37 additions and 30 deletions
|
@ -530,23 +530,15 @@ class AclShell extends Shell {
|
|||
* @access private
|
||||
*/
|
||||
function __getParams() {
|
||||
$aro = ife(is_numeric($this->args[0]), intval($this->args[0]), $this->args[0]);
|
||||
$aco = ife(is_numeric($this->args[1]), intval($this->args[1]), $this->args[1]);
|
||||
$aro = is_numeric($this->args[0]) ? intval($this->args[0]) : $this->args[0];
|
||||
$aco = is_numeric($this->args[1]) ? intval($this->args[1]) : $this->args[1];
|
||||
|
||||
if (is_string($aro) && preg_match('/^([\w]+)\.(.*)$/', $aro, $matches)) {
|
||||
$aro = array(
|
||||
'model' => $matches[1],
|
||||
'foreign_key' => $matches[2],
|
||||
);
|
||||
if (is_string($aro)) {
|
||||
$aro = $this->parseIdentifier($aro);
|
||||
}
|
||||
|
||||
if (is_string($aco) && preg_match('/^([\w]+)\.(.*)$/', $aco, $matches)) {
|
||||
$aco = array(
|
||||
'model' => $matches[1],
|
||||
'foreign_key' => $matches[2],
|
||||
);
|
||||
if (is_string($aco)) {
|
||||
$aco = $this->parseIdentifier($aco);
|
||||
}
|
||||
|
||||
$action = null;
|
||||
if (isset($this->args[2])) {
|
||||
$action = $this->args[2];
|
||||
|
|
|
@ -217,5 +217,20 @@ class AclShellTest extends CakeTestCase {
|
|||
$result = $Aro->read(null, 4);
|
||||
$this->assertEqual($result['Aro']['parent_id'], null);
|
||||
}
|
||||
|
||||
/**
|
||||
* test grant
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testGrant() {
|
||||
$this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'create');
|
||||
$this->Task->expectAt(0, 'out', array(new PatternExpectation('/Permission granted/'), true));
|
||||
$this->Task->grant();
|
||||
|
||||
$node = $this->Task->Acl->Aro->read(null, 4);
|
||||
$this->assertFalse(empty($node['Aco'][0]));
|
||||
$this->assertEqual($node['Aco'][0]['Permission']['_create'], 1);
|
||||
}
|
||||
}
|
||||
?>
|
30
cake/tests/fixtures/aco_fixture.php
vendored
30
cake/tests/fixtures/aco_fixture.php
vendored
|
@ -49,13 +49,13 @@ class AcoFixture extends CakeTestFixture {
|
|||
* @access public
|
||||
*/
|
||||
var $fields = array(
|
||||
'id' => array('type' => 'integer', 'key' => 'primary'),
|
||||
'parent_id' => array('type' => 'integer', 'length' => 10, 'null' => true),
|
||||
'model' => array('type' => 'string', 'default' => ''),
|
||||
'id' => array('type' => 'integer', 'key' => 'primary'),
|
||||
'parent_id' => array('type' => 'integer', 'length' => 10, 'null' => true),
|
||||
'model' => array('type' => 'string', 'default' => ''),
|
||||
'foreign_key' => array('type' => 'integer', 'length' => 10, 'null' => true),
|
||||
'alias' => array('type' => 'string', 'default' => ''),
|
||||
'lft' => array('type' => 'integer', 'length' => 10, 'null' => true),
|
||||
'rght' => array('type' => 'integer', 'length' => 10, 'null' => true)
|
||||
'alias' => array('type' => 'string', 'default' => ''),
|
||||
'lft' => array('type' => 'integer', 'length' => 10, 'null' => true),
|
||||
'rght' => array('type' => 'integer', 'length' => 10, 'null' => true)
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -65,15 +65,15 @@ class AcoFixture extends CakeTestFixture {
|
|||
* @access public
|
||||
*/
|
||||
var $records = array(
|
||||
array('parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'ROOT', 'lft' => 1, 'rght' => 18),
|
||||
array('parent_id' => 1, 'model' => null, 'foreign_key' => null, 'alias' => 'Controller1', 'lft' => 2, 'rght' => 9),
|
||||
array('parent_id' => 2, 'model' => null, 'foreign_key' => null, 'alias' => 'action1', 'lft' => 3, 'rght' => 6),
|
||||
array('parent_id' => 3, 'model' => null, 'foreign_key' => null, 'alias' => 'record1', 'lft' => 4, 'rght' => 5),
|
||||
array('parent_id' => 2, 'model' => null, 'foreign_key' => null, 'alias' => 'action2', 'lft' => 7, 'rght' => 8),
|
||||
array('parent_id' => 1, 'model' => null, 'foreign_key' => null, 'alias' => 'Controller2', 'lft' => 10, 'rght' => 17),
|
||||
array('parent_id' => 6, 'model' => null, 'foreign_key' => null, 'alias' => 'action1', 'lft' => 11, 'rght' => 14),
|
||||
array('parent_id' => 7, 'model' => null, 'foreign_key' => null, 'alias' => 'record1', 'lft' => 12, 'rght' => 13),
|
||||
array('parent_id' => 6, 'model' => null, 'foreign_key' => null, 'alias' => 'action2', 'lft' => 15, 'rght' => 16),
|
||||
array('parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'ROOT', 'lft' => 1, 'rght' => 18),
|
||||
array('parent_id' => 1, 'model' => null, 'foreign_key' => null, 'alias' => 'Controller1', 'lft' => 2, 'rght' => 9),
|
||||
array('parent_id' => 2, 'model' => null, 'foreign_key' => null, 'alias' => 'action1', 'lft' => 3, 'rght' => 6),
|
||||
array('parent_id' => 3, 'model' => null, 'foreign_key' => null, 'alias' => 'record1', 'lft' => 4, 'rght' => 5),
|
||||
array('parent_id' => 2, 'model' => null, 'foreign_key' => null, 'alias' => 'action2', 'lft' => 7, 'rght' => 8),
|
||||
array('parent_id' => 1, 'model' => null, 'foreign_key' => null, 'alias' => 'Controller2','lft' => 10, 'rght' => 17),
|
||||
array('parent_id' => 6, 'model' => null, 'foreign_key' => null, 'alias' => 'action1', 'lft' => 11, 'rght' => 14),
|
||||
array('parent_id' => 7, 'model' => null, 'foreign_key' => null, 'alias' => 'record1', 'lft' => 12, 'rght' => 13),
|
||||
array('parent_id' => 6, 'model' => null, 'foreign_key' => null, 'alias' => 'action2', 'lft' => 15, 'rght' => 16),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue