public function testHandleSaveNoWid() { $message = 'Saved'; $form = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock(); $entity = new \stdClass(); $handler = $this->getMockBuilder('Oro\\Bundle\\FormBundle\\Tests\\Unit\\Form\\Stub\\HandlerStub')->getMock(); $handler->expects($this->once())->method('process')->with($entity)->will($this->returnValue(true)); $flashBag = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBagInterface')->getMock(); $flashBag->expects($this->once())->method('add')->with('success', $message); $this->session->expects($this->once())->method('getFlashBag')->will($this->returnValue($flashBag)); $saveAndStayRoute = array('route' => 'test_update'); $saveAndCloseRoute = array('route' => 'test_view'); $expected = array('redirect' => true); $this->router->expects($this->once())->method('redirectAfterSave')->with($saveAndStayRoute, $saveAndCloseRoute, $entity)->will($this->returnValue($expected)); $result = $this->handler->handleUpdate($entity, $form, $saveAndStayRoute, $saveAndCloseRoute, $message, $handler); $this->assertEquals($expected, $result); }
public function testHandleSaveNoWid() { $queryParameters = ['qwe' => 'rty']; $this->request->query = new ParameterBag($queryParameters); $message = 'Saved'; /** @var \PHPUnit_Framework_MockObject_MockObject|Form $form */ $form = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock(); $entity = $this->getObject(); $handler = $this->getMockBuilder('Oro\\Bundle\\FormBundle\\Tests\\Unit\\Form\\Stub\\HandlerStub')->getMock(); $handler->expects($this->once())->method('process')->with($entity)->will($this->returnValue(true)); $flashBag = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBagInterface')->getMock(); $flashBag->expects($this->once())->method('add')->with('success', $message); $this->session->expects($this->once())->method('getFlashBag')->will($this->returnValue($flashBag)); $saveAndStayRoute = ['route' => 'test_update']; $saveAndCloseRoute = ['route' => 'test_view']; $expected = ['redirect' => true]; $this->router->expects($this->once())->method('redirectAfterSave')->with(array_merge($saveAndStayRoute, ['parameters' => $queryParameters]), array_merge($saveAndCloseRoute, ['parameters' => $queryParameters]), $entity)->will($this->returnValue($expected)); $result = $this->handler->handleUpdate($entity, $form, $saveAndStayRoute, $saveAndCloseRoute, $message, $handler); $this->assertEquals($expected, $result); }