Skip to content

Commit 8e0a482

Browse files
author
Mike Weis
committed
MAGETWO-33664: Refactor Sales module to use mutable data object interfaces
- fix unit test
1 parent 689ed44 commit 8e0a482

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

dev/tests/unit/testsuite/Magento/Quote/Model/Quote/Payment/ToOrderPaymentTest.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,12 @@ public function setUp()
6969
public function testConvert()
7070
{
7171
$methodInterface = $this->getMock('Magento\Payment\Model\MethodInterface', [], [], '', false);
72-
$orderPayment = $this->getMockForAbstractClass(
73-
'Magento\Sales\Api\Data\OrderPaymentInterface',
74-
[],
75-
'',
76-
false,
77-
true,
78-
true,
79-
['setCcNumberEnc', 'setCcCidEnc', 'setAdditionalInformation']
80-
);
72+
8173
$paymentData = ['test' => 'test2'];
8274
$data = ['some_id' => 1];
8375
$paymentMethodTitle = 'TestTitle';
8476
$additionalInfo = ['token' => 'TOKEN-123'];
77+
8578
$this->paymentMock->expects($this->once())->method('getMethodInstance')->willReturn($methodInterface);
8679
$methodInterface->expects($this->once())->method('getTitle')->willReturn($paymentMethodTitle);
8780
$this->objectCopyMock->expects($this->once())->method('getDataFromFieldset')->with(
@@ -99,28 +92,35 @@ public function testConvert()
9992
->willReturn($additionalInfo);
10093
$ccNumber = 123456798;
10194
$ccCid = 1234;
102-
$this->paymentMock->expects($this->once())
95+
$this->paymentMock->expects($this->any())
10396
->method('getCcNumber')
10497
->willReturn($ccNumber);
105-
$this->paymentMock->expects($this->once())
106-
->method('getCcCidEnc')
98+
$this->paymentMock->expects($this->any())
99+
->method('getCcCid')
107100
->willReturn($ccCid);
108101

109-
$this->orderPaymentFactoryMock->expects($this->once())->method('create')->willReturn($orderPayment);
110-
102+
$orderPayment = $this->getMockForAbstractClass(
103+
'Magento\Sales\Api\Data\OrderPaymentInterface',
104+
[],
105+
'',
106+
false,
107+
true,
108+
true,
109+
['setCcNumber', 'setCcCid', 'setAdditionalInformation']
110+
);
111111
$orderPayment->expects($this->once())
112112
->method('setAdditionalInformation')
113113
->with(serialize(array_merge($additionalInfo, [Substitution::INFO_KEY_TITLE => $paymentMethodTitle])))
114114
->willReturnSelf();
115-
$orderPayment->expects($this->once())
116-
->method('setCcNumberEnc')
117-
->with($ccNumber)
115+
$orderPayment->expects($this->any())
116+
->method('setCcNumber')
118117
->willReturnSelf();
119-
$orderPayment->expects($this->once())
120-
->method('setCcCidEnc')
121-
->with($ccCid)
118+
$orderPayment->expects($this->any())
119+
->method('setCcCid')
122120
->willReturnSelf();
123121

122+
$this->orderPaymentFactoryMock->expects($this->once())->method('create')->willReturn($orderPayment);
123+
124124
$this->assertSame($orderPayment, $this->converter->convert($this->paymentMock, $data));
125125
}
126126
}

0 commit comments

Comments
 (0)