mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 20:00:37 +02:00
Strict fixes for e_tree_model::flattenTree()
- FIX: Null check during child recursion of e_tree_model::flattenTree() - FIX: TreeModelTest::testTreeParentsAreAssignedCorrectly() apparently never worked until now because the wrong index was used
This commit is contained in:
@@ -3519,7 +3519,7 @@ class e_tree_model extends e_front_model
|
|||||||
|
|
||||||
foreach($tree as $item)
|
foreach($tree as $item)
|
||||||
{
|
{
|
||||||
$children = $item['_children'];
|
$children = isset($item['_children']) ? $item['_children'] : null;
|
||||||
unset($item['_children']);
|
unset($item['_children']);
|
||||||
$item['_depth'] = $depth;
|
$item['_depth'] = $depth;
|
||||||
if($depth > 0)
|
if($depth > 0)
|
||||||
|
@@ -52,11 +52,11 @@ class TreeModelTest extends \Codeception\Test\Unit
|
|||||||
{
|
{
|
||||||
$key = $this->sample_key;
|
$key = $this->sample_key;
|
||||||
$parent_key = $this->sample_parent_key;
|
$parent_key = $this->sample_parent_key;
|
||||||
$l0_id = $this->tree[1][$key];
|
$l0_id = $this->tree[0][$key];
|
||||||
$l1_id = $this->tree[1]['_children'][0][$key];
|
$l1_id = $this->tree[0]['_children'][0][$key];
|
||||||
$l1_parent = $this->tree[1]['_children'][0][$parent_key];
|
$l1_parent = $this->tree[0]['_children'][0][$parent_key];
|
||||||
$l2_id = $this->tree[1]['_children'][0]['_children'][0][$key];
|
$l2_id = $this->tree[0]['_children'][0]['_children'][0][$key];
|
||||||
$l2_parent = $this->tree[1]['_children'][0]['_children'][0][$parent_key];
|
$l2_parent = $this->tree[0]['_children'][0]['_children'][0][$parent_key];
|
||||||
|
|
||||||
$this->assertEquals($l0_id, $l1_parent);
|
$this->assertEquals($l0_id, $l1_parent);
|
||||||
$this->assertEquals($l1_id, $l2_parent);
|
$this->assertEquals($l1_id, $l2_parent);
|
||||||
|
Reference in New Issue
Block a user