public function testChildrenMethodReturnsCollection()
 {
     $category = new Category();
     $this->assertInstanceOf('Illuminate\\Support\\Collection', $category->children());
 }
Exemplo n.º 2
0
 /**
  * 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;
 }