public function testExecute() { $type = 'sampleType'; $feed = $this->getMockBuilder('Magento\\SampleServiceContractNew\\API\\Data\\FeedInterface')->getMockForAbstractClass(); $xml = 'xmlDataString'; $this->request->expects($this->once())->method('getParam')->with('type')->willReturn($type); $this->feedRepository->expects($this->once())->method('getById')->with($type)->willReturn($feed); $this->response->expects($this->once())->method('setHeader')->with('Content-type', 'text/xml; charset=UTF-8')->willReturnSelf(); $this->feedTransformer->expects($this->once())->method('toXml')->with($feed)->willReturn($xml); $this->response->expects($this->once())->method('setBody')->with($xml)->willReturnSelf(); $this->controller->execute(); }