@@ -36,7 +36,13 @@ class ToOrderPaymentTest extends \PHPUnit_Framework_TestCase
36
36
37
37
public function setUp ()
38
38
{
39
- $ this ->paymentMock = $ this ->getMock ('Magento\Quote\Model\Quote\Payment ' , [], [], '' , false );
39
+ $ this ->paymentMock = $ this ->getMock (
40
+ 'Magento\Quote\Model\Quote\Payment ' ,
41
+ ['getCcNumber ' , 'getCcCid ' , 'getMethodInstance ' , 'getAdditionalInformation ' ],
42
+ [],
43
+ '' ,
44
+ false
45
+ );
40
46
$ this ->objectCopyMock = $ this ->getMock ('Magento\Framework\Object\Copy ' , [], [], '' , false );
41
47
$ this ->orderPaymentBuilderMock = $ this ->getMock (
42
48
'Magento\Sales\Api\Data\OrderPaymentDataBuilder ' ,
@@ -61,10 +67,19 @@ public function setUp()
61
67
public function testConvert ()
62
68
{
63
69
$ methodInterface = $ this ->getMock ('Magento\Payment\Model\MethodInterface ' , [], [], '' , false );
64
- $ orderPayment = $ this ->getMock ('Magento\Sales\Api\Data\OrderPaymentInterface ' , [], [], '' , false );
70
+ $ orderPayment = $ this ->getMockForAbstractClass (
71
+ 'Magento\Sales\Api\Data\OrderPaymentInterface ' ,
72
+ [],
73
+ '' ,
74
+ false ,
75
+ true ,
76
+ true ,
77
+ ['setCcNumber ' , 'setCcCid ' ]
78
+ );
65
79
$ paymentData = ['test ' => 'test2 ' ];
66
80
$ data = ['some_id ' => 1 ];
67
81
$ paymentMethodTitle = 'TestTitle ' ;
82
+ $ additionalInfo = ['token ' => 'TOKEN-123 ' ];
68
83
$ this ->paymentMock ->expects ($ this ->once ())->method ('getMethodInstance ' )->willReturn ($ methodInterface );
69
84
$ methodInterface ->expects ($ this ->once ())->method ('getTitle ' )->willReturn ($ paymentMethodTitle );
70
85
$ this ->objectCopyMock ->expects ($ this ->once ())->method ('getDataFromFieldset ' )->with (
@@ -77,11 +92,31 @@ public function testConvert()
77
92
->with (array_merge ($ paymentData , $ data ))
78
93
->willReturnSelf ();
79
94
95
+ $ this ->paymentMock ->expects ($ this ->once ())
96
+ ->method ('getAdditionalInformation ' )
97
+ ->willReturn ($ additionalInfo );
98
+ $ ccNumber = 123456798 ;
99
+ $ ccCid = 1234 ;
100
+ $ this ->paymentMock ->expects ($ this ->once ())
101
+ ->method ('getCcNumber ' )
102
+ ->willReturn ($ ccNumber );
103
+ $ this ->paymentMock ->expects ($ this ->once ())
104
+ ->method ('getCcCid ' )
105
+ ->willReturn ($ ccCid );
106
+
80
107
$ this ->orderPaymentBuilderMock ->expects ($ this ->once ())
81
108
->method ('setAdditionalInformation ' )
82
- ->with (serialize ([Substitution::INFO_KEY_TITLE => $ paymentMethodTitle ]))
109
+ ->with (serialize (array_merge ( $ additionalInfo , [Substitution::INFO_KEY_TITLE => $ paymentMethodTitle ]) ))
83
110
->willReturnSelf ();
84
111
$ this ->orderPaymentBuilderMock ->expects ($ this ->once ())->method ('create ' )->willReturn ($ orderPayment );
112
+ $ orderPayment ->expects ($ this ->once ())
113
+ ->method ('setCcNumber ' )
114
+ ->with ($ ccNumber )
115
+ ->willReturnSelf ();
116
+ $ orderPayment ->expects ($ this ->once ())
117
+ ->method ('setCcCid ' )
118
+ ->with ($ ccCid )
119
+ ->willReturnSelf ();
85
120
$ this ->assertSame ($ orderPayment , $ this ->converter ->convert ($ this ->paymentMock , $ data ));
86
121
}
87
122
}
0 commit comments