public function testProcessExistingShoppingList() { $this->shoppingList->expects($this->once())->method('getId')->willReturn(1); $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)); /** @var \PHPUnit_Framework_MockObject_MockObject|ObjectManager $manager */ $manager = $this->getMock('Doctrine\\Common\\Persistence\\ObjectManager'); $manager->expects($this->once())->method('persist'); $manager->expects($this->once())->method('flush'); $this->registry->expects($this->once())->method('getManagerForClass')->with(self::SHOPPING_LIST_SHORTCUT)->will($this->returnValue($manager)); $handler = new ShoppingListHandler($this->form, $this->request, $this->manager, $this->registry); $this->assertTrue($handler->process($this->shoppingList)); }