Ejemplo n.º 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();
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 3
0
 /**
  * @dataProvider lazyDataProvider
  * @param bool $lazy
  */
 public function testExtractDto($lazy)
 {
     list($id, $data) = [1, []];
     $transactionModelMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Payment\\Transaction')->disableOriginalConstructor()->setMethods([])->getMock();
     $transactionDtoMock = $this->getMockBuilder('Magento\\Sales\\Service\\V1\\Data\\Transaction')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->prepareTransactionOrder($transactionModelMock, $id);
     $transactionModelMock->expects($this->once())->method('getData')->will($this->returnValue($data));
     $this->transactionBuilderMock->expects($this->once())->method('populateWithArray')->with($data);
     $transactionModelMock->expects($this->once())->method('getAdditionalInformation')->will($this->returnValue([]));
     $this->transactionBuilderMock->expects($this->once())->method('setAdditionalInformation')->with([]);
     $this->transactionBuilderMock->expects($this->once())->method('setIncrementId')->with($id);
     $transactionModelMock->expects($this->any())->method('getChildTransactions')->will($this->returnValue([]));
     $this->transactionBuilderMock->expects($this->once())->method('setChildTransactions')->with([]);
     $this->transactionBuilderMock->expects($this->once())->method('create')->will($this->returnValue($transactionDtoMock));
     $this->assertSame($transactionDtoMock, $this->transactionMapper->extractDto($transactionModelMock, $lazy));
 }
 /**
  * @dataProvider lazyDataProvider
  * @param bool $lazy
  */
 public function testExtractDto($lazy)
 {
     $id = 1;
     $transactionModelMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Payment\\Transaction')->disableOriginalConstructor()->setMethods([])->getMock();
     $transactionDtoMock = $this->getMockBuilder('Magento\\Sales\\Service\\V1\\Data\\Transaction')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->prepareTransactionOrder($transactionModelMock, $id);
     $this->transactionBuilderMock->expects($this->once())->method('setTransactionId');
     $this->transactionBuilderMock->expects($this->once())->method('setParentId');
     $this->transactionBuilderMock->expects($this->once())->method('setOrderId');
     $this->transactionBuilderMock->expects($this->once())->method('setTxnId');
     $this->transactionBuilderMock->expects($this->once())->method('setPaymentId');
     $this->transactionBuilderMock->expects($this->once())->method('setParentTxnId');
     $this->transactionBuilderMock->expects($this->once())->method('setTxnType');
     $this->transactionBuilderMock->expects($this->once())->method('setIsClosed');
     $this->transactionBuilderMock->expects($this->once())->method('setCreatedAt');
     $this->transactionBuilderMock->expects($this->once())->method('setMethod');
     $transactionModelMock->expects($this->once())->method('getAdditionalInformation')->will($this->returnValue([]));
     $this->transactionBuilderMock->expects($this->once())->method('setAdditionalInformation')->with([]);
     $this->transactionBuilderMock->expects($this->once())->method('setIncrementId')->with($id);
     $transactionModelMock->expects($this->any())->method('getChildTransactions')->will($this->returnValue([]));
     $this->transactionBuilderMock->expects($this->once())->method('setChildTransactions')->with([]);
     $this->transactionBuilderMock->expects($this->once())->method('create')->will($this->returnValue($transactionDtoMock));
     $this->assertSame($transactionDtoMock, $this->transactionMapper->extractDto($transactionModelMock, $lazy));
 }