-
Notifications
You must be signed in to change notification settings - Fork 212
/
Copy pathSuccessTest.php
107 lines (91 loc) · 4.11 KB
/
SuccessTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/**
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2024 Adyen N.V. (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Test\Unit\Block\Checkout\Multishipping;
use Adyen\Payment\Block\Checkout\Multishipping\Success;
use Adyen\Payment\Helper\PaymentMethods;
use Adyen\Payment\Test\Unit\AbstractAdyenTestCase;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Api\SearchCriteriaInterface;
use Magento\Framework\Session\SessionManager;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Framework\View\Element\Template\Context;
use Magento\Sales\Api\Data\OrderAddressInterface;
use Magento\Sales\Api\Data\OrderSearchResultInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Sales\Model\Order;
class SuccessTest extends AbstractAdyenTestCase
{
private $successBlock;
private $contextMock;
private $sessionMock;
private $orderRepositoryMock;
private $searchCriteriaBuilderMock;
private $orderSearchResultMock;
private $orderMock;
private $paymentMock;
private $paymentMethodHelperMock;
const ORDER_BILLING_ADDRESS_COUNTRY = 'TR';
protected function setUp(): void
{
$this->sessionMock = $this->createGeneratedMock(SessionManager::class, [
'getOrderIds'
]);
$this->sessionMock->method('getOrderIds')->willReturn(['1' => 1, '2' => 2]);
$this->contextMock = $this->createMock(Context::class);
$this->contextMock->method('getSession')->willReturn($this->sessionMock);
$this->paymentMock = $this->createMock(Order\Payment::class);
$this->paymentMock->method('getMethod')->willReturn('adyen_cc');
$this->paymentMock->method('getAdditionalInformation')->willReturn([
'resultCode' => 'Authorised'
]);
$billingAddressMock = $this->createMock(OrderAddressInterface::class);
$billingAddressMock->method('getCountryId')->willReturn(self::ORDER_BILLING_ADDRESS_COUNTRY);
$this->orderMock = $this->createMock(Order::class);
$this->orderMock->method('getPayment')->willReturn($this->paymentMock);
$this->orderMock->method('getEntityId')->willReturn(1);
$this->orderMock->method('getBillingAddress')->willReturn($billingAddressMock);
$this->orderSearchResultMock = $this->createMock(OrderSearchResultInterface::class);
$this->orderSearchResultMock->method('getItems')->willReturn([$this->orderMock]);
$this->orderRepositoryMock = $this->createMock(OrderRepositoryInterface::class);
$this->orderRepositoryMock->method('getList')->willReturn($this->orderSearchResultMock);
$this->searchCriteriaBuilderMock = $this->createMock(SearchCriteriaBuilder::class);
$this->searchCriteriaBuilderMock->method('addFilter')->willReturnSelf();
$this->searchCriteriaBuilderMock->method('create')->willReturn(
$this->createMock(SearchCriteriaInterface::class)
);
$this->paymentMethodHelperMock = $this->createMock(PaymentMethods::class);
$this->paymentMethodHelperMock->method('isAdyenPayment')->willReturn(true);
$payments = [
['result_code' => 'Authorised'],
['result_code' => 'IdentifyShopper', 'action' => 'DUMMY_ACTION_OBJECT']
];
$objectManager = new ObjectManager($this);
$this->successBlock = $objectManager->getObject(Success::class, [
'paymentResponseEntities' => $payments,
'context' => $this->contextMock,
'orderRepository' => $this->orderRepositoryMock,
'searchCriteriaBuilder' => $this->searchCriteriaBuilderMock,
'paymentMethodsHelper' => $this->paymentMethodHelperMock
]);
}
public function testRenderAction()
{
$result = $this->successBlock->renderAction();
$this->assertTrue($result);
}
public function testBillingCountryCodeSetterGetter()
{
$this->assertEquals(
self::ORDER_BILLING_ADDRESS_COUNTRY,
$this->successBlock->getBillingCountryCode()
);
}
}