示例#1
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());
 }
示例#2
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();
 }