/** * test case for api call if post values are not there * * @covers AppBundle\Controller\DemoController::indexAction */ public function testindexActionPostFails() { $defaultData = array('message' => 'Enter City Name Or Country Name For Weather'); $this->mockController->expects($this->once())->method('createFormBuilder')->with($this->equalTo($defaultData))->will($this->returnValue($this->mockFormBuilder)); $this->mockFormBuilder->expects($this->at(0))->method('add')->with($this->equalTo('countryname'), $this->equalTo('text'))->will($this->returnValue($this->mockFormBuilder)); $this->mockFormBuilder->expects($this->at(1))->method('add')->with($this->equalTo('cityname'), $this->equalTo('text'))->will($this->returnValue($this->mockFormBuilder)); $this->mockFormBuilder->expects($this->at(2))->method('add')->with($this->equalTo('search'), $this->equalTo('submit'))->will($this->returnValue($this->mockFormBuilder)); $this->mockFormBuilder->expects($this->once())->method('getForm')->will($this->returnValue($this->mockForm)); $this->mockRequest->expects($this->once())->method('isMethod')->with($this->equalTo('POST'))->will($this->returnValue(false)); $this->mockController->expects($this->once())->method('render')->with($this->equalTo('AppBundle:Demo:show.html.twig'), $this->equalTo(array('form' => ''))); $this->mockController->indexAction($this->mockRequest); }