Beispiel #1
0
 /**
  * @depends testAddCategory
  */
 public function testRemoveCategory(array $productCategory)
 {
     $product = $productCategory['product'];
     $category = $productCategory['category'];
     $product->clearProductCategories();
     $this->assertEquals(2, count($product->getProductCategories()));
     $event = new ProductDeleteCategoryEvent($product, $category->getId());
     $event->setDispatcher($this->getDispatcher());
     $action = new Product();
     $action->removeCategory($event);
     $product->clearProductCategories();
     $this->assertEquals(1, count($product->getProductCategories()));
     return $product;
 }
Beispiel #2
0
 public function removeCategory(ProductDeleteCategoryEvent $event)
 {
     $productCategory = ProductCategoryQuery::create()->filterByProduct($event->getProduct())->filterByCategoryId($event->getCategoryId())->findOne();
     if ($productCategory != null) {
         $productCategory->delete();
     }
 }