12
12
use Magento \Framework \Serialize \SerializerInterface ;
13
13
use Magento \GraphQl \Controller \GraphQl ;
14
14
use Magento \GraphQl \Quote \GetMaskedQuoteIdByReservedOrderId ;
15
- use Magento \Paypal \Model \Payflow \Request ;
16
- use Magento \Paypal \Model \Payflow \Service \Gateway ;
17
15
use Magento \Quote \Model \Quote ;
18
16
use Magento \TestFramework \Helper \Bootstrap ;
19
17
use Magento \Framework \UrlInterface ;
20
18
use Magento \TestFramework \ObjectManager ;
21
- use PHPUnit \Framework \MockObject \MockObject ;
22
19
use PHPUnit \Framework \TestCase ;
23
20
24
21
/**
25
- * End to end place order test using payflow_link via graphql endpoint for guest
22
+ * Test SetPayment method for payflow_link and validate the additional information
26
23
*
27
24
* @magentoAppArea graphql
28
25
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -48,12 +45,6 @@ class SetPaymentMethodAsPayflowLinkTest extends TestCase
48
45
/** @var GraphQl */
49
46
protected $ graphqlController ;
50
47
51
- /** @var Gateway|MockObject */
52
- private $ gateway ;
53
-
54
- /** @var Request|MockObject */
55
- private $ payflowRequest ;
56
-
57
48
protected function setUp ()
58
49
{
59
50
parent ::setUp ();
@@ -63,21 +54,6 @@ protected function setUp()
63
54
$ this ->json = $ this ->objectManager ->get (SerializerInterface::class);
64
55
$ this ->getMaskedQuoteIdByReservedOrderId = $ this ->objectManager ->get (GetMaskedQuoteIdByReservedOrderId::class);
65
56
$ this ->graphqlController = $ this ->objectManager ->get (GraphQl::class);
66
- $ this ->gateway = $ this ->getMockBuilder (Gateway::class)
67
- ->disableOriginalConstructor ()
68
- ->setMethods (['postRequest ' ])
69
- ->getMock ();
70
-
71
- $ requestFactory = $ this ->getMockBuilder (\Magento \Paypal \Model \Payflow \RequestFactory::class)
72
- ->setMethods (['create ' ])
73
- ->disableOriginalConstructor ()
74
- ->getMock ();
75
-
76
- $ this ->payflowRequest = $ this ->getMockBuilder (\Magento \Paypal \Model \Payflow \Request::class)
77
- ->disableOriginalConstructor ()
78
- ->getMock ();
79
- $ requestFactory ->expects ($ this ->any ())->method ('create ' )->will ($ this ->returnValue ($ this ->payflowRequest ));
80
- $ this ->objectManager ->addSharedInstance ($ this ->gateway , Gateway::class);
81
57
}
82
58
83
59
/**
@@ -114,9 +90,9 @@ public function testSetPayflowLinkAsPaymentMethod(): void
114
90
additional_data: {
115
91
payflow_link:
116
92
{
117
- return_url:" { $ baseUrl } paypal/payflow/returnUrl "
118
- cancel_url:" { $ baseUrl } paypal/payflow/cancelPayment "
119
- error_url:" { $ baseUrl } paypal/payflow/errorUrl "
93
+ return_url:"http://magento.com/ paypal/payflow/link/success "
94
+ cancel_url:"http://magento.com/ paypal/payflow/link/cancel "
95
+ error_url:"http://magento.com/ paypal/payflow/link/error "
120
96
}
121
97
}
122
98
}
@@ -153,10 +129,18 @@ public function testSetPayflowLinkAsPaymentMethod(): void
153
129
154
130
$ quote ->load ('test_quote ' , 'reserved_order_id ' );
155
131
$ payment = $ quote ->getPayment ();
156
- $ actualPaymentAdditionalInformation = $ payment ->getAdditionalInformation ('payflow_link ' );
157
- $ this ->assertEquals ("{$ baseUrl }paypal/payflow/cancelPayment " , $ payment ->getAdditionalInformation ('cancel_url ' ));
158
- $ this ->assertEquals ("{$ baseUrl }paypal/payflow/returnUrl " , $ payment ->getAdditionalInformation ('return_url ' ));
159
- $ this ->assertEquals ("{$ baseUrl }paypal/payflow/errorUrl " , $ payment ->getAdditionalInformation ('error_url ' ));
132
+ $ this ->assertEquals (
133
+ "http://magento.com/paypal/payflow/link/cancel " ,
134
+ $ payment ->getAdditionalInformation ('cancel_url ' )
135
+ );
136
+ $ this ->assertEquals (
137
+ "http://magento.com/paypal/payflow/link/success " ,
138
+ $ payment ->getAdditionalInformation ('return_url ' )
139
+ );
140
+ $ this ->assertEquals (
141
+ "http://magento.com/paypal/payflow/link/error " ,
142
+ $ payment ->getAdditionalInformation ('error_url ' )
143
+ );
160
144
}
161
145
162
146
/**
@@ -180,9 +164,6 @@ public function testInvalidUrl(): void
180
164
$ paymentMethod = 'payflow_link ' ;
181
165
$ cartId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_quote ' );
182
166
183
- $ url = $ this ->objectManager ->get (UrlInterface::class);
184
- $ baseUrl = $ url ->getBaseUrl ();
185
-
186
167
$ query
187
168
= <<<QUERY
188
169
mutation {
@@ -193,8 +174,8 @@ public function testInvalidUrl(): void
193
174
additional_data: {
194
175
payflow_link:
195
176
{
196
- return_url:" { $ baseUrl } paypal/payflow/returnUrl "
197
- cancel_url:" { $ baseUrl } paypal/payflow/cancelPayment "
177
+ return_url:"http://magento.com/ paypal/payflow/link/sucess "
178
+ cancel_url:"http://magento.com/ paypal/payflow/link/cancel "
198
179
error_url:"/not/a/validUrl"
199
180
}
200
181
}
0 commit comments