public function testHasChildrenReturnsBool() { $category = new Category(); $this->assertFalse($category->hasChildren()); $child = new Category(['id' => 1]); $category->addChild($child); $this->assertTrue($category->hasChildren()); }
/** * Hydrate the documents of a category * * @param CobwebInfo\Cobra5Sdk\Entity\Category $category * @return CobwebInfo\Cobra5Sdk\Entity\Category */ protected function hydrateDocuments(Category $category) { if ($category->hasChildren()) { foreach ($category->children() as $child) { $documents = $this->getDocumentsForCategory($child); if ($documents) { foreach ($documents as $document) { $child->addDocument($document); } } } return $category; } $documents = $this->getDocumentsForCategory($category); if ($documents) { foreach ($documents as $document) { $category->addDocument($document); } } return $category; }