Skip to content
Permalink
Browse files

Alias order field in findTreeList().

  • Loading branch information...
ADmad committed Dec 3, 2016
1 parent ae2099f commit 073a1278f12e5e0375167fdc27b37a106fd1851b
Showing with 12 additions and 2 deletions.
  1. +3 −1 src/ORM/Behavior/TreeBehavior.php
  2. +9 −1 tests/TestCase/ORM/Behavior/TreeBehaviorTest.php
@@ -483,10 +483,12 @@ function ($field) {
*/
public function findTreeList(Query $query, array $options)
{
$left = $this->_table->aliasField($this->config('left'));
$results = $this->_scope($query)
->find('threaded', [
'parentField' => $this->config('parent'),
'order' => [$this->config('left') => 'ASC'],
'order' => [$left => 'ASC'],
]);
return $this->formatTreeList($results, $options);
@@ -256,7 +256,15 @@ public function testFindTreeList()
{
$table = TableRegistry::get('MenuLinkTrees');
$table->addBehavior('Tree', ['scope' => ['menu' => 'main-menu']]);
$result = $table->find('treeList')->toArray();
$query = $table->find('treeList');
$result = null;
$query->clause('order')->iterateParts(function ($dir, $field) use (&$result) {
$result = $field;
});
$this->assertEquals('MenuLinkTrees.lft', $result);
$result = $query->toArray();
$expected = [
1 => 'Link 1',
2 => '_Link 2',

0 comments on commit 073a127

Please sign in to comment.
You can’t perform that action at this time.