/** * @return Basket|\Symfony\Component\Form\FormInterface */ private function handleForm() { $item = new Basket(); $item->setOwner($this->user); $form = $this->formFactory->createNamed('', $this->type, $item); $form->handleRequest($this->stack->getCurrentRequest()); if ($form->isValid()) { $this->repository->add($item); $this->postCreate($item); return $item; } return $form; }
/** * @Given /^basket item with "([^"]*)" products exists$/ */ public function basketItemWithProductsExists($quantity) { $product = $this->getParameterBag()->get('product'); $user = $this->getParameterBag()->get('user'); $basketItem = new Basket(); $basketItem->setProduct($product); $basketItem->setQuantity($quantity); $basketItem->setOwner($user); $this->getEntityManager()->persist($basketItem); $this->getEntityManager()->flush(); $this->getParameterBag()->set('basket', $basketItem); }