/** * Rebuilds the path for a single category * * @param int $categoryId * @param String $categoryPath * @return int */ public function rebuildPath($categoryId, $categoryPath = null) { $updateStmt = $this->connection->prepare('UPDATE s_categories set path = :path WHERE id = :categoryId'); $parents = $this->categoryDenormalization->getParentCategoryIds($categoryId); array_shift($parents); if (empty($parents)) { $path = null; } else { $path = implode('|', $parents); $path = '|' . $path . '|'; } if ($categoryPath != $path) { $updateStmt->execute(array(':path' => $path, ':categoryId' => $categoryId)); return 1; } return 0; }
public function testGetParentCategoryIdsForRootLevelReturnsEmptyArray() { $expectedResult = array(); $result = $this->component->getParentCategoryIds(1); $this->assertEquals($expectedResult, $result); }