Skip to content

Commit eb8ca78

Browse files
author
Ivan Tagil
authored
Merge pull request #31 from Itonomy/feature/CMP-70_paypal-tests
CMP-70 -PayPal tests
2 parents c7e77c2 + a820cfc commit eb8ca78

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed

Test/Integration/Service/PaymentServiceTest.php

+38
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,44 @@ public function testCreateIdealPayment()
7777
);
7878
}
7979

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+
80118
/**
81119
* @param string $orderId
82120
* @return OrderInterface

Test/Unit/Config/ConfigTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ class ConfigTest extends UnitTestCase
1818
* @var StoreManager|\PHPUnit\Framework\MockObject\MockObject
1919
*/
2020
private $storeManagerMock;
21+
2122
/**
2223
* @var ScopeConfigInterface|\PHPUnit\Framework\MockObject\MockObject
2324
*/
2425
private $scopeConfigMock;
26+
2527
/**
2628
* @var Config
2729
*/

Test/Unit/Gateway/Validator/CurrencyValidatorTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ class CurrencyValidatorTest extends UnitTestCase
1515
* @var \PHPUnit\Framework\MockObject\MockObject
1616
*/
1717
private $resultMock;
18+
1819
/**
1920
* @var \Magento\Payment\Gateway\ConfigInterface|\PHPUnit\Framework\MockObject\MockObject
2021
*/
2122
private $configMock;
23+
2224
/**
2325
* @var CurrencyValidator
2426
*/

Test/Unit/Service/PaymentServiceTest.php

+28
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,34 @@ public function testCreateIdealPayment()
113113
);
114114
}
115115

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+
116144
public function testEventDispatch()
117145
{
118146
$paymentCreateResponse = new \CM\Payments\Client\Model\Response\PaymentCreate(

0 commit comments

Comments
 (0)