/** * @return void */ public function execute() { $feedId = $this->getRequest()->getParam('type'); /** @var FeedInterface $feed */ $feed = $this->feedRepository->getById($feedId); $this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8'); $this->getResponse()->setBody($this->feedTransformer->toXml($feed)); }
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(); }