44 $this->paymentMock = $this->createPartialMock(
46 [
'getCcNumber',
'getCcCid',
'getMethodInstance',
'getAdditionalInformation']
48 $this->objectCopyMock = $this->createMock(\
Magento\Framework\
DataObject\Copy::class);
49 $this->orderPaymentRepositoryMock = $this->getMockForAbstractClass(
50 \
Magento\Sales\Api\OrderPaymentRepositoryInterface::class,
56 $this->dataObjectHelper = $this->createMock(\
Magento\Framework\Api\DataObjectHelper::class);
61 'orderPaymentRepository' => $this->orderPaymentRepositoryMock,
62 'objectCopyService' => $this->objectCopyMock,
63 'dataObjectHelper' => $this->dataObjectHelper
73 $methodInterface = $this->getMockForAbstractClass(\
Magento\
Payment\Model\MethodInterface::class);
75 $paymentData = [
'test' =>
'test2'];
76 $data = [
'some_id' => 1];
77 $paymentMethodTitle =
'TestTitle';
78 $additionalInfo = [
'token' =>
'TOKEN-123'];
80 $this->paymentMock->expects($this->once())->method(
'getMethodInstance')->willReturn($methodInterface);
81 $methodInterface->expects($this->once())->method(
'getTitle')->willReturn($paymentMethodTitle);
82 $this->objectCopyMock->expects($this->once())->method(
'getDataFromFieldset')->with(
83 'quote_convert_payment',
86 )->willReturn($paymentData);
88 $this->paymentMock->expects($this->once())
89 ->method(
'getAdditionalInformation')
90 ->willReturn($additionalInfo);
91 $ccNumber = 123456798;
93 $this->paymentMock->expects($this->once())
94 ->method(
'getCcNumber')
95 ->willReturn($ccNumber);
96 $this->paymentMock->expects($this->once())
100 $orderPayment = $this->getMockForAbstractClass(
101 \
Magento\Sales\Api\Data\OrderPaymentInterface::class,
107 [
'setCcNumber',
'setCcCid',
'setAdditionalInformation']
109 $orderPayment->expects($this->once())
110 ->method(
'setAdditionalInformation')
113 $orderPayment->expects($this->once())
114 ->method(
'setCcNumber')
116 $orderPayment->expects($this->once())
120 $this->orderPaymentRepositoryMock->expects($this->once())->method(
'create')->willReturn($orderPayment);
121 $this->dataObjectHelper->expects($this->once())
122 ->method(
'populateWithArray')
125 array_merge($paymentData,
$data),
126 \
Magento\Sales\Api\Data\OrderPaymentInterface::class
130 $this->assertSame($orderPayment, $this->converter->convert($this->paymentMock,
$data));
$orderPaymentRepositoryMock