From b4c12fccd3f920763d07d92b35d721823a675b34 Mon Sep 17 00:00:00 2001 From: Jevgenij Liachovic Date: Tue, 2 Dec 2014 14:47:08 +0200 Subject: [PATCH] Changed usage of DocumentTrait attributes from public to setters/getters. --- Service/CategoryService.php | 10 +++++----- Tests/Unit/Service/CategoryServiceTest.php | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Service/CategoryService.php b/Service/CategoryService.php index c98df41..5927630 100755 --- a/Service/CategoryService.php +++ b/Service/CategoryService.php @@ -100,7 +100,7 @@ private function buildChildNode($node, $references, $maxLevel) if ($maxLevel == 0 || $level <= $maxLevel) { $node->setLevel($level); $node->setParent($references[$node->getParentId()]); - $references[$node->getParentId()]->setChild($node, $node->id); + $references[$node->getParentId()]->setChild($node, $node->getId()); } } } @@ -129,7 +129,7 @@ public function getCategory($id) private function buildRootNode($node, $tree, $level) { $node->setLevel($level); - $tree[$node->id] = $node; + $tree[$node->getId()] = $node; } /** @@ -142,12 +142,12 @@ private function buildRootNode($node, $tree, $level) */ private function buildNode($node, $references, $tree, $maxLevel) { - if ($node->id == $this->getCurrentCategoryId()) { + if ($node->getId() == $this->getCurrentCategoryId()) { $node->setCurrent(true); $this->currentLeaf = $node; } - $references[$node->id] = $node; + $references[$node->getId()] = $node; if ($node->getParentId() == self::ROOT_CATEGORY_ID) { $this->buildRootNode($node, $tree, 1); @@ -306,7 +306,7 @@ protected function findPartialTree($tree, $categoryId) { /** @var CategoryTrait|DocumentTrait $node */ foreach ($tree as $node) { - if ($node->id == $categoryId) { + if ($node->getId() == $categoryId) { return [$node]; } if ($node->getChildren()) { diff --git a/Tests/Unit/Service/CategoryServiceTest.php b/Tests/Unit/Service/CategoryServiceTest.php index 08d86c1..acde7af 100644 --- a/Tests/Unit/Service/CategoryServiceTest.php +++ b/Tests/Unit/Service/CategoryServiceTest.php @@ -172,7 +172,7 @@ public function testSetGetCurrentCategoryId() protected function buildCategory($category) { $cat = new Category(); - $cat->id = $category['id']; + $cat->setId($category['id']); $cat->setActive($category['is_active']); $cat->setSort($category['sort']); $cat->setLeft($category['left']); @@ -359,6 +359,7 @@ public function testGetCurrentCategoryDocument(array $data) $expected = $data['cat42']; $expected->setCurrent(true); $expected->setExpanded(true); + $expected->getParent()->setExpanded(true); $leaf = $service->getCurrentCategoryDocument();