Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function search(SearchCriteria $searchCriteria)
 {
     $transactions = [];
     foreach ($this->transactionRepository->find($searchCriteria) as $transaction) {
         $transactions[] = $this->transactionMapper->extractDto($transaction, true);
     }
     return $this->searchResultsBuilder->setItems($transactions)->setTotalCount(count($transactions))->setSearchCriteria($searchCriteria)->create();
 }
Exemple #2
0
 public function testSearch()
 {
     /**
      * @var \Magento\Framework\Service\V1\Data\SearchCriteria $searchCriteria
      */
     $searchCriteria = $this->getMock('Magento\\Framework\\Service\\V1\\Data\\SearchCriteria', [], [], '', false);
     $transactions = $this->getMock('Magento\\Sales\\Model\\Order\\Payment\\Transaction', [], [], '', false);
     $transactionDto = $this->getMock('Magento\\Sales\\Service\\V1\\Data\\Transaction', [], [], '', false);
     $searchResults = $this->getMock('Magento\\Sales\\Service\\V1\\Data\\TransactionSearchResults', [], [], '', false);
     $this->transactionRepositoryMock->expects($this->once())->method('find')->with($searchCriteria)->will($this->returnValue([$transactions]));
     $this->transactionMapperMock->expects($this->once())->method('extractDto')->with($transactions, true)->will($this->returnValue($transactionDto));
     $this->searchResultsBuilderMock->expects($this->once())->method('setItems')->with([$transactionDto])->willReturnSelf();
     $this->searchResultsBuilderMock->expects($this->once())->method('setTotalCount')->with(1)->willReturnSelf();
     $this->searchResultsBuilderMock->expects($this->once())->method('setSearchCriteria')->with($searchCriteria)->willReturnSelf();
     $this->searchResultsBuilderMock->expects($this->once())->method('create')->willReturn($searchResults);
     $this->assertEquals($searchResults, $this->transactionRead->search($searchCriteria));
 }
Exemple #3
0
 public function testFind()
 {
     list($id, $collectionIds, $filterData) = [1, [1], ['field', 'value', 'lteq']];
     $transactionModelMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Payment\\Transaction')->disableOriginalConstructor()->setMethods([])->getMock();
     $transactionModelMock->expects($this->any())->method('getId')->will($this->returnValue($id));
     $collection = $this->prepareCollection($transactionModelMock, $collectionIds);
     $searchCriteriaMock = $this->getMock('Magento\\Framework\\Api\\SearchCriteria', [], [], '', false);
     $filterGroup = $this->getMock('Magento\\Framework\\Api\\Search\\FilterGroup', [], [], '', false);
     $filter = $this->getMock('Magento\\Framework\\Api\\Filter', [], [], '', false);
     $searchCriteriaMock->expects($this->once())->method('getFilterGroups')->will($this->returnValue([$filterGroup]));
     $filterGroup->expects($this->once())->method('getFilters')->will($this->returnValue([$filter]));
     $filter->expects($this->once())->method('getField')->will($this->returnValue($filterData[0]));
     $filter->expects($this->once())->method('getValue')->will($this->returnValue($filterData[1]));
     $filter->expects($this->any())->method('getConditionType')->will($this->returnValue($filterData[2]));
     $collection->expects($this->once())->method('addFieldToFilter')->with($filterData[0], [$filterData[2] => $filterData[1]]);
     $collection->expects($this->once())->method('addPaymentInformation')->with(['method']);
     $collection->expects($this->once())->method('addOrderInformation')->with(['increment_id']);
     $this->assertSame([$id => $transactionModelMock], $this->transactionRepository->find($searchCriteriaMock));
 }