1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 12:48:24 +01: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:
Nick Liu 2020-01-18 12:06:52 +01:00
parent d6eafdc3fc
commit a1560b1989
No known key found for this signature in database
GPG Key ID: 1167C5F9C9897637
2 changed files with 6 additions and 6 deletions

View File

@ -3519,7 +3519,7 @@ class e_tree_model extends e_front_model
foreach($tree as $item)
{
$children = $item['_children'];
$children = isset($item['_children']) ? $item['_children'] : null;
unset($item['_children']);
$item['_depth'] = $depth;
if($depth > 0)

View File

@ -52,11 +52,11 @@ class TreeModelTest extends \Codeception\Test\Unit
{
$key = $this->sample_key;
$parent_key = $this->sample_parent_key;
$l0_id = $this->tree[1][$key];
$l1_id = $this->tree[1]['_children'][0][$key];
$l1_parent = $this->tree[1]['_children'][0][$parent_key];
$l2_id = $this->tree[1]['_children'][0]['_children'][0][$key];
$l2_parent = $this->tree[1]['_children'][0]['_children'][0][$parent_key];
$l0_id = $this->tree[0][$key];
$l1_id = $this->tree[0]['_children'][0][$key];
$l1_parent = $this->tree[0]['_children'][0][$parent_key];
$l2_id = $this->tree[0]['_children'][0]['_children'][0][$key];
$l2_parent = $this->tree[0]['_children'][0]['_children'][0][$parent_key];
$this->assertEquals($l0_id, $l1_parent);
$this->assertEquals($l1_id, $l2_parent);