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\ResourceModel; |
28
|
|
|
|
29
|
|
|
use Payone\Core\Helper\Toolkit; |
30
|
|
|
use Payone\Core\Model\ResourceModel\TransactionStatus as ClassToTest; |
31
|
|
|
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; |
32
|
|
|
use Payone\Core\Helper\Shop; |
33
|
|
|
use Magento\Quote\Api\Data\AddressInterface; |
34
|
|
|
use Magento\Framework\Model\ResourceModel\Db\Context; |
35
|
|
|
use Magento\Framework\App\ResourceConnection; |
36
|
|
|
use Magento\Framework\DB\Adapter\AdapterInterface; |
37
|
|
|
use Magento\Store\Model\StoreManagerInterface; |
38
|
|
|
use Magento\Store\Api\Data\StoreInterface; |
39
|
|
|
use Magento\Framework\App\Action\Context as ActionContext; |
40
|
|
|
use Magento\Framework\App\Request\Http; |
41
|
|
|
|
42
|
|
|
class TransactionStatusTest extends \PHPUnit_Framework_TestCase |
43
|
|
|
{ |
44
|
|
|
/** |
45
|
|
|
* @var ClassToTest |
46
|
|
|
*/ |
47
|
|
|
private $classToTest; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var ObjectManager |
51
|
|
|
*/ |
52
|
|
|
private $objectManager; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var AddressInterface|\PHPUnit_Framework_MockObject_MockObject |
56
|
|
|
*/ |
57
|
|
|
private $address; |
|
|
|
|
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @var Shop|\PHPUnit_Framework_MockObject_MockObject |
61
|
|
|
*/ |
62
|
|
|
private $shopHelper; |
|
|
|
|
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject |
66
|
|
|
*/ |
67
|
|
|
private $connection; |
68
|
|
|
|
69
|
|
View Code Duplication |
protected function setUp() |
|
|
|
|
70
|
|
|
{ |
71
|
|
|
$this->objectManager = new ObjectManager($this); |
72
|
|
|
|
73
|
|
|
$store = $this->getMockBuilder(StoreInterface::class)->disableOriginalConstructor()->getMock(); |
74
|
|
|
$store->method('getId')->willReturn('15'); |
75
|
|
|
|
76
|
|
|
$storeManager = $this->getMockBuilder(StoreManagerInterface::class)->disableOriginalConstructor()->getMock(); |
77
|
|
|
$storeManager->method('getStore')->willReturn($store); |
78
|
|
|
|
79
|
|
|
$this->connection = $this->getMockBuilder(AdapterInterface::class)->disableOriginalConstructor()->getMock(); |
80
|
|
|
|
81
|
|
|
$resource = $this->getMockBuilder(ResourceConnection::class)->disableOriginalConstructor()->getMock(); |
82
|
|
|
$resource->method('getConnection')->willReturn($this->connection); |
83
|
|
|
|
84
|
|
|
$context = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock(); |
85
|
|
|
$context->method('getResources')->willReturn($resource); |
86
|
|
|
|
87
|
|
|
$toolkitHelper = $this->getMockBuilder(Toolkit::class)->disableOriginalConstructor()->getMock(); |
88
|
|
|
$toolkitHelper->method('isUTF8')->willReturn(false); |
89
|
|
|
|
90
|
|
|
$this->classToTest = $this->objectManager->getObject(ClassToTest::class, [ |
91
|
|
|
'context' => $context, |
92
|
|
|
'storeManager' => $storeManager, |
93
|
|
|
'toolkitHelper' => $toolkitHelper |
94
|
|
|
]); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function testAddTransactionLogEntry() |
98
|
|
|
{ |
99
|
|
|
$post = 15; |
100
|
|
|
|
101
|
|
|
$request = $this->getMockBuilder(Http::class) |
102
|
|
|
->disableOriginalConstructor() |
103
|
|
|
->setMethods(['getPostValue', 'getParam']) |
104
|
|
|
->getMock(); |
105
|
|
|
$request->method('getPostValue')->willReturn($post); |
106
|
|
|
$request->method('getParam')->willReturn(15); |
107
|
|
|
|
108
|
|
|
$context = $this->getMockBuilder(ActionContext::class)->disableOriginalConstructor()->getMock(); |
109
|
|
|
$context->method('getRequest')->willReturn($request); |
110
|
|
|
|
111
|
|
|
$result = $this->classToTest->addTransactionLogEntry($context); |
112
|
|
|
$this->assertInstanceOf(ClassToTest::class, $result); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function testGetParam() |
116
|
|
|
{ |
117
|
|
|
$expected = 'default'; |
118
|
|
|
$result = $this->classToTest->getParam('key', $expected); |
119
|
|
|
$this->assertEquals($expected, $result); |
120
|
|
|
} |
121
|
|
|
} |
122
|
|
|
|
This check marks private properties in classes that are never used. Those properties can be removed.