/**
  * @param \PHPUnit_Framework_MockObject_MockObject|LineItem $existingLineItem
  * @param mixed $newNotes
  *
  * @dataProvider lineItemDataProvider
  */
 public function testProcessExistingLineItem($existingLineItem, $newNotes)
 {
     $this->request = Request::create('/', 'PUT');
     $this->addRegistryExpectations($existingLineItem);
     $this->form->expects($this->once())->method('submit')->with($this->request);
     $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $this->lineItem->expects($this->once())->method('getQuantity')->will($this->returnValue(40));
     $this->lineItem->expects($this->once())->method('getNotes')->will($this->returnValue($newNotes));
     $handler = new LineItemHandler($this->form, $this->request, $this->registry, $this->shoppingListManager);
     $this->assertTrue($handler->process($this->lineItem));
     $this->assertEquals(['savedId' => 123], $handler->updateSavedId([]));
 }
 /**
  * @param \PHPUnit_Framework_MockObject_MockObject|LineItem $existingLineItem
  * @param mixed $newNotes
  *
  * @dataProvider lineItemDataProvider
  */
 public function testProcessExistingLineItem($existingLineItem, $newNotes)
 {
     $this->request->expects($this->once())->method('getMethod')->will($this->returnValue('PUT'));
     $this->form->expects($this->once())->method('submit')->with($this->request);
     $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $this->lineItem->expects($this->once())->method('getQuantity')->will($this->returnValue(40));
     $this->lineItem->expects($this->once())->method('getNotes')->will($this->returnValue($newNotes));
     $repository = $this->getMockBuilder('OroB2B\\Bundle\\ShoppingListBundle\\Entity\\Repository\\LineItemRepository')->disableOriginalConstructor()->getMock();
     $repository->expects($this->once())->method('findDuplicate')->with($this->lineItem)->will($this->returnValue($existingLineItem));
     $manager = $this->getMock('Doctrine\\Common\\Persistence\\ObjectManager');
     $manager->expects($this->once())->method('getRepository')->with(self::LINE_ITEM_SHORTCUT)->will($this->returnValue($repository));
     $manager->expects($this->never())->method('persist');
     $manager->expects($this->once())->method('flush');
     $this->registry->expects($this->once())->method('getManagerForClass')->with(self::LINE_ITEM_SHORTCUT)->will($this->returnValue($manager));
     $handler = new LineItemHandler($this->form, $this->request, $this->registry);
     $this->assertTrue($handler->process($this->lineItem));
     $this->assertEquals(['savedId' => 123], $handler->updateSavedId([]));
 }