/** * @param ShoppingList $shoppingList * * @return bool */ public function process(ShoppingList $shoppingList) { $this->form->setData($shoppingList); if (in_array($this->request->getMethod(), ['POST', 'PUT'], true)) { $this->form->submit($this->request); if ($this->form->isValid()) { if ($shoppingList->getId() === null) { $this->manager->setCurrent($shoppingList->getAccountUser(), $shoppingList); } else { $em = $this->doctrine->getManagerForClass('OroB2BShoppingListBundle:ShoppingList'); $em->persist($shoppingList); $em->flush(); } return true; } } return false; }
public function testCreateCurrent() { $this->manager->setCurrent((new AccountUser())->setFirstName('setCurrent'), $this->shoppingListTwo); $this->assertTrue($this->shoppingListTwo->isCurrent()); $this->assertFalse($this->shoppingListOne->isCurrent()); }