/** * @param int $id * @param array $collectionIds * @param $conditionType * @dataProvider getDataProvider */ public function testGet($id, array $collectionIds, $conditionType) { $filter = $this->getMock('Magento\\Framework\\Api\\Filter', ['getConditionType', 'getField', 'getValue'], [], '', false); $filter->expects($this->any())->method('getConditionType')->willReturn($conditionType); $this->filterBuilder->expects($this->once())->method('setField')->with('transaction_id')->willReturnSelf(); $this->filterBuilder->expects($this->once())->method('setValue')->with($id)->willReturnSelf(); $this->filterBuilder->expects($this->once())->method('setConditionType')->with('eq')->willReturnSelf(); $this->filterBuilder->expects($this->once())->method('create')->willReturn($filter); $filterGroup = $this->getMock('Magento\\Framework\\Api\\Search\\FilterGroup', [], [], '', false); $filterGroup->expects($this->any())->method('getFilters')->willReturn($filter); $searchCriteria = $this->getMock('Magento\\Framework\\Api\\SearchCriteria', [], [], '', false); $searchCriteria->expects($this->any())->method('getFilterGroups')->willReturn([$filterGroup]); $this->searchCriteriaBuilder->expects($this->once())->method('addFilter')->with([$filter]); $this->searchCriteriaBuilder->expects($this->once())->method('create')->willReturn($searchCriteria); $transactionModelMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Payment\\Transaction')->disableOriginalConstructor()->setMethods([])->getMock(); $transactionModelMock->expects($this->any())->method('getId')->will($this->returnValue($id)); $this->prepareCollection($transactionModelMock, $collectionIds); $this->assertSame($transactionModelMock, $this->transactionRepository->get($id)); }
/** * {@inheritdoc} */ public function get($id) { $transaction = $this->transactionRepository->get($id); return $this->transactionMapper->extractDto($transaction); }