Example #1
0
 /**
  * @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));
 }
Example #2
0
 public function testGetFeeds()
 {
     $feeds = ['feed1', 'feed2'];
     $searchCriteria = $this->getMockBuilder('\\Magento\\Framework\\Api\\SearchCriteria')->disableOriginalConstructor()->getMock();
     $this->searchCriteriaBuilder->expects($this->once())->method('create')->willReturn($searchCriteria);
     $searchResult = $this->getMockBuilder('\\Magento\\SampleServiceContractNew\\API\\Data\\FeedSearchResultInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $searchResult->expects($this->once())->method('getItems')->willReturn($feeds);
     $this->feedRepository->expects($this->once())->method('getList')->willReturn($searchResult);
     $this->assertEquals($feeds, $this->block->getFeeds());
 }
Example #3
0
 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();
 }
Example #4
0
 /**
  * @return \Magento\SampleServiceContractNew\API\Data\FeedInterface[]
  */
 public function getFeeds()
 {
     $searchCriteria = $this->searchCriteriaBuilder->create();
     $searchResult = $this->feedRepository->getList($searchCriteria);
     return $searchResult->getItems();
 }