/** * @depends testRemoveContent */ public function testAddCategory(ProductModel $product) { $categories = $product->getProductCategories(); $this->assertEquals(1, count($categories)); $defaultCategory = $categories->getFirst(); $category = CategoryQuery::create()->filterById($defaultCategory->getCategoryId(), Criteria::NOT_IN)->addAscendingOrderByColumn('RAND()')->findOne(); $event = new ProductAddCategoryEvent($product, $category->getId()); $event->setDispatcher($this->getDispatcher()); $action = new Product(); $action->addCategory($event); $product->clearProductCategories(); $newCategories = $product->getProductCategories(); $this->assertEquals(2, count($newCategories)); return array('product' => $product, 'category' => $category); }