This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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\Helper; |
||
28 | |||
29 | use Payone\Core\Helper\Payment; |
||
30 | use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; |
||
31 | use Magento\Store\Model\StoreManagerInterface; |
||
32 | use Magento\Store\Api\Data\StoreInterface; |
||
33 | use Magento\Framework\App\Helper\Context; |
||
34 | use Magento\Store\Model\ScopeInterface; |
||
35 | use Magento\Framework\App\Config\ScopeConfigInterface; |
||
36 | use Payone\Core\Model\PayoneConfig; |
||
37 | use Payone\Core\Helper\Toolkit; |
||
38 | use Payone\Core\Test\Unit\BaseTestCase; |
||
39 | use Payone\Core\Model\Test\PayoneObjectManager; |
||
40 | |||
41 | class PaymentTest extends BaseTestCase |
||
42 | { |
||
43 | /** |
||
44 | * @var ObjectManager|PayoneObjectManager |
||
45 | */ |
||
46 | private $objectManager; |
||
47 | |||
48 | /** |
||
49 | * @var Payment |
||
50 | */ |
||
51 | private $payment; |
||
52 | |||
53 | /** |
||
54 | * @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject |
||
55 | */ |
||
56 | private $scopeConfig; |
||
57 | |||
58 | /** |
||
59 | * @var Toolkit |
||
60 | */ |
||
61 | private $toolkitHelper; |
||
62 | |||
63 | View Code Duplication | protected function setUp() |
|
0 ignored issues
–
show
|
|||
64 | { |
||
65 | $this->objectManager = $this->getObjectManager(); |
||
66 | |||
67 | $this->scopeConfig = $this->getMockBuilder(ScopeConfigInterface::class)->disableOriginalConstructor()->getMock(); |
||
68 | $context = $this->objectManager->getObject(Context::class, ['scopeConfig' => $this->scopeConfig]); |
||
69 | |||
70 | $store = $this->getMockBuilder(StoreInterface::class)->disableOriginalConstructor()->getMock(); |
||
71 | $store->method('getCode')->willReturn(null); |
||
72 | |||
73 | $storeManager = $this->getMockBuilder(StoreManagerInterface::class)->disableOriginalConstructor()->getMock(); |
||
74 | $storeManager->method('getStore')->willReturn($store); |
||
75 | |||
76 | $this->toolkitHelper = $this->objectManager->getObject(Toolkit::class); |
||
77 | |||
78 | $this->payment = $this->objectManager->getObject(Payment::class, [ |
||
79 | 'context' => $context, |
||
80 | 'storeManager' => $storeManager, |
||
81 | 'toolkitHelper' => $this->toolkitHelper |
||
82 | ]); |
||
83 | } |
||
84 | |||
85 | public function testGetAvailablePaymentTypes() |
||
86 | { |
||
87 | $result = $this->payment->getAvailablePaymentTypes(); |
||
88 | $this->assertContains(PayoneConfig::METHOD_CREDITCARD, $result); |
||
89 | } |
||
90 | |||
91 | public function testGetAvailableCreditcardTypes() |
||
92 | { |
||
93 | $creditcardTypes = 'V,M'; |
||
94 | $expected = [ |
||
95 | ['id' => 'V', 'title' => 'Visa'], |
||
96 | ['id' => 'M', 'title' => 'Mastercard'] |
||
97 | ]; |
||
98 | $this->scopeConfig->expects($this->any()) |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Magento\Framework\App\Config\ScopeConfigInterface .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
99 | ->method('getValue') |
||
100 | ->willReturnMap([['payone_payment/'.PayoneConfig::METHOD_CREDITCARD.'/types', ScopeInterface::SCOPE_STORE, null, $creditcardTypes]]); |
||
101 | |||
102 | $result = $this->payment->getAvailableCreditcardTypes(); |
||
103 | $this->assertEquals($expected, $result); |
||
104 | } |
||
105 | |||
106 | View Code Duplication | public function testIsCheckCvcActive() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
107 | { |
||
108 | $this->scopeConfig->expects($this->any()) |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Magento\Framework\App\Config\ScopeConfigInterface .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
109 | ->method('getValue') |
||
110 | ->willReturnMap([['payone_payment/'.PayoneConfig::METHOD_CREDITCARD.'/check_cvc', ScopeInterface::SCOPE_STORE, null, 1]]); |
||
111 | $result = $this->payment->isCheckCvcActive(); |
||
112 | $this->assertTrue($result); |
||
113 | } |
||
114 | |||
115 | View Code Duplication | public function testIsMandateManagementActive() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
116 | { |
||
117 | $this->scopeConfig->expects($this->any()) |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Magento\Framework\App\Config\ScopeConfigInterface .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
118 | ->method('getValue') |
||
119 | ->willReturnMap([['payone_payment/'.PayoneConfig::METHOD_DEBIT.'/sepa_mandate_enabled', ScopeInterface::SCOPE_STORE, null, 1]]); |
||
120 | $result = $this->payment->isMandateManagementActive(); |
||
121 | $this->assertTrue($result); |
||
122 | } |
||
123 | |||
124 | View Code Duplication | public function testIsMandateManagementDownloadActive() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
125 | { |
||
126 | $this->scopeConfig->expects($this->any()) |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Magento\Framework\App\Config\ScopeConfigInterface .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
127 | ->method('getValue') |
||
128 | ->willReturnMap([['payone_payment/'.PayoneConfig::METHOD_DEBIT.'/sepa_mandate_download_enabled', ScopeInterface::SCOPE_STORE, null, 1]]); |
||
129 | $result = $this->payment->isMandateManagementDownloadActive(); |
||
130 | $this->assertTrue($result); |
||
131 | } |
||
132 | |||
133 | public function testGetStatusMappingByCode() |
||
134 | { |
||
135 | $mapping = [ |
||
136 | 'key' => [ |
||
137 | 'txaction' => 'appointed', |
||
138 | 'state_status' => 'processing' |
||
139 | ] |
||
140 | ]; |
||
141 | $this->scopeConfig->expects($this->any()) |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Magento\Framework\App\Config\ScopeConfigInterface .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
142 | ->method('getValue') |
||
143 | ->willReturnMap([['payone_general/statusmapping/'.PayoneConfig::METHOD_CREDITCARD, ScopeInterface::SCOPE_STORE, null, $this->toolkitHelper->serialize($mapping)]]); |
||
144 | $result = $this->payment->getStatusMappingByCode(PayoneConfig::METHOD_CREDITCARD); |
||
145 | $expected = ['appointed' => 'processing']; |
||
146 | $this->assertEquals($expected, $result); |
||
147 | } |
||
148 | |||
149 | public function testGetBankaccountCheckBlockedMessage() |
||
150 | { |
||
151 | $this->scopeConfig->expects($this->any()) |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Magento\Framework\App\Config\ScopeConfigInterface .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
152 | ->method('getValue') |
||
153 | ->willReturnMap([['payone_payment/'.PayoneConfig::METHOD_DEBIT.'/message_response_blocked/', ScopeInterface::SCOPE_STORE, null, '']]); |
||
154 | $result = $this->payment->getBankaccountCheckBlockedMessage(); |
||
155 | $expected = 'Bankdata invalid.'; |
||
156 | $this->assertEquals($expected, $result); |
||
157 | } |
||
158 | |||
159 | View Code Duplication | public function testIsPayPalExpressActive() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
160 | { |
||
161 | $this->scopeConfig->expects($this->any()) |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Magento\Framework\App\Config\ScopeConfigInterface .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
162 | ->method('getValue') |
||
163 | ->willReturnMap([['payone_payment/'.PayoneConfig::METHOD_PAYPAL.'/express_active', ScopeInterface::SCOPE_STORE, null, 1]]); |
||
164 | $result = $this->payment->isPayPalExpressActive(); |
||
165 | $this->assertTrue($result); |
||
166 | } |
||
167 | |||
168 | public function testGetPaymentAbbreviation() |
||
169 | { |
||
170 | $result = $this->payment->getPaymentAbbreviation(PayoneConfig::METHOD_CREDITCARD); |
||
171 | $expected = 'cc'; |
||
172 | $this->assertEquals($expected, $result); |
||
173 | |||
174 | $result = $this->payment->getPaymentAbbreviation('not_existing'); |
||
175 | $expected = 'unknown'; |
||
176 | $this->assertEquals($expected, $result); |
||
177 | } |
||
178 | } |
||
179 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.