Skip to content

Commit 9245810

Browse files
committed
MC-17592: End-to-end integration to test order with Payflow Link
- review comments and static fix
1 parent 39cc246 commit 9245810

File tree

1 file changed

+18
-37
lines changed

1 file changed

+18
-37
lines changed

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

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,14 @@
1212
use Magento\Framework\Serialize\SerializerInterface;
1313
use Magento\GraphQl\Controller\GraphQl;
1414
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
15-
use Magento\Paypal\Model\Payflow\Request;
16-
use Magento\Paypal\Model\Payflow\Service\Gateway;
1715
use Magento\Quote\Model\Quote;
1816
use Magento\TestFramework\Helper\Bootstrap;
1917
use Magento\Framework\UrlInterface;
2018
use Magento\TestFramework\ObjectManager;
21-
use PHPUnit\Framework\MockObject\MockObject;
2219
use PHPUnit\Framework\TestCase;
2320

2421
/**
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
2623
*
2724
* @magentoAppArea graphql
2825
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -48,12 +45,6 @@ class SetPaymentMethodAsPayflowLinkTest extends TestCase
4845
/** @var GraphQl */
4946
protected $graphqlController;
5047

51-
/** @var Gateway|MockObject */
52-
private $gateway;
53-
54-
/** @var Request|MockObject */
55-
private $payflowRequest;
56-
5748
protected function setUp()
5849
{
5950
parent::setUp();
@@ -63,21 +54,6 @@ protected function setUp()
6354
$this->json = $this->objectManager->get(SerializerInterface::class);
6455
$this->getMaskedQuoteIdByReservedOrderId = $this->objectManager->get(GetMaskedQuoteIdByReservedOrderId::class);
6556
$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);
8157
}
8258

8359
/**
@@ -114,9 +90,9 @@ public function testSetPayflowLinkAsPaymentMethod(): void
11490
additional_data: {
11591
payflow_link:
11692
{
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"
12096
}
12197
}
12298
}
@@ -153,10 +129,18 @@ public function testSetPayflowLinkAsPaymentMethod(): void
153129

154130
$quote->load('test_quote', 'reserved_order_id');
155131
$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+
);
160144
}
161145

162146
/**
@@ -180,9 +164,6 @@ public function testInvalidUrl(): void
180164
$paymentMethod = 'payflow_link';
181165
$cartId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
182166

183-
$url = $this->objectManager->get(UrlInterface::class);
184-
$baseUrl = $url->getBaseUrl();
185-
186167
$query
187168
= <<<QUERY
188169
mutation {
@@ -193,8 +174,8 @@ public function testInvalidUrl(): void
193174
additional_data: {
194175
payflow_link:
195176
{
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"
198179
error_url:"/not/a/validUrl"
199180
}
200181
}

0 commit comments

Comments
 (0)