File tree 4 files changed +70
-0
lines changed
4 files changed +70
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,44 @@ public function testCreateIdealPayment()
77
77
);
78
78
}
79
79
80
+ /**
81
+ * @magentoDataFixture Magento/Sales/_files/order.php
82
+ */
83
+ public function testCreatePaypalPayment ()
84
+ {
85
+ $ magentoOrder = $ this ->loadOrderById ('100000001 ' );
86
+ $ magentoOrder = $ this ->addCurrencyToOrder ($ magentoOrder );
87
+
88
+ $ cmOrderFactory = $ this ->objectManager ->create (OrderInterfaceFactory::class);
89
+ $ cmOrderOrder = $ cmOrderFactory ->create ();
90
+ $ cmOrderRepository = $ this ->objectManager ->get (CMOrderRepositoryInterface::class);
91
+ $ cmOrderOrder ->setIncrementId ($ magentoOrder ->getIncrementId ());
92
+ $ cmOrderOrder ->setOrderId ((int )$ magentoOrder ->getEntityId ());
93
+ $ cmOrderOrder ->setOrderKey ('0287A1617D93780EF28044B98438BF2F ' );
94
+ $ cmOrderRepository ->save ($ cmOrderOrder );
95
+
96
+ $ this ->clientMock ->expects ($ this ->once ())->method ('execute ' )->willReturn (
97
+ [
98
+ 'id ' => 'pid4911261016t ' ,
99
+ 'status ' => 'REDIRECTED_FOR_AUTHORIZATION ' ,
100
+ 'urls ' => [
101
+ 0 => [
102
+ 'purpose ' => 'REDIRECT ' ,
103
+ 'method ' => 'GET ' ,
104
+ //phpcs:ignore
105
+ 'url ' => 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&useraction=commit&token=EC-0HD94326F3768884E ' ,
106
+ 'order ' => 1 ,
107
+ ],
108
+ ]
109
+ ]
110
+ );
111
+
112
+ $ payment = $ this ->paymentService ->create ($ magentoOrder ->getId ());
113
+ $ this ->assertNotNull (
114
+ $ payment ->getId ()
115
+ );
116
+ }
117
+
80
118
/**
81
119
* @param string $orderId
82
120
* @return OrderInterface
Original file line number Diff line number Diff line change @@ -18,10 +18,12 @@ class ConfigTest extends UnitTestCase
18
18
* @var StoreManager|\PHPUnit\Framework\MockObject\MockObject
19
19
*/
20
20
private $ storeManagerMock ;
21
+
21
22
/**
22
23
* @var ScopeConfigInterface|\PHPUnit\Framework\MockObject\MockObject
23
24
*/
24
25
private $ scopeConfigMock ;
26
+
25
27
/**
26
28
* @var Config
27
29
*/
Original file line number Diff line number Diff line change @@ -15,10 +15,12 @@ class CurrencyValidatorTest extends UnitTestCase
15
15
* @var \PHPUnit\Framework\MockObject\MockObject
16
16
*/
17
17
private $ resultMock ;
18
+
18
19
/**
19
20
* @var \Magento\Payment\Gateway\ConfigInterface|\PHPUnit\Framework\MockObject\MockObject
20
21
*/
21
22
private $ configMock ;
23
+
22
24
/**
23
25
* @var CurrencyValidator
24
26
*/
Original file line number Diff line number Diff line change @@ -113,6 +113,34 @@ public function testCreateIdealPayment()
113
113
);
114
114
}
115
115
116
+ public function testCreatePaypalPayment ()
117
+ {
118
+ $ this ->paymentClientMock ->expects ($ this ->once ())->method ('create ' )->willReturn (
119
+ new \CM \Payments \Client \Model \Response \PaymentCreate (
120
+ [
121
+ 'id ' => 'pid4911261016t ' ,
122
+ 'status ' => 'REDIRECTED_FOR_AUTHORIZATION ' ,
123
+ 'urls ' => [
124
+ 0 => [
125
+ 'purpose ' => 'REDIRECT ' ,
126
+ 'method ' => 'GET ' ,
127
+ //phpcs:ignore
128
+ 'url ' => 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&useraction=commit&token=EC-0HD94326F3768884E ' ,
129
+ 'order ' => 1 ,
130
+ ],
131
+ ]
132
+ ]
133
+ )
134
+ );
135
+
136
+ $ order = $ this ->getOrderMock ();
137
+ $ payment = $ this ->paymentService ->create ((string )$ order ->getEntityId ());
138
+
139
+ $ this ->assertNotNull (
140
+ $ payment ->getId ()
141
+ );
142
+ }
143
+
116
144
public function testEventDispatch ()
117
145
{
118
146
$ paymentCreateResponse = new \CM \Payments \Client \Model \Response \PaymentCreate (
You can’t perform that action at this time.
0 commit comments