public function testRemoveIngredient() { $productService = new ProductService($this->entityManager); $product = new Product(); $product->setProductname("Paine"); $product->setPrice(4.3); $product->setAdition(10); $product->setPieces(100); $ingredient = new Ingredient(); $ingredient->setIngredientname("Faina"); $producer = new Producer(); $producer->setProducername("Velpitar"); $productService->insertProduct($product); $productService->addIngredient($product->getId(), $ingredient); $aux = $productService->getProductById(1); $ingredients = $aux->getIdingredient(); $this->assertCount(1, $ingredients); $productService->removeIngredient($product, $ingredient); $aux = $productService->getProductById(1); $ingredients = $aux->getIdingredient(); $this->assertCount(0, $ingredients); }
public function updateStockProcessAction($offset) { $productName = $_POST['productName']; $hits = Product::getLuceneIndex()->find($productName); $pks = array(); foreach ($hits as $hit) { $pks[] = $hit->pk; } $productService = $this->get('product_service'); $products = array(); for ($i = 0; $i < sizeof($pks); $i++) { $productObject = $productService->getProductById($pks[$i]); $products[$i] = $productObject; } $limit = 7; $midrange = 3; $itemsCount = sizeof($products); $resultProducts = array(); $n = $offset * $limit; for ($i = $offset * $limit - $limit; $i < $n && $i < $itemsCount; $i++) { $resultProducts[$i] = $products[$i]; } $paginator = new StockManagerPaginator($itemsCount, $offset, $limit, $midrange); return $this->render('MainStockManagerBundle:Pages/Admin:viewSearchProduct.html.twig', array('products' => $resultProducts, 'paginator' => $paginator)); }