Example #1
0
 public function testChildCategoryAccessors()
 {
     $category = new Category();
     $this->assertEmpty($category->getChildCategories()->toArray());
     $firstCategory = new Category();
     $firstCategory->setLevel(1);
     $secondCategory = new Category();
     $secondCategory->setLevel(2);
     $category->addChildCategory($firstCategory)->addChildCategory($secondCategory)->addChildCategory($secondCategory);
     $this->assertEquals([$firstCategory, $secondCategory], array_values($category->getChildCategories()->toArray()));
     $category->removeChildCategory($firstCategory)->removeChildCategory($firstCategory);
     $this->assertEquals([$secondCategory], array_values($category->getChildCategories()->toArray()));
 }