public function testGetAllProducts() { $product = $this->mockProduct(); $this->assertCount(2, $product->getIdingredient()); $this->assertEquals("Velpitar", $product->getIdproducer()->getProducername()); $this->mockEntityManager(); $productService = new ProductService($this->em); $this->assertEquals($this->mockProduct(), $productService->getProductById(1)); $this->assertCount(2, $productService->getProductById(1)->getIdingredient()); $this->assertCount(3, $productService->getAllProducts()); //$this->assertCount(4,$productService->insertProduct($this->mockProduct())); }
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); }