1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify |
5
|
|
|
* it under the terms of the GNU Lesser General Public License as published by |
6
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
7
|
|
|
* (at your option) any later version. |
8
|
|
|
* |
9
|
|
|
* PAYONE Magento 2 Connector is distributed in the hope that it will be useful, |
10
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
11
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12
|
|
|
* GNU Lesser General Public License for more details. |
13
|
|
|
* |
14
|
|
|
* You should have received a copy of the GNU Lesser General Public License |
15
|
|
|
* along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>. |
16
|
|
|
* |
17
|
|
|
* PHP version 5 |
18
|
|
|
* |
19
|
|
|
* @category Payone |
20
|
|
|
* @package Payone_Magento2_Plugin |
21
|
|
|
* @author FATCHIP GmbH <[email protected]> |
22
|
|
|
* @copyright 2003 - 2017 Payone GmbH |
23
|
|
|
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License |
24
|
|
|
* @link http://www.payone.de |
25
|
|
|
*/ |
26
|
|
|
|
27
|
|
|
namespace Payone\Core\Test\Unit\Model\Config; |
28
|
|
|
|
29
|
|
|
use Payone\Core\Model\Config\Export as ClassToTest; |
30
|
|
|
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; |
31
|
|
|
use Payone\Core\Helper\ConfigExport; |
32
|
|
|
use Payone\Core\Model\ChecksumCheck; |
33
|
|
|
use Magento\Store\Model\StoreManagerInterface; |
34
|
|
|
use Payone\Core\Helper\Payment; |
35
|
|
|
use Payone\Core\Model\PayoneConfig; |
36
|
|
|
use Payone\Core\Model\Risk\Addresscheck; |
37
|
|
|
use Magento\Store\Api\Data\StoreInterface; |
38
|
|
|
use Payone\Core\Helper\Shop; |
39
|
|
|
use Payone\Core\Test\Unit\BaseTestCase; |
40
|
|
|
use Payone\Core\Model\Test\PayoneObjectManager; |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
class ExportTest extends BaseTestCase |
44
|
|
|
{ |
45
|
|
|
/** |
46
|
|
|
* @var ClassToTest |
47
|
|
|
*/ |
48
|
|
|
private $classToTest; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var ObjectManager|PayoneObjectManager |
52
|
|
|
*/ |
53
|
|
|
private $objectManager; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var ChecksumCheck|\PHPUnit_Framework_MockObject_MockObject |
57
|
|
|
*/ |
58
|
|
|
private $checksumCheck; |
59
|
|
|
|
60
|
|
|
protected function setUp() |
61
|
|
|
{ |
62
|
|
|
$this->objectManager = $this->getObjectManager(); |
63
|
|
|
|
64
|
|
|
$configExportHelper = $this->getMockBuilder(ConfigExport::class)->disableOriginalConstructor()->getMock(); |
65
|
|
|
$configExportHelper->method('getModuleInfo')->willReturn(['Test_Module' => '1.2.3']); |
66
|
|
|
$configExportHelper->method('getConfigParam')->willReturn('value'); |
67
|
|
|
$configExportHelper->method('getMappings')->willReturn([ |
68
|
|
|
'cc' => [ |
69
|
|
|
['from' => 'appointed', 'to' => 'pending'] |
70
|
|
|
] |
71
|
|
|
]); |
72
|
|
|
$configExportHelper->method('getPaymentConfig')->willReturn('value'); |
73
|
|
|
$configExportHelper->method('getCountries')->willReturn('DE,AT'); |
74
|
|
|
$configExportHelper->method('getForwardings')->willReturn([ |
75
|
|
|
['status' => 'appointed', 'url' => 'http://testdomain.org', 'timeout' => '45'] |
76
|
|
|
]); |
77
|
|
|
|
78
|
|
|
$this->checksumCheck = $this->getMockBuilder(ChecksumCheck::class)->disableOriginalConstructor()->getMock(); |
79
|
|
|
|
80
|
|
|
$store = $this->getMockBuilder(StoreInterface::class)->disableOriginalConstructor()->getMock(); |
81
|
|
|
$store->method('getName')->willReturn('Testshop'); |
82
|
|
|
$stores = ['1' => $store]; |
83
|
|
|
$storeManager = $this->getMockBuilder(StoreManagerInterface::class)->disableOriginalConstructor()->getMock(); |
84
|
|
|
$storeManager->method('getStores')->willReturn($stores); |
85
|
|
|
|
86
|
|
|
$paymentHelper = $this->getMockBuilder(Payment::class)->disableOriginalConstructor()->getMock(); |
87
|
|
|
$paymentHelper->method('getAvailablePaymentTypes')->willReturn([PayoneConfig::METHOD_CREDITCARD]); |
88
|
|
|
$paymentHelper->method('getPaymentAbbreviation')->willReturn('cc'); |
89
|
|
|
|
90
|
|
|
$addresscheck = $this->getMockBuilder(Addresscheck::class)->disableOriginalConstructor()->getMock(); |
91
|
|
|
$addresscheck->method('getPersonstatusMapping')->willReturn(['ABC' => 'G', 'NONE' => 'R']); |
92
|
|
|
|
93
|
|
|
$shopHelper = $this->getMockBuilder(Shop::class)->disableOriginalConstructor()->getMock(); |
94
|
|
|
$shopHelper->method('getMagentoVersion')->willReturn('2.0.0'); |
95
|
|
|
$shopHelper->method('getMagentoEdition')->willReturn('CE'); |
96
|
|
|
$shopHelper->method('getConfigParam')->willReturn('value'); |
97
|
|
|
|
98
|
|
|
$this->classToTest = $this->objectManager->getObject(ClassToTest::class, [ |
99
|
|
|
'shopHelper' => $shopHelper, |
100
|
|
|
'configExportHelper' => $configExportHelper, |
101
|
|
|
'checksumCheck' => $this->checksumCheck, |
102
|
|
|
'storeManager' => $storeManager, |
103
|
|
|
'paymentHelper' => $paymentHelper, |
104
|
|
|
'addresscheck' => $addresscheck |
105
|
|
|
]); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
public function testHandleForwardings() |
109
|
|
|
{ |
110
|
|
|
$this->checksumCheck->method('getChecksumErrors')->willReturn(false); |
111
|
|
|
|
112
|
|
|
$result = $this->classToTest->generateConfigExportXml(); |
113
|
|
|
$this->assertNotEmpty($result); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
public function testHandleForwardingsChecksumError() |
117
|
|
|
{ |
118
|
|
|
$this->checksumCheck->method('getChecksumErrors')->willReturn(['Something is wrong']); |
119
|
|
|
|
120
|
|
|
$result = $this->classToTest->generateConfigExportXml(); |
121
|
|
|
$this->assertNotEmpty($result); |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|