Created
January 17, 2017 03:13
-
-
Save markstory/34c250f7045f0fe9698366c0063c9bb6 to your computer and use it in GitHub Desktop.
cakephp issue 10005
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ Console/cake test core Model/Behavior/TreeBehaviorNumber --filter testSaveRecursiveTree | |
Welcome to CakePHP v2.9.4 Console | |
--------------------------------------------------------------- | |
App : app | |
Path: /Users/markstory/Sites/cake_dev/app/ | |
--------------------------------------------------------------- | |
CakePHP Test Shell | |
--------------------------------------------------------------- | |
PHPUnit 3.7.38 by Sebastian Bergmann. | |
./Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php (line 1654) | |
########## DEBUG ########## | |
array( | |
'app' => array( | |
'GroupPermissions' => array( | |
'admin_add' => (int) 0, | |
'admin_delete' => (int) 1, | |
'admin_edit' => (int) 2, | |
'admin_group' => (int) 3, | |
'admin_index' => (int) 4 | |
), | |
'Groups' => array( | |
'admin_acos' => (int) 0, | |
'admin_add' => (int) 1, | |
'admin_delete' => (int) 2, | |
'admin_edit' => (int) 3, | |
'admin_index' => (int) 4 | |
), | |
'Members' => array( | |
'login' => '*****', | |
'admin_acos' => (int) 0, | |
'admin_add' => (int) 1, | |
'admin_delete' => (int) 2, | |
'admin_edit' => (int) 3, | |
'admin_index' => (int) 4, | |
'admin_test' => (int) 5, | |
'admin_view' => (int) 6, | |
'logout' => (int) 8, | |
'setup' => (int) 9 | |
) | |
) | |
) | |
########################### | |
/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php (line 1654) | |
########## DEBUG ########## | |
array( | |
'GroupPermissions' => array( | |
'admin_add' => (int) 0, | |
'admin_delete' => (int) 1, | |
'admin_edit' => (int) 2, | |
'admin_group' => (int) 3, | |
'admin_index' => (int) 4 | |
), | |
'Groups' => array( | |
'admin_acos' => (int) 0, | |
'admin_add' => (int) 1, | |
'admin_delete' => (int) 2, | |
'admin_edit' => (int) 3, | |
'admin_index' => (int) 4 | |
), | |
'Members' => array( | |
'login' => '*****', | |
'admin_acos' => (int) 0, | |
'admin_add' => (int) 1, | |
'admin_delete' => (int) 2, | |
'admin_edit' => (int) 3, | |
'admin_index' => (int) 4, | |
'admin_test' => (int) 5, | |
'admin_view' => (int) 6, | |
'logout' => (int) 8, | |
'setup' => (int) 9 | |
) | |
) | |
########################### | |
/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php (line 1654) | |
########## DEBUG ########## | |
array( | |
'admin_add' => (int) 0, | |
'admin_delete' => (int) 1, | |
'admin_edit' => (int) 2, | |
'admin_group' => (int) 3, | |
'admin_index' => (int) 4 | |
) | |
########################### | |
/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php (line 1654) | |
########## DEBUG ########## | |
array( | |
'admin_acos' => (int) 0, | |
'admin_add' => (int) 1, | |
'admin_delete' => (int) 2, | |
'admin_edit' => (int) 3, | |
'admin_index' => (int) 4 | |
) | |
########################### | |
/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php (line 1654) | |
########## DEBUG ########## | |
array( | |
'login' => '*****', | |
'admin_acos' => (int) 0, | |
'admin_add' => (int) 1, | |
'admin_delete' => (int) 2, | |
'admin_edit' => (int) 3, | |
'admin_index' => (int) 4, | |
'admin_test' => (int) 5, | |
'admin_view' => (int) 6, | |
'logout' => (int) 8, | |
'setup' => (int) 9 | |
) | |
########################### | |
/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php (line 1647) | |
########## DEBUG ########## | |
array( | |
(int) 0 => array( | |
'NumberTree' => array( | |
'id' => '1', | |
'name' => 'app', | |
'parent_id' => null, | |
'lft' => '1', | |
'rght' => '48', | |
'level' => '0' | |
) | |
), | |
(int) 1 => array( | |
'NumberTree' => array( | |
'id' => '2', | |
'name' => 'GroupPermissions', | |
'parent_id' => '1', | |
'lft' => '2', | |
'rght' => '13', | |
'level' => '1' | |
) | |
), | |
(int) 2 => array( | |
'NumberTree' => array( | |
'id' => '3', | |
'name' => 'admin_add', | |
'parent_id' => '2', | |
'lft' => '3', | |
'rght' => '4', | |
'level' => '2' | |
) | |
), | |
(int) 3 => array( | |
'NumberTree' => array( | |
'id' => '4', | |
'name' => 'admin_delete', | |
'parent_id' => '2', | |
'lft' => '5', | |
'rght' => '6', | |
'level' => '2' | |
) | |
), | |
(int) 4 => array( | |
'NumberTree' => array( | |
'id' => '5', | |
'name' => 'admin_edit', | |
'parent_id' => '2', | |
'lft' => '7', | |
'rght' => '8', | |
'level' => '2' | |
) | |
), | |
(int) 5 => array( | |
'NumberTree' => array( | |
'id' => '6', | |
'name' => 'admin_group', | |
'parent_id' => '2', | |
'lft' => '9', | |
'rght' => '10', | |
'level' => '2' | |
) | |
), | |
(int) 6 => array( | |
'NumberTree' => array( | |
'id' => '7', | |
'name' => 'admin_index', | |
'parent_id' => '2', | |
'lft' => '11', | |
'rght' => '12', | |
'level' => '2' | |
) | |
), | |
(int) 7 => array( | |
'NumberTree' => array( | |
'id' => '8', | |
'name' => 'Groups', | |
'parent_id' => '1', | |
'lft' => '14', | |
'rght' => '25', | |
'level' => '1' | |
) | |
), | |
(int) 8 => array( | |
'NumberTree' => array( | |
'id' => '9', | |
'name' => 'admin_acos', | |
'parent_id' => '8', | |
'lft' => '15', | |
'rght' => '16', | |
'level' => '2' | |
) | |
), | |
(int) 9 => array( | |
'NumberTree' => array( | |
'id' => '10', | |
'name' => 'admin_add', | |
'parent_id' => '8', | |
'lft' => '17', | |
'rght' => '18', | |
'level' => '2' | |
) | |
), | |
(int) 10 => array( | |
'NumberTree' => array( | |
'id' => '11', | |
'name' => 'admin_delete', | |
'parent_id' => '8', | |
'lft' => '19', | |
'rght' => '20', | |
'level' => '2' | |
) | |
), | |
(int) 11 => array( | |
'NumberTree' => array( | |
'id' => '12', | |
'name' => 'admin_edit', | |
'parent_id' => '8', | |
'lft' => '21', | |
'rght' => '22', | |
'level' => '2' | |
) | |
), | |
(int) 12 => array( | |
'NumberTree' => array( | |
'id' => '13', | |
'name' => 'admin_index', | |
'parent_id' => '8', | |
'lft' => '23', | |
'rght' => '24', | |
'level' => '2' | |
) | |
), | |
(int) 13 => array( | |
'NumberTree' => array( | |
'id' => '14', | |
'name' => 'Members', | |
'parent_id' => '1', | |
'lft' => '26', | |
'rght' => '47', | |
'level' => '1' | |
) | |
), | |
(int) 14 => array( | |
'NumberTree' => array( | |
'id' => '15', | |
'name' => 'admin_acos', | |
'parent_id' => '14', | |
'lft' => '27', | |
'rght' => '28', | |
'level' => '2' | |
) | |
), | |
(int) 15 => array( | |
'NumberTree' => array( | |
'id' => '16', | |
'name' => 'admin_add', | |
'parent_id' => '14', | |
'lft' => '29', | |
'rght' => '30', | |
'level' => '2' | |
) | |
), | |
(int) 16 => array( | |
'NumberTree' => array( | |
'id' => '17', | |
'name' => 'admin_delete', | |
'parent_id' => '14', | |
'lft' => '31', | |
'rght' => '32', | |
'level' => '2' | |
) | |
), | |
(int) 17 => array( | |
'NumberTree' => array( | |
'id' => '18', | |
'name' => 'admin_edit', | |
'parent_id' => '14', | |
'lft' => '33', | |
'rght' => '34', | |
'level' => '2' | |
) | |
), | |
(int) 18 => array( | |
'NumberTree' => array( | |
'id' => '19', | |
'name' => 'admin_index', | |
'parent_id' => '14', | |
'lft' => '35', | |
'rght' => '36', | |
'level' => '2' | |
) | |
), | |
(int) 19 => array( | |
'NumberTree' => array( | |
'id' => '20', | |
'name' => 'admin_test', | |
'parent_id' => '14', | |
'lft' => '37', | |
'rght' => '38', | |
'level' => '2' | |
) | |
), | |
(int) 20 => array( | |
'NumberTree' => array( | |
'id' => '21', | |
'name' => 'admin_view', | |
'parent_id' => '14', | |
'lft' => '39', | |
'rght' => '40', | |
'level' => '2' | |
) | |
), | |
(int) 21 => array( | |
'NumberTree' => array( | |
'id' => '22', | |
'name' => 'login', | |
'parent_id' => '14', | |
'lft' => '41', | |
'rght' => '42', | |
'level' => '2' | |
) | |
), | |
(int) 22 => array( | |
'NumberTree' => array( | |
'id' => '23', | |
'name' => 'logout', | |
'parent_id' => '14', | |
'lft' => '43', | |
'rght' => '44', | |
'level' => '2' | |
) | |
), | |
(int) 23 => array( | |
'NumberTree' => array( | |
'id' => '24', | |
'name' => 'setup', | |
'parent_id' => '14', | |
'lft' => '45', | |
'rght' => '46', | |
'level' => '2' | |
) | |
) | |
) | |
########################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This test method was added to the bottom of lib/Cake/TestCase/Model/Behavior/TreeBehaviorNumberTest.php | |
public function testSaveRecursiveTree() { | |
extract($this->settings); | |
$this->Tree = new $modelClass(); | |
$this->Tree->Behaviors->attach('Tree', array('level' => 'level')); | |
$this->completeTreeSave(array( | |
'app' => array( | |
'GroupPermissions' => array( | |
'admin_add' => 0, | |
'admin_delete' => 1, | |
'admin_edit' => 2, | |
'admin_group' => 3, | |
'admin_index' => 4, | |
), | |
'Groups' => array( | |
'admin_acos' => 0, | |
'admin_add' => 1, | |
'admin_delete' => 2, | |
'admin_edit' => 3, | |
'admin_index' => 4, | |
), | |
'Members' => array( | |
'admin_acos' => 0, | |
'admin_add' => 1, | |
'admin_delete' => 2, | |
'admin_edit' => 3, | |
'admin_index' => 4, | |
'admin_test' => 5, | |
'admin_view' => 6, | |
'login' => 7, | |
'logout' => 8, | |
'setup' => 9, | |
), | |
), | |
)); | |
debug($this->Tree->find('all', ['order' => 'lft asc'])); | |
} | |
public function completeTreeSave($tree, $parent_id = null) { | |
if ($parent_id === null) { | |
$this->Tree->deleteAll('1=1'); | |
} | |
debug($tree); | |
foreach ($tree as $aro => $tre) { | |
$this->Tree->create(); | |
$this->Tree->save(array( | |
'parent_id' => $parent_id, | |
'alias' => $aro, | |
'name' => $aro, | |
)); | |
if (is_array($tre)) { | |
$this->completeTreeSave($tre, $this->Tree->id); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment