mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing AclNode::node() so that node expressions that could match deeper elements are contained to their parent elements. Test added.
This commit is contained in:
parent
46348e9bbd
commit
068631ebe2
3 changed files with 20 additions and 4 deletions
|
@ -111,7 +111,8 @@ class AclNode extends AppModel {
|
|||
'conditions' => array(
|
||||
$db->name("{$type}{$i}.lft") . ' > ' . $db->name("{$type}{$j}.lft"),
|
||||
$db->name("{$type}{$i}.rght") . ' < ' . $db->name("{$type}{$j}.rght"),
|
||||
$db->name("{$type}{$i}.alias") . ' = ' . $db->value($alias, 'string')
|
||||
$db->name("{$type}{$i}.alias") . ' = ' . $db->value($alias, 'string'),
|
||||
$db->name("{$type}{$j}.id") . ' = ' . $db->name("{$type}{$i}.parent_id")
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ class AclNodeTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testNode() {
|
||||
$Aco = new DbAcoTest();
|
||||
$Aco =& new DbAcoTest();
|
||||
$result = Set::extract($Aco->node('Controller1'), '{n}.DbAcoTest.id');
|
||||
$expected = array(2, 1);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
@ -317,7 +317,19 @@ class AclNodeTest extends CakeTestCase {
|
|||
$result = $Aco->node('');
|
||||
$this->assertEqual($result, null);
|
||||
}
|
||||
/**
|
||||
|
||||
/**
|
||||
* test that node() doesn't dig deeper than it should.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testNodeWithDuplicatePathSegments() {
|
||||
$Aco =& new DbAcoTest();
|
||||
$nodes = $Aco->node('ROOT/Users');
|
||||
$this->assertEqual($nodes[0]['DbAcoTest']['parent_id'], 1, 'Parent id does not point at ROOT. %s');
|
||||
}
|
||||
|
||||
/**
|
||||
* testNodeArrayFind method
|
||||
*
|
||||
* @access public
|
||||
|
|
5
cake/tests/fixtures/aco_fixture.php
vendored
5
cake/tests/fixtures/aco_fixture.php
vendored
|
@ -57,7 +57,7 @@ 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' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'ROOT', 'lft' => 1, 'rght' => 24),
|
||||
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),
|
||||
|
@ -66,6 +66,9 @@ class AcoFixture extends CakeTestFixture {
|
|||
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' => 1, 'model' => null, 'foreign_key' => null, 'alias' => 'Users', 'lft' => 18, 'rght' => 23),
|
||||
array('parent_id' => 9, 'model' => null, 'foreign_key' => null, 'alias' => 'Users', 'lft' => 19, 'rght' => 22),
|
||||
array('parent_id' => 10, 'model' => null, 'foreign_key' => null, 'alias' => 'view', 'lft' => 20, 'rght' => 21),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue