Skip to content

Commit 096b288

Browse files
committed
MC-17592: End-to-end integration to test order with Payflow Link
- addressing review comments
1 parent 97fb174 commit 096b288

File tree

4 files changed

+33
-17
lines changed

4 files changed

+33
-17
lines changed

dev/tests/integration/testsuite/Magento/Paypal/_files/order_payflow_link_with_payment_rollback.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@
55
*/
66

77
use Magento\TestFramework\Helper\Bootstrap;
8+
use Magento\Sales\Model\ResourceModel\Order\Collection;
9+
use Magento\Framework\Registry;
10+
11+
$objectManager = Bootstrap::getObjectManager();
812

913
/** @var \Magento\Framework\Registry $registry */
10-
$registry = Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class);
14+
$registry = Bootstrap::getObjectManager()->get(Registry::class);
1115
$registry->unregister('isSecureArea');
1216
$registry->register('isSecureArea', true);
1317

1418
/** @var $order \Magento\Sales\Model\Order */
15-
$orderCollection = Bootstrap::getObjectManager()->create(\Magento\Sales\Model\ResourceModel\Order\Collection::class);
19+
$orderCollection = $objectManager->create(Collection::class);
1620
foreach ($orderCollection as $order) {
1721
$order->delete();
1822
}

dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/GetPayflowLinkTokenTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Magento\TestFramework\Helper\Bootstrap;
1818
use Magento\TestFramework\ObjectManager;
1919
use PHPUnit\Framework\TestCase;
20+
use Zend\Http\Headers;
2021

2122
/**
2223
* Test getPayflowLinkToken graphql endpoint for non-registered customer
@@ -47,7 +48,6 @@ class GetPayflowLinkTokenTest extends TestCase
4748

4849
protected function setUp()
4950
{
50-
parent::setUp();
5151
$this->objectManager = Bootstrap::getObjectManager();
5252
$this->getMaskedQuoteIdByReservedOrderId = $this->objectManager->get(GetMaskedQuoteIdByReservedOrderId::class);
5353
$this->graphqlController = $this->objectManager->get(GraphQl::class);
@@ -74,8 +74,8 @@ public function testResolvePayflowLinkToken() : void
7474
{
7575
getPayflowLinkToken(input: {cart_id:"$cartId"})
7676
{
77-
secret_token
78-
secret_token_id
77+
secure_token
78+
secure_token_id
7979
mode
8080
paypal_url
8181
}
@@ -86,7 +86,7 @@ public function testResolvePayflowLinkToken() : void
8686
$this->request->setPathInfo('/graphql');
8787
$this->request->setMethod('POST');
8888
$this->request->setContent($postData);
89-
$headers = $this->objectManager->create(\Zend\Http\Headers::class)
89+
$headers = $this->objectManager->create(Headers::class)
9090
->addHeaders(['Content-Type' => 'application/json']);
9191
$this->request->setHeaders($headers);
9292
$response = $this->graphqlController->dispatch($this->request);
@@ -96,8 +96,8 @@ public function testResolvePayflowLinkToken() : void
9696

9797
$payflowLinkTokenResponse = $responseData['data']['getPayflowLinkToken'];
9898

99-
$this->assertArrayHasKey('secret_token', $payflowLinkTokenResponse);
100-
$this->assertArrayHasKey('secret_token_id', $payflowLinkTokenResponse);
99+
$this->assertArrayHasKey('secure_token', $payflowLinkTokenResponse);
100+
$this->assertArrayHasKey('secure_token_id', $payflowLinkTokenResponse);
101101

102102
$this->assertEquals('TEST', $payflowLinkTokenResponse['mode']);
103103
$this->assertEquals('https://pilot-payflowlink.paypal.com', $payflowLinkTokenResponse['paypal_url']);

dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PlaceOrderWithPayflowLinkTest.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Magento\TestFramework\ObjectManager;
2424
use PHPUnit\Framework\MockObject\MockObject;
2525
use PHPUnit\Framework\TestCase;
26+
use Zend\Http\Headers;
2627

2728
/**
2829
* End to end place order test using payflow_link via graphql endpoint for guest
@@ -78,7 +79,21 @@ protected function setUp()
7879

7980
$this->payflowRequest = $this->getMockBuilder(\Magento\Paypal\Model\Payflow\Request::class)
8081
->disableOriginalConstructor()
82+
->setMethods(['__call','setData'])
8183
->getMock();
84+
$this->payflowRequest->expects($this->any())
85+
->method('__call')
86+
->will(
87+
$this->returnCallback(
88+
function ($method) {
89+
if (strpos($method, 'set') === 0) {
90+
return $this->payflowRequest;
91+
}
92+
return null;
93+
}
94+
)
95+
);
96+
8297
$requestFactory->expects($this->any())->method('create')->will($this->returnValue($this->payflowRequest));
8398
$this->objectManager->addSharedInstance($this->gateway, Gateway::class);
8499
}
@@ -161,7 +176,7 @@ public function testResolvePlaceOrderWithPayflowLink(): void
161176
->method('postRequest')
162177
->willReturn($payflowLinkResponse);
163178

164-
$this->payflowRequest->expects($this->any())
179+
$this->payflowRequest
165180
->method('setData')
166181
->willReturnMap(
167182
[
@@ -177,7 +192,7 @@ public function testResolvePlaceOrderWithPayflowLink(): void
177192
$this->returnSelf()
178193
],
179194
['USER1', 1, $this->returnSelf()],
180-
['USER2', '4b102efb018ad34bacea669f401fc8cb', $this->returnSelf()]
195+
['USER2', 'USER2SilentPostHash', $this->returnSelf()]
181196
);
182197

183198
$response = $this->graphqlController->dispatch($this->request);
@@ -260,13 +275,13 @@ public function testResolveWithPayflowLinkDeclined(): void
260275
$this->request->setPathInfo('/graphql');
261276
$this->request->setMethod('POST');
262277
$this->request->setContent($postData);
263-
$headers = $this->objectManager->create(\Zend\Http\Headers::class)
278+
$headers = $this->objectManager->create(Headers::class)
264279
->addHeaders(['Content-Type' => 'application/json']);
265280
$this->request->setHeaders($headers);
266281

267282
$resultCode = Payflowlink::RESPONSE_CODE_DECLINED_BY_FILTER;
268283
$exception = new LocalizedException(__('Declined response message from PayPal gateway'));
269-
$this->payflowRequest->expects($this->any())
284+
$this->payflowRequest
270285
->method('setData')
271286
->with(
272287
[
@@ -280,7 +295,7 @@ public function testResolveWithPayflowLinkDeclined(): void
280295

281296
]
282297
]
283-
);
298+
)->willReturnSelf();
284299
$this->gateway->method('postRequest')
285300
/** @var DataObject $linkRequest */
286301
->with(

dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/SetPaymentMethodAsPayflowLinkTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class SetPaymentMethodAsPayflowLinkTest extends TestCase
4343
protected $objectManager;
4444

4545
/** @var GraphQl */
46-
protected $graphqlController;
46+
private $graphqlController;
4747

4848
protected function setUp()
4949
{
@@ -77,9 +77,6 @@ public function testSetPayflowLinkAsPaymentMethod(): void
7777
$paymentMethod = 'payflow_link';
7878
$cartId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
7979

80-
$url = $this->objectManager->get(UrlInterface::class);
81-
$baseUrl = $url->getBaseUrl();
82-
8380
$query
8481
= <<<QUERY
8582
mutation {

0 commit comments

Comments
 (0)