/** * @param ObjectManager $manager * @param ShoppingList $shoppingList * @param ProductUnit $unit * @param Product $product * @param string $referenceName */ protected function createLineItem(ObjectManager $manager, ShoppingList $shoppingList, ProductUnit $unit, Product $product, $referenceName) { $item = new LineItem(); $item->setNotes('Test Notes'); $item->setAccountUser($shoppingList->getAccountUser()); $item->setOrganization($shoppingList->getOrganization()); $item->setShoppingList($shoppingList); $item->setUnit($unit); $item->setProduct($product); $item->setQuantity(23.15); $manager->persist($item); $this->addReference($referenceName, $item); }
/** * @return array */ public function submitDataProvider() { $product = $this->getProductEntityWithPrecision(1, 'kg', 3); $defaultLineItem = new LineItem(); $defaultLineItem->setProduct($product); /** @var ShoppingList $expectedShoppingList */ $expectedShoppingList = $this->getShoppingList(1, 'Shopping List 1'); $expectedLineItem = clone $defaultLineItem; $expectedLineItem->setQuantity(15.112)->setUnit($product->getUnitPrecision('kg')->getUnit())->setShoppingList($expectedShoppingList); return ['New line item with existing shopping list' => ['defaultData' => $defaultLineItem, 'submittedData' => ['shoppingList' => 1, 'quantity' => 15.1119, 'unit' => 'kg', 'shoppingListLabel' => null], 'expectedData' => $expectedLineItem]]; }